:root {
    --ink: #172625;
    --muted: #667572;
    --line: #dce4e1;
    --paper: #f5f7f4;
    --white: #fff;
    --petrol: #0b6661;
    --petrol-dark: #084a47;
    --mint: #d9eee8;
    --red: #b63d3d;
    --red-soft: #fbe3e1;
    --shadow: 0 12px 35px rgba(22, 43, 40, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "IBM Plex Sans", sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand, .stat strong { font-family: "Manrope", sans-serif; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 40px); letter-spacing: 0; }
h2 { margin-bottom: 4px; font-size: 18px; }
.muted { margin-bottom: 0; color: var(--muted); }
.eyebrow { margin-bottom: 9px; color: var(--petrol); font-size: 12px; font-weight: 600; letter-spacing: .13em; }

.app-shell { min-height: 100vh; padding-left: 255px; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; display: flex; width: 255px; flex-direction: column; padding: 28px 20px 22px; background: var(--ink); color: #eaf2ef; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 700; }
.brand small { display: block; margin-top: 2px; color: #91aaa5; font-family: "IBM Plex Sans", sans-serif; font-size: 11px; font-weight: 400; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; flex: 0 0 auto; border-radius: 6px; background: #e6aa42; color: var(--ink); font-size: 14px; }
.sidebar nav { display: grid; gap: 7px; margin-top: 48px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 6px; color: #aec0bc; font-weight: 500; }
.sidebar nav a:hover, .sidebar nav a.active { background: #25413e; color: #fff; }
.sidebar-user { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; margin-top: auto; padding-top: 18px; border-top: 1px solid #38504d; }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; max-width: 112px; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { font-size: 13px; }
.sidebar-user small { color: #91aaa5; font-size: 11px; }
.sidebar-user .icon-button { width: 32px; color: #aec0bc; }
.sidebar-user .icon-button:hover, .sidebar-user .icon-button.active { background: #25413e; color: #fff; }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--mint); color: var(--petrol-dark); font-weight: 700; }
.avatar.small { width: 32px; height: 32px; font-size: 13px; }
.content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 42px 48px 64px; }
.company-switcher { display: flex; width: min(100%, 390px); align-items: center; gap: 8px; margin: 0 0 28px auto; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.company-switcher svg { flex: 0 0 auto; color: var(--petrol); }
.company-switcher select { min-height: 34px; margin: 0; padding: 4px 30px 4px 5px; border: 0; box-shadow: none; font-weight: 600; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-header.compact { align-items: flex-start; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 22px; color: var(--petrol); font-size: 14px; font-weight: 600; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 600; }
.button.primary { background: var(--petrol); color: #fff; }
.button.primary:hover { background: var(--petrol-dark); }
.button.secondary { border-color: var(--line); background: var(--white); color: var(--ink); }
.button.full { width: 100%; justify-content: space-between; }
.icon-button { display: inline-grid; width: 36px; height: 36px; place-items: center; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #687875; cursor: pointer; }
.icon-button:hover { background: #e7eeeb; color: var(--petrol); }
.danger-button:hover { background: var(--red-soft); color: var(--red); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { display: flex; min-height: 124px; align-items: center; gap: 16px; padding: 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.stat-icon { display: grid; width: 46px; height: 46px; place-items: center; flex: 0 0 auto; border-radius: 6px; }
.stat-icon.petrol { background: #dbecea; color: var(--petrol); }
.stat-icon.green { background: #e3eedb; color: #52733d; }
.stat-icon.amber { background: #fff1d5; color: #a16b16; }
.stat-icon.ink { background: #e3e9e8; color: var(--ink); }
.stat small, .stat strong { display: block; }
.stat small { margin-bottom: 5px; color: var(--muted); }
.stat strong { font-size: 23px; }
.stat-detail { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--white); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-heading p { font-size: 14px; }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--petrol); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 18px; background: #f8faf8; color: #71807d; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 16px 18px; border-top: 1px solid #e8eeec; font-size: 14px; vertical-align: middle; }
td strong, td small { display: block; }
td small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.stock, .role { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.stock.danger { background: var(--red-soft); color: var(--red); }
.stock.good { background: #e2f1e5; color: #397147; }
.role.admin { background: #dceceb; color: var(--petrol-dark); }
.role.raktaros { background: #eef0ef; color: #586561; }
.event-badge { display: inline-block; padding: 5px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.event-badge.global { background: #e3e9e8; color: var(--ink); }
.event-badge.local { background: var(--mint); color: var(--petrol-dark); }
.nowrap { white-space: nowrap; }
.actions { display: flex; align-items: center; gap: 2px; }
.actions form { margin: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; }
.search svg { position: absolute; top: 19px; left: 12px; color: #798985; }
.search input { width: 100%; padding-left: 40px; }
.check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.check input { width: auto; min-height: 0; margin: 0; }
.empty { padding: 60px 20px; color: var(--muted); text-align: center; }
.empty svg { width: 35px; height: 35px; margin-bottom: 14px; color: var(--petrol); }
.empty h3 { margin-bottom: 6px; color: var(--ink); }

input, select { width: 100%; min-height: 43px; margin-top: 7px; padding: 9px 11px; border: 1px solid #cbd6d2; border-radius: 5px; outline: 0; background: #fff; color: var(--ink); }
input:focus, select:focus { border-color: var(--petrol); box-shadow: 0 0 0 3px rgba(11, 102, 97, .1); }
label { color: #344542; font-size: 13px; font-weight: 600; }
label > small { display: block; margin-top: 6px; color: var(--muted); font-weight: 400; }
.editor-form { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--white); box-shadow: var(--shadow); }
.editor-form.narrow { max-width: 900px; }
.form-section { display: grid; grid-template-columns: 220px 1fr; gap: 38px; padding: 28px; border-bottom: 1px solid var(--line); }
.section-title p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.span-two { grid-column: 1 / -1; }
.company-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.company-check { display: flex; min-height: 58px; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fafbf9; }
.company-check input { width: auto; min-height: 0; margin: 0; }
.company-check strong, .company-check small { display: block; }
.company-check small { margin-top: 2px; color: var(--muted); font-weight: 400; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 28px; background: #fafbf9; }
.alert { margin-bottom: 20px; padding: 13px 15px; border: 1px solid; border-radius: 6px; font-size: 14px; }
.alert.success { border-color: #afd1b8; background: #e7f4e9; color: #2f653b; }
.alert.error { border-color: #e7b4b1; background: var(--red-soft); color: #8f3030; }

.login-shell { min-height: 100vh; min-height: 100dvh; background: #edf1ee; }
.login-layout { display: grid; min-height: 100vh; min-height: 100dvh; }
.login-panel { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; padding: 32px 20px; }
.login-card { width: min(100%, 410px); }
.login-brand { justify-content: center; margin-bottom: 36px; text-align: center; }
.login-card > div:not(.alert):not(.login-brand) { text-align: center; }
.login-card h1 { font-size: 34px; }
.form-stack { display: grid; gap: 16px; margin-top: 24px; }
.align-right { justify-self: end; }
.top-gap { margin-top: 28px; }
.segmented { display: inline-flex; margin-bottom: 16px; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.segmented a { padding: 7px 13px; border-radius: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.segmented a.active { background: var(--ink); color: var(--white); }
.movement-history { margin-top: 24px; }
.analytics-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
.chart-legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; }
.chart-legend .sale { background: #d98447; }
.chart-legend .receipt { background: var(--petrol); }
.movement-chart { display: grid; height: 280px; grid-template-columns: repeat(var(--chart-columns), minmax(14px, 1fr)); align-items: end; gap: 5px; padding: 26px 24px 20px; }
.chart-day { display: grid; height: 100%; grid-template-rows: 1fr 22px; gap: 8px; align-items: end; min-width: 0; }
.chart-bars { display: flex; height: 100%; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--line); }
.chart-bars span { width: min(12px, 42%); min-height: 2px; border-radius: 3px 3px 0 0; }
.chart-bars .sale { background: #d98447; }
.chart-bars .receipt { background: var(--petrol); }
.chart-day small { overflow: visible; color: var(--muted); font-size: 10px; text-align: center; white-space: nowrap; }
.ranking { margin: 0; padding: 10px 24px 14px 54px; }
.ranking li { padding: 14px 4px 14px 3px; border-bottom: 1px solid #e8eeec; color: var(--muted); }
.ranking li:last-child { border-bottom: 0; }
.ranking li::marker { color: var(--petrol); font-family: "Manrope", sans-serif; font-weight: 700; }
.ranking li > span { display: inline-block; max-width: calc(100% - 55px); vertical-align: middle; }
.ranking strong, .ranking small { display: block; }
.ranking strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.ranking small { margin-top: 2px; font-size: 11px; }
.ranking b { float: right; color: var(--ink); font-family: "Manrope", sans-serif; }
.empty.compact { padding-top: 42px; padding-bottom: 42px; }
.visually-hidden { position: absolute; overflow: hidden; width: 1px; height: 1px; clip: rect(0 0 0 0); white-space: nowrap; clip-path: inset(50%); }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid.three { grid-template-columns: repeat(2, 1fr); }
    .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { padding: 0 0 76px; }
    .sidebar { inset: auto 0 0; width: auto; height: 68px; flex-direction: row; align-items: center; padding: 8px 14px; }
    .sidebar > .brand, .sidebar-user > .avatar, .sidebar-user-info { display: none; }
    .sidebar nav { display: flex; flex: 1; justify-content: space-around; margin: 0; }
    .sidebar nav a { min-width: 0; flex-direction: column; gap: 2px; padding: 6px; font-size: 10px; }
    .sidebar nav svg { width: 20px; }
    .sidebar-user { margin: 0; padding: 0; border: 0; }
    .content { padding: 25px 16px 40px; }
    .company-switcher { width: 100%; margin-bottom: 22px; }
    .page-header { align-items: flex-start; }
    .page-header .button { flex: 0 0 auto; }
    .header-actions { width: 100%; flex-wrap: wrap; }
    .header-actions .button { flex: 1 1 auto; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat { min-height: 105px; padding: 15px; }
    .stat-icon { display: none; }
    .stat strong { font-size: 19px; }
    .toolbar { align-items: stretch; flex-wrap: wrap; }
    .search { flex-basis: 100%; }
    .form-section { grid-template-columns: 1fr; gap: 16px; padding: 22px 18px; }
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }
    .company-checks { grid-template-columns: 1fr; }
    .login-panel { padding: 20px; }
    .login-brand { margin-bottom: 28px; }
    .movement-chart { overflow-x: auto; grid-template-columns: repeat(var(--chart-columns), minmax(18px, 1fr)); }
    th, td { padding-right: 13px; padding-left: 13px; }
}

@media (max-width: 430px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .page-header > .button { width: 100%; }
    .check { width: 100%; }
    .toolbar > .button { flex: 1; }
}