:root {
    --kds-bg: #0b0e14;
    --kds-panel: #121721;
    --kds-panel-2: #171d29;
    --kds-card: #f8fafc;
    --kds-card-text: #111827;
    --kds-muted: #8590a3;
    --kds-border: rgba(255, 255, 255, .08);
    --kds-new: #5b8cff;
    --kds-preparing: #f5a623;
    --kds-ready: #20c77a;
    --kds-danger: #f05252;
    --kds-radius: 22px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--kds-bg); }
body.kds-app {
    min-height: 100vh;
    margin: 0;
    color: #f7f9fc;
    background:
        radial-gradient(circle at 12% -10%, rgba(91, 140, 255, .15), transparent 28%),
        radial-gradient(circle at 88% -8%, rgba(32, 199, 122, .1), transparent 26%),
        var(--kds-bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}
button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.kds-topbar {
    position: sticky;
    z-index: 80;
    top: 0;
    min-height: 76px;
    padding: 12px 22px;
    border-bottom: 1px solid var(--kds-border);
    background: rgba(11, 14, 20, .9);
    backdrop-filter: blur(18px);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 18px;
}
.kds-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.kds-brand__mark {
    width: 48px; height: 48px; flex: 0 0 48px; border-radius: 16px;
    color: #fff; background: linear-gradient(145deg, #ff8b3d, #e9503f);
    display: grid; place-items: center; font-size: 22px;
    box-shadow: 0 12px 28px rgba(233, 80, 63, .27);
}
.kds-brand p, .kds-history header p {
    margin: 0 0 2px; color: #ff9d66; font-size: 9px; font-weight: 900;
    letter-spacing: .16em; text-transform: uppercase;
}
.kds-brand h1 { margin: 0; font-size: 22px; line-height: 1; letter-spacing: -.03em; }
.kds-topbar__center { display: flex; align-items: center; gap: 14px; }
.kds-live {
    padding: 7px 10px; border: 1px solid rgba(32, 199, 122, .22); border-radius: 999px;
    color: #62e9aa; background: rgba(32, 199, 122, .08); font-size: 10px; font-weight: 850;
    display: inline-flex; align-items: center; gap: 6px;
}
.kds-live i { width: 7px; height: 7px; border-radius: 50%; background: #20c77a; box-shadow: 0 0 0 5px rgba(32, 199, 122, .12); }
.kds-clock { min-width: 58px; color: #dbe3ef; font-size: 20px; font-weight: 850; font-variant-numeric: tabular-nums; }
.kds-tools { justify-self: end; display: flex; align-items: center; gap: 7px; }
.kds-user { margin-right: 5px; text-align: right; line-height: 1.15; }
.kds-user span { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 850; }
.kds-user small { color: #56dda0; font-size: 9px; font-weight: 750; }
.kds-user small.is-offline { color: #ff7474; }
.kds-icon-button, .kds-logout {
    height: 42px; padding: 0 12px; border: 1px solid var(--kds-border); border-radius: 13px;
    color: #c5cedb; background: #171c26; text-decoration: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-size: 10px; font-weight: 800; transition: .18s ease;
}
.kds-icon-button:hover { color: #fff; border-color: rgba(255,255,255,.18); background: #202735; }
.kds-icon-button.is-active { color: #65e9ac; border-color: rgba(32,199,122,.32); background: rgba(32,199,122,.1); }
.kds-logout { color: #ff8585; border-color: rgba(240,82,82,.18); background: rgba(240,82,82,.08); }

.kds-main { width: min(1880px, 100%); margin: 0 auto; padding: 18px 20px 30px; }
.kds-summary { margin-bottom: 16px; display: grid; grid-template-columns: repeat(4, minmax(125px, 175px)) 1fr; gap: 10px; }
.kds-stat {
    min-height: 66px; padding: 10px 13px; border: 1px solid var(--kds-border); border-radius: 18px;
    background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.022));
    display: flex; align-items: center; gap: 11px;
}
.kds-stat > span { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; font-size: 15px; }
.kds-stat strong { display: block; font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.kds-stat small { margin-top: 4px; display: block; color: var(--kds-muted); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.kds-stat--new > span { color: #7ca5ff; background: rgba(91,140,255,.13); }
.kds-stat--preparing > span { color: #ffc762; background: rgba(245,166,35,.13); }
.kds-stat--ready > span { color: #58e6a2; background: rgba(32,199,122,.13); }
.kds-stat--late > span { color: #ff8585; background: rgba(240,82,82,.13); }
.kds-refresh {
    justify-self: end; align-self: center; min-height: 42px; padding: 0 14px; border: 1px solid var(--kds-border); border-radius: 13px;
    color: #c5cedb; background: #171c26; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 850;
}
.kds-refresh.is-loading i { animation: kds-spin .8s linear infinite; }

.kds-lane-tabs { display: none; }
.kds-board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.kds-lane {
    min-width: 0; min-height: calc(100vh - 190px); padding: 10px;
    border: 1px solid var(--kds-border); border-radius: 24px; background: rgba(18, 23, 33, .72);
}
.kds-lane__head { min-height: 61px; padding: 5px 7px 12px; display: flex; align-items: center; justify-content: space-between; }
.kds-lane__head > div { display: flex; align-items: center; gap: 10px; }
.kds-lane__head > b { min-width: 31px; height: 31px; padding: 0 8px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: #252c39; font-size: 12px; }
.kds-lane__icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; }
.kds-lane__head p { margin: 0 0 2px; color: var(--kds-muted); font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.kds-lane__head h2 { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.kds-lane--new .kds-lane__icon { color: #82a9ff; background: rgba(91,140,255,.13); }
.kds-lane--preparing .kds-lane__icon { color: #ffc65e; background: rgba(245,166,35,.13); }
.kds-lane--ready .kds-lane__icon { color: #5be7a5; background: rgba(32,199,122,.13); }
.kds-lane__orders { display: grid; gap: 11px; }

.kds-ticket {
    position: relative; color: var(--kds-card-text); background: var(--kds-card); border: 1px solid #e6ebf2; border-radius: var(--kds-radius);
    box-shadow: 0 12px 30px rgba(0,0,0,.19); overflow: hidden; transition: transform .18s ease, box-shadow .18s ease;
}
.kds-ticket::before { position: absolute; z-index: 2; top: 0; left: 0; right: 0; height: 4px; background: var(--kds-new); content: ""; }
.kds-ticket[data-lane="PREPARING"]::before { background: var(--kds-preparing); }
.kds-ticket[data-lane="READY"]::before { background: var(--kds-ready); }
.kds-ticket.is-warning::before { background: #f59e0b; }
.kds-ticket.is-late::before { height: 5px; background: var(--kds-danger); }
.kds-ticket.is-busy { opacity: .65; pointer-events: none; }
.kds-ticket__head { padding: 17px 16px 12px; border-bottom: 1px dashed #dbe1ea; }
.kds-ticket__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kds-ticket__table p { margin: 0 0 3px; color: #7a8494; font-size: 8px; font-weight: 900; text-transform: uppercase; letter-spacing: .13em; }
.kds-ticket__table h3 { margin: 0; font-size: 23px; line-height: 1; letter-spacing: -.04em; }
.kds-ticket__timer { min-width: 66px; padding: 8px 9px; border-radius: 12px; color: #386fd9; background: #edf3ff; text-align: center; }
.kds-ticket[data-lane="PREPARING"] .kds-ticket__timer { color: #b46c00; background: #fff3da; }
.kds-ticket[data-lane="READY"] .kds-ticket__timer { color: #078c54; background: #e5f9ef; }
.kds-ticket.is-late .kds-ticket__timer { color: #c62f3b; background: #ffebed; }
.kds-ticket__timer strong { display: block; font-size: 15px; line-height: 1; font-variant-numeric: tabular-nums; }
.kds-ticket__timer span { margin-top: 3px; display: block; font-size: 7px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.kds-ticket__meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.kds-ticket__meta span { padding: 5px 7px; border-radius: 8px; color: #5f6978; background: #eef1f5; font-size: 8px; font-weight: 800; }
.kds-ticket__meta i { margin-right: 3px; }

.kds-ticket__note { margin: 0 13px 2px; padding: 10px 11px; border-left: 3px solid #ee705e; border-radius: 10px; color: #8e382d; background: #fff0ed; font-size: 10px; font-weight: 750; line-height: 1.35; }
.kds-item-group { border-bottom: 1px solid #e7ebf1; }
.kds-item-group__head { min-height: 40px; padding: 8px 14px 3px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kds-item-group__head > div { color: #737f91; display: flex; align-items: center; gap: 6px; font-size: 8px; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.kds-item-group[data-item-group="ready"] .kds-item-group__head > div { color: #a36507; }
.kds-select-all { color: #4f5d70; display: inline-flex; align-items: center; gap: 6px; font-size: 9px; font-weight: 900; cursor: pointer; }
.kds-select-all input { position: absolute; opacity: 0; pointer-events: none; }
.kds-select-all > span { width: 21px; height: 21px; border: 2px solid #c6cfdb; border-radius: 7px; color: transparent; background: #fff; display: grid; place-items: center; }
.kds-select-all input:checked + span { color: #fff; border-color: #4e7fe8; background: #4e7fe8; }
.kds-select-all input:indeterminate + span { color: #fff; border-color: #7b8ba3; background: #7b8ba3; }
.kds-select-all input:indeterminate + span i::before { content: "\f068"; }
.kds-items { padding: 3px 12px 7px; display: grid; gap: 4px; }
.kds-item {
    position: relative; min-height: 57px; padding: 9px 8px; border: 1px solid transparent; border-radius: 13px;
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: flex-start; gap: 9px;
}
.kds-item:hover { background: #f0f4f9; }
.kds-item.is-selected { border-color: #a7c0fa; background: #edf3ff; }
.kds-item.is-ready { color: #597064; background: #ecf9f2; }
.kds-item__check { position: relative; width: 25px; height: 25px; margin-top: 1px; }
.kds-item__check input { position: absolute; opacity: 0; pointer-events: none; }
.kds-item__check span { width: 25px; height: 25px; border: 2px solid #cbd3df; border-radius: 8px; background: #fff; display: grid; place-items: center; color: transparent; cursor: pointer; }
.kds-item__check input:checked + span { color: #fff; border-color: #4e7fe8; background: #4e7fe8; }
.kds-item__check--ready span { color: #fff; border-color: #20b56e; background: #20b56e; cursor: default; }
.kds-item__copy { min-width: 0; }
.kds-item__name { font-size: 12px; font-weight: 900; line-height: 1.25; }
.kds-item__qty { color: #315ebd; margin-right: 4px; font-size: 14px; }
.kds-item__detail { margin-top: 4px; color: #667181; font-size: 9px; font-weight: 650; line-height: 1.35; }
.kds-item__detail--note { color: #a7463a; }
.kds-item__status { margin-top: 3px; padding: 4px 6px; border-radius: 7px; color: #7f5a08; background: #fff1cc; font-size: 7px; font-weight: 950; text-transform: uppercase; letter-spacing: .06em; }
.kds-item.is-ready .kds-item__status { color: #077d4c; background: #d8f5e7; }
.kds-item__new { margin-top: 5px; display: inline-flex; padding: 4px 6px; border-radius: 7px; color: #c73b45; background: #ffebed; font-size: 7px; font-weight: 950; text-transform: uppercase; }

.kds-ticket__actions { padding: 10px 12px 13px; border-top: 1px solid #e7ebf1; background: #f3f6fa; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.kds-ticket__actions.is-single { grid-template-columns: 1fr; }
.kds-action {
    min-height: 46px; padding: 0 11px; border: 0; border-radius: 13px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 10px; font-weight: 900; transition: .15s ease;
}
.kds-action:disabled { opacity: .48; cursor: not-allowed; }
.kds-action--start { color: #fff; background: linear-gradient(135deg, #f4a620, #e77f19); box-shadow: 0 10px 22px rgba(231,127,25,.22); }
.kds-action--selected { color: #2455b5; border: 1px solid #b8caf0; background: #eaf1ff; }
.kds-action--ready { color: #fff; background: linear-gradient(135deg, #22bd77, #0b9c5c); box-shadow: 0 10px 22px rgba(11,156,92,.22); }
.kds-ready-banner { padding: 14px; color: #087c4c; background: #e7f9f0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 10px; font-weight: 900; }
.kds-ready-banner i { width: 25px; height: 25px; border-radius: 50%; color: #fff; background: #17ad68; display: grid; place-items: center; }

.kds-empty { min-height: 170px; padding: 22px; border: 1px dashed rgba(255,255,255,.1); border-radius: 18px; display: grid; place-items: center; text-align: center; }
.kds-empty i { width: 48px; height: 48px; margin: 0 auto 11px; border-radius: 16px; color: #6f7d91; background: rgba(255,255,255,.05); display: grid; place-items: center; font-size: 19px; }
.kds-empty strong { display: block; font-size: 12px; }
.kds-empty span { margin-top: 5px; display: block; color: var(--kds-muted); font-size: 9px; line-height: 1.4; }
.kds-loading { min-height: 150px; color: var(--kds-muted); display: grid; place-items: center; gap: 8px; font-size: 11px; }

.kds-history-layer { position: fixed; z-index: 180; inset: 0; background: rgba(3,6,10,.7); backdrop-filter: blur(7px); opacity: 0; visibility: hidden; transition: .2s ease; }
.kds-history-layer.is-open { opacity: 1; visibility: visible; }
.kds-history { position: absolute; top: 0; right: 0; width: min(560px, 100%); height: 100%; color: #f5f7fb; background: #111620; box-shadow: -25px 0 70px rgba(0,0,0,.38); transform: translateX(100%); transition: transform .25s ease; }
.kds-history-layer.is-open .kds-history { transform: translateX(0); }
.kds-history header { min-height: 82px; padding: 18px 20px; border-bottom: 1px solid var(--kds-border); display: flex; align-items: center; justify-content: space-between; }
.kds-history header h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.kds-history header button { width: 42px; height: 42px; border: 1px solid var(--kds-border); border-radius: 13px; color: #d6deea; background: #1a202b; cursor: pointer; }
.kds-history__content { height: calc(100% - 82px); padding: 14px; overflow-y: auto; }
.kds-history-item { margin-bottom: 9px; padding: 14px; border: 1px solid var(--kds-border); border-radius: 17px; background: #181e29; display: grid; grid-template-columns: 43px 1fr auto; gap: 11px; align-items: center; }
.kds-history-item__icon { width: 43px; height: 43px; border-radius: 14px; color: #5ce8a7; background: rgba(32,199,122,.12); display: grid; place-items: center; }
.kds-history-item h3 { margin: 0 0 4px; font-size: 13px; }
.kds-history-item p { margin: 0; color: #919cad; font-size: 9px; line-height: 1.4; }
.kds-history-item time { color: #778397; font-size: 9px; white-space: nowrap; }
.kds-history-empty { min-height: 300px; display: grid; place-items: center; color: #8590a3; text-align: center; font-size: 11px; }

.kds-toast-stack { position: fixed; z-index: 260; right: 17px; bottom: 17px; width: min(390px, calc(100% - 34px)); display: grid; gap: 8px; }
.kds-toast { padding: 13px 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 15px; color: #fff; background: #242b37; box-shadow: 0 18px 45px rgba(0,0,0,.32); display: flex; align-items: center; gap: 9px; font-size: 10px; font-weight: 800; animation: kds-toast-in .2s ease; }
.kds-toast.is-success { background: #087b4f; }
.kds-toast.is-error { background: #b93440; }

.kds-audio-gate {
    position: fixed; z-index: 320; inset: 0; padding: 20px; background: rgba(3,6,10,.82); backdrop-filter: blur(9px);
    display: grid; place-items: center; opacity: 0; visibility: hidden; transition: .2s ease;
}
.kds-audio-gate.is-open { opacity: 1; visibility: visible; }
.kds-audio-gate__card {
    width: min(440px, 100%); padding: 30px; border: 1px solid rgba(255,255,255,.12); border-radius: 27px;
    color: #f7f9fc; background: linear-gradient(145deg, #1a202b, #11161f); box-shadow: 0 30px 90px rgba(0,0,0,.48); text-align: center;
}
.kds-audio-gate.is-attention .kds-audio-gate__card { border-color: rgba(255,169,49,.6); box-shadow: 0 30px 90px rgba(0,0,0,.48), 0 0 0 5px rgba(255,154,29,.08); }
.kds-audio-gate__icon {
    width: 74px; height: 74px; margin: 0 auto 18px; border-radius: 24px; color: #fff;
    background: linear-gradient(145deg, #ff9d29, #ed5d42); box-shadow: 0 16px 35px rgba(237,93,66,.3); display: grid; place-items: center; font-size: 29px;
}
.kds-audio-gate__card p { margin: 0 0 7px; color: #ffa94d; font-size: 10px; font-weight: 950; letter-spacing: .11em; text-transform: uppercase; }
.kds-audio-gate__card h2 { margin: 0 0 10px; font-size: clamp(23px, 5vw, 31px); letter-spacing: -.04em; }
.kds-audio-gate__card > span:not(.kds-audio-gate__icon) { color: #9ba7b9; display: block; font-size: 12px; line-height: 1.55; }
.kds-audio-gate__primary, .kds-audio-gate__secondary { width: 100%; min-height: 52px; border: 0; border-radius: 15px; cursor: pointer; font-weight: 900; }
.kds-audio-gate__primary { margin-top: 22px; color: #fff; background: linear-gradient(135deg, #ff9d22, #ed6b22); box-shadow: 0 13px 28px rgba(237,107,34,.25); }
.kds-audio-gate__secondary { margin-top: 8px; color: #909caf; background: transparent; }

@keyframes kds-spin { to { transform: rotate(360deg); } }
@keyframes kds-toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
    .kds-topbar { grid-template-columns: 1fr auto; }
    .kds-topbar__center { display: none; }
    .kds-user { display: none; }
    .kds-summary { grid-template-columns: repeat(4, 1fr) auto; }
    .kds-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .kds-topbar { min-height: 68px; padding: 9px 11px; gap: 8px; }
    .kds-brand__mark { width: 43px; height: 43px; flex-basis: 43px; border-radius: 14px; }
    .kds-brand h1 { font-size: 18px; }
    .kds-tools { gap: 4px; }
    .kds-icon-button, .kds-logout { width: 39px; height: 39px; padding: 0; }
    .kds-icon-button span, .kds-logout span, .kds-tools [data-fullscreen] { display: none; }
    .kds-main { padding: 11px 9px 22px; }
    .kds-summary { margin-bottom: 10px; grid-template-columns: repeat(4, 1fr); gap: 5px; }
    .kds-stat { min-height: 55px; padding: 8px; border-radius: 14px; gap: 7px; }
    .kds-stat > span { width: 31px; height: 31px; border-radius: 10px; font-size: 12px; }
    .kds-stat strong { font-size: 17px; }
    .kds-stat small { font-size: 7px; }
    .kds-refresh { position: fixed; z-index: 70; right: 12px; bottom: 13px; width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 16px; box-shadow: 0 12px 30px rgba(0,0,0,.32); }
    .kds-refresh span { display: none; }
    .kds-lane-tabs { margin-bottom: 9px; padding: 4px; border: 1px solid var(--kds-border); border-radius: 15px; background: #141923; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
    .kds-lane-tabs button { min-height: 40px; padding: 0 5px; border: 0; border-radius: 11px; color: #8894a7; background: transparent; font-size: 9px; font-weight: 850; }
    .kds-lane-tabs button.is-active { color: #fff; background: #262e3b; }
    .kds-lane-tabs b { margin-left: 3px; }
    .kds-board { display: block; }
    .kds-lane { display: none; min-height: calc(100vh - 175px); padding: 8px; border-radius: 19px; }
    .kds-lane.is-mobile-active { display: block; }
    .kds-lane__head { min-height: 54px; }
    .kds-ticket__table h3 { font-size: 22px; }
    .kds-action { min-height: 49px; }
    .kds-history-item { grid-template-columns: 40px 1fr; }
    .kds-history-item time { grid-column: 2; }
}

@media (max-width: 390px) {
    .kds-brand p { display: none; }
    .kds-stat > span { display: none; }
    .kds-stat { justify-content: center; text-align: center; }
    .kds-ticket__actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
