:root {
    --ink: #171719;
    --ink-2: #2e3034;
    --muted: #73777f;
    --muted-2: #9a9da3;
    --line: #e3e4e7;
    --soft: #f4f5f7;
    --panel: #fff;
    --accent: #ef4e37;
    --accent-hover: #dc402c;
    --accent-soft: #fff0ed;
    --green: #148154;
    --green-soft: #eaf7f0;
    --amber: #9a6200;
    --amber-soft: #fff6df;
    --red: #c83d32;
    --red-soft: #fff0ef;
    --sidebar: #171719;
    --radius: 16px;
    --shadow: 0 18px 50px rgba(18, 20, 24, .09);
    color-scheme: light;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--soft); color: var(--ink); }
body { min-width: 320px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.is-hidden { display: none !important; }

.login-screen {
    min-height: 100svh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    padding: clamp(24px, 5vw, 56px);
    background:
        radial-gradient(circle at 85% 15%, rgba(239,78,55,.16), transparent 26rem),
        linear-gradient(145deg, #111113 0%, #1b1b1e 62%, #242327 100%);
    color: #fff;
}
.login-brand { font-size: 22px; font-weight: 800; letter-spacing: -.04em; }
.login-brand span, .sidebar-brand > span { color: var(--accent); }
.login-card { width: min(100%, 560px); align-self: center; justify-self: center; padding: clamp(28px, 5vw, 52px); border-radius: 24px; background: #fff; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.login-kicker, .section-kicker, .topbar-eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-card h1 { margin: 10px 0 12px; max-width: 420px; font-size: clamp(34px, 6vw, 54px); line-height: .96; letter-spacing: -.055em; }
.login-card > p { margin: 0 0 32px; max-width: 420px; color: var(--muted); line-height: 1.55; }
.login-card label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.login-input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.login-input-row input, .dialog-body input, .search-field, .select-field select { min-height: 46px; border: 1px solid var(--line); border-radius: 11px; background: #fff; outline: none; }
.login-input-row input, .dialog-body input { width: 100%; padding: 0 14px; }
input:focus, select:focus { border-color: var(--ink) !important; box-shadow: 0 0 0 3px rgba(23,23,25,.08); }
.login-note { align-self: end; justify-self: center; color: rgba(255,255,255,.55); font-size: 12px; }
.back-link { display: inline-block; margin-top: 28px; color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button, .danger-button, .store-button {
    min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    border-radius: 11px; border: 1px solid transparent; font-weight: 750; cursor: pointer; transition: .18s ease;
}
.primary-button { background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-hover); transform: translateY(-1px); }
.secondary-button, .store-button { border-color: var(--line); background: #fff; }
.secondary-button:hover, .store-button:hover { border-color: #b9bcc2; background: #fafafa; }
.danger-button { border-color: #f1c5c1; background: var(--red-soft); color: var(--red); }
.inline-button { width: fit-content; margin-top: 14px; }
.form-message { min-height: 20px; padding-top: 8px; color: var(--red); font-size: 12px; }

.admin-shell { min-height: 100svh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100svh; padding: 25px 16px 20px; display: flex; flex-direction: column; background: var(--sidebar); color: #fff; z-index: 30; }
.sidebar-brand { padding: 0 10px 24px; font-weight: 850; letter-spacing: -.035em; font-size: 17px; }
.sidebar-brand em { margin-left: 5px; color: #96969d; font-size: 11px; font-style: normal; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 45px; padding: 0 12px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 10px; background: transparent; color: #aeb0b7; cursor: pointer; text-align: left; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-item.is-active { color: #fff; background: #2d2d31; }
.nav-item b { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 20px; background: var(--accent); font-size: 11px; }
.sidebar-foot { margin-top: auto; padding: 18px 10px 0; display: grid; gap: 14px; border-top: 1px solid rgba(255,255,255,.1); color: #85858c; font-size: 12px; }
.sidebar-foot a { display: flex; align-items: center; gap: 9px; color: #d5d5d9; }
.sidebar-foot svg { width: 16px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 78px; padding: 14px clamp(20px, 3vw, 42px); display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(18px); }
.topbar h1 { margin: 3px 0 0; font-size: 22px; letter-spacing: -.035em; }
.topbar-eyebrow { color: var(--muted); font-size: 9px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync-state { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.sync-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.sync-state.is-loading i { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); animation: pulse 1s infinite alternate; }
.sync-state.is-error i { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
@keyframes pulse { to { opacity: .35; } }
.menu-button { display: none; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

.main-content { padding: clamp(24px, 3.5vw, 44px); }
.view { display: none; max-width: 1380px; margin: 0 auto; }
.view.is-active { display: block; animation: viewIn .24s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }
.page-intro { margin-bottom: 24px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-intro h2 { margin: 6px 0 5px; font-size: clamp(27px, 3vw, 38px); letter-spacing: -.05em; }
.page-intro p { margin: 0; color: var(--muted); line-height: 1.45; }
.compact-intro { align-items: center; }

.metric-grid { margin-bottom: 14px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.metric-card { min-height: 132px; padding: 18px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.metric-card > span { color: var(--muted); font-size: 13px; }
.metric-card strong { margin-top: 13px; font-size: 31px; line-height: 1; letter-spacing: -.045em; }
.metric-card small { margin-top: auto; color: var(--green); font-size: 12px; }
.metric-card.is-alert small { color: var(--amber); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.panel-head { min-height: 76px; padding: 17px 18px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0 0 5px; font-size: 15px; }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.text-button { padding: 8px 0; display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.text-button svg { width: 14px; }

.queue-row { min-height: 70px; padding: 12px 18px; display: grid; grid-template-columns: minmax(180px, 1.5fr) minmax(100px, .7fr) auto 34px; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.queue-row:last-child { border-bottom: 0; }
.queue-row strong, .table-main strong { display: block; font-size: 13px; }
.queue-row small, .table-main small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.queue-total { font-size: 13px; font-weight: 700; white-space: nowrap; }
.row-button, .icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }
.row-button:hover, .icon-button:hover { border-color: var(--ink); }
.row-button svg { width: 14px; }
.status-badge { width: fit-content; padding: 5px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 750; white-space: nowrap; }
.status-badge.pending { color: var(--red); background: var(--red-soft); }
.status-badge.confirmed, .status-badge.processing { color: var(--amber); background: var(--amber-soft); }
.status-badge.ready, .status-badge.completed { color: var(--green); background: var(--green-soft); }
.attention-panel { display: flex; flex-direction: column; }
.attention-list { flex: 1; padding: 8px 18px; }
.attention-row { padding: 12px 0; display: grid; grid-template-columns: 20px 1fr; gap: 9px; border-bottom: 1px solid var(--line); }
.attention-row:last-child { border-bottom: 0; }
.attention-row svg { width: 17px; color: var(--amber); }
.attention-row strong { display: block; font-size: 13px; }
.attention-row small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.wide-link { min-height: 48px; margin: 10px 18px 16px; padding: 0; display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; cursor: pointer; }

.toolbar { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.search-field { min-width: 280px; flex: 1; padding: 0 14px; display: flex; align-items: center; gap: 9px; color: var(--muted); }
.search-field input { width: 100%; min-height: 44px; border: 0; outline: none; background: transparent; }
.search-field input:focus { box-shadow: none; }
.select-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.select-field select { min-height: 46px; padding: 0 36px 0 12px; color: var(--ink); cursor: pointer; }
.table-panel { overflow: visible; }
.data-table { overflow: hidden; border-radius: inherit; }
.table-row { min-height: 72px; padding: 12px 16px; display: grid; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.table-row:last-child { border-bottom: 0; }
.table-row.orders { grid-template-columns: minmax(150px,1.35fr) minmax(135px,.8fr) 110px 100px 142px 34px; }
.table-row.catalog { grid-template-columns: minmax(210px,1.45fr) minmax(120px,.8fr) 104px 90px 110px 34px; }
.table-row.stock { grid-template-columns: minmax(220px,1.5fr) minmax(120px,.8fr) 110px 120px 34px; }
.table-row.table-header { min-height: 42px; background: #fafafa; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.table-cell { min-width: 0; font-size: 12px; }
.table-cell strong, .table-cell small { display: block; }
.table-cell small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.table-cell.muted { color: var(--muted); }
.table-cell.price { font-weight: 750; white-space: nowrap; }
.table-row select { width: 100%; min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 11px; }
.updated-at { color: var(--muted); font-size: 11px; }
.availability { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; }
.availability::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.availability.off::before { background: var(--red); }
.stock-summary { margin-bottom: 12px; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.stock-summary-card { padding: 16px; display: flex; align-items: baseline; gap: 9px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.stock-summary-card strong { font-size: 24px; letter-spacing: -.04em; }
.stock-summary-card span { color: var(--muted); font-size: 12px; }
.stock-value { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; }
.stock-value.low { color: var(--amber); }
.stock-value.zero { color: var(--red); }

.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.settings-card { min-height: 210px; padding: 24px; display: grid; grid-template-columns: 48px 1fr; align-items: start; gap: 17px; }
.settings-wide { grid-column: 1 / -1; min-height: auto; }
.settings-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--soft); }
.settings-card h3 { margin: 2px 0 9px; font-size: 17px; }
.settings-card p { max-width: 600px; margin: 0; color: var(--muted); line-height: 1.55; font-size: 13px; }
.settings-card .danger-button { margin-top: 18px; }
.system-list { margin: 18px 0 0; max-width: 520px; }
.system-list div { padding: 10px 0; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
.system-list dt { color: var(--muted); font-size: 12px; }
.system-list dd { margin: 0; font-size: 12px; font-weight: 700; text-align: right; }

.empty-state { min-height: 180px; padding: 36px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state strong { margin-bottom: 6px; color: var(--ink); }
.skeleton { background: linear-gradient(90deg,#f0f1f3,#fafafa,#f0f1f3); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

dialog { padding: 0; border: 0; background: transparent; }
dialog::backdrop { background: rgba(15,15,17,.52); backdrop-filter: blur(3px); }
.editor-dialog, .order-dialog { width: min(94vw, 560px); max-height: 92svh; }
.dialog-card { display: block; overflow: hidden; border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.dialog-head { padding: 21px 22px 17px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.dialog-head span { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.dialog-head h2 { margin: 5px 0 4px; font-size: 21px; letter-spacing: -.035em; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-body { max-height: 62svh; padding: 20px 22px; display: grid; gap: 16px; overflow-y: auto; }
.dialog-body > label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; }
.toggle-row { padding: 14px 0; grid-template-columns: 1fr auto !important; align-items: center; border-top: 1px solid var(--line); }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { margin-top: 4px; color: var(--muted); font-weight: 400; line-height: 1.4; }
.toggle-row input { width: 42px; height: 24px; accent-color: var(--accent); }
.dialog-actions { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 9px; }
.order-detail-section { padding: 2px 0 15px; border-bottom: 1px solid var(--line); }
.order-detail-section:last-child { border-bottom: 0; }
.order-detail-section h3 { margin: 0 0 9px; font-size: 12px; }
.order-detail-section p { margin: 4px 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.order-product { padding: 9px 0; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
.order-product strong { font-size: 12px; }
.order-product small { display: block; margin-top: 4px; color: var(--muted); }
.order-total { font-size: 18px; font-weight: 850; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 90; max-width: min(380px,calc(100vw - 32px)); padding: 13px 16px; border-radius: 11px; background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-error { background: var(--red); }

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .overview-grid { grid-template-columns: 1fr; }
    .table-row.orders { grid-template-columns: minmax(150px,1.4fr) minmax(120px,.8fr) 105px 130px 34px; }
    .table-row.orders > :nth-child(4), .table-row.orders.table-header > :nth-child(4) { display: none; }
    .table-row.catalog { grid-template-columns: minmax(190px,1.5fr) minmax(115px,.8fr) 92px 105px 34px; }
    .table-row.catalog > :nth-child(4), .table-row.catalog.table-header > :nth-child(4) { display: none; }
}

@media (max-width: 780px) {
    .admin-shell { display: block; }
    .sidebar { position: fixed; left: 0; top: 0; width: min(82vw, 280px); transform: translateX(-104%); transition: transform .22s ease; box-shadow: 20px 0 50px rgba(0,0,0,.25); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-scrim { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(0,0,0,.35); }
    .menu-button { display: grid; }
    .topbar { min-height: 68px; padding: 10px 16px; }
    .topbar-eyebrow { display: none; }
    .topbar h1 { margin: 0; font-size: 19px; }
    .sync-state span { display: none; }
    .store-button { width: 42px; padding: 0; }
    .store-button span { display: none; }
    .main-content { padding: 22px 14px 40px; }
    .page-intro { align-items: flex-start; }
    .page-intro h2 { font-size: 29px; }
    .page-intro .secondary-button { min-height: 40px; padding: 0 12px; }
    .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .metric-card { min-height: 115px; padding: 14px; }
    .metric-card strong { font-size: 25px; }
    .queue-row { grid-template-columns: 1fr auto 32px; gap: 8px; padding: 12px 14px; }
    .queue-row > :nth-child(2) { display: none; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .search-field { min-width: 0; }
    .select-field { justify-content: space-between; }
    .select-field select { flex: 1; }
    .table-row.orders, .table-row.catalog, .table-row.stock { padding: 15px 14px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 14px; }
    .table-row .row-button { position: static; transform: none; align-self: start; justify-self: end; }
    .table-row.orders { grid-template-areas: "main button" "customer price" "date date" "status status"; }
    .table-row.orders > :nth-child(1) { grid-area: main; }
    .table-row.orders > :nth-child(2) { grid-area: customer; display: block; }
    .table-row.orders > :nth-child(3) { grid-area: price; }
    .table-row.orders > :nth-child(4) { grid-area: date; display: block; }
    .table-row.orders > :nth-child(5) { grid-area: status; width: min(190px,100%); }
    .table-row.orders > :nth-child(6) { grid-area: button; }
    .table-row.catalog { grid-template-areas: "main button" "variant variant" "price state"; }
    .table-row.catalog > :nth-child(1) { grid-area: main; }
    .table-row.catalog > :nth-child(2) { grid-area: variant; display: block; }
    .table-row.catalog > :nth-child(3) { grid-area: price; }
    .table-row.catalog > :nth-child(4) { display: none; }
    .table-row.catalog > :nth-child(5) { grid-area: state; justify-self: end; }
    .table-row.catalog > :nth-child(6) { grid-area: button; }
    .table-row.stock { grid-template-areas: "main button" "variant variant" "amount available"; }
    .table-row.stock > :nth-child(1) { grid-area: main; }
    .table-row.stock > :nth-child(2) { grid-area: variant; display: block; }
    .table-row.stock > :nth-child(3) { grid-area: amount; }
    .table-row.stock > :nth-child(4) { grid-area: available; justify-self: end; }
    .table-row.stock > :nth-child(5) { grid-area: button; }
    .table-row.table-header { display: none; }
    .stock-summary { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-wide { grid-column: auto; }
}

@media (max-width: 520px) {
    .login-screen { padding: 20px; }
    .login-card { padding: 26px 20px; border-radius: 18px; }
    .login-card h1 { font-size: 38px; }
    .login-input-row { grid-template-columns: 1fr; }
    .login-input-row .primary-button { width: 100%; }
    .page-intro { flex-direction: column; }
    .page-intro .secondary-button { width: 100%; }
    .panel-head { padding: 15px 14px; }
    .attention-list { padding-inline: 14px; }
    .settings-card { grid-template-columns: 1fr; padding: 20px; }
    .settings-icon { width: 42px; height: 42px; }
    .dialog-actions > button { flex: 1; }
    .toast { right: 16px; bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
