:root {
    --bg: #f5f2eb;
    --card: #ffffff;
    --ink: #1c1a16;
    --muted: #6d675b;
    --line: #e2dccf;
    --soft: #efe9dd;
    --accent: #1f4e8c;
    --accent-ink: #ffffff;
    --accent-soft: #e3ecf8;
    --ring: #c62828;
    --ring-soft: #fdecea;
    --ok: #1b7a3a;
    --ok-soft: #e4f4e8;
    --wait: #a15c00;
    --wait-soft: #fff1dc;
    --shadow: 0 1px 2px rgba(40, 30, 10, .08), 0 2px 8px rgba(40, 30, 10, .06);
    --radius: 14px;
    color-scheme: light;
}

.kitchen {
    --accent: #9a4a00;
    --accent-soft: #fbead8;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14130f;
        --card: #1f1d18;
        --ink: #f2eee5;
        --muted: #a69f90;
        --line: #36322a;
        --soft: #2a2721;
        --accent: #6fa3e8;
        --accent-ink: #0d1520;
        --accent-soft: #1d2a3c;
        --ring: #ff6b5e;
        --ring-soft: #3a1b18;
        --ok: #5cc982;
        --ok-soft: #173222;
        --wait: #f0a64a;
        --wait-soft: #35260f;
        --shadow: none;
        color-scheme: dark;
    }

    .kitchen {
        --accent: #f0a050;
        --accent-soft: #3a2812;
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 16px 96px;
}

.ta {
    display: block;
    font-size: .82em;
    color: var(--muted);
    font-weight: 500;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: .85rem;
}

/* ---------- top bar ---------- */

.top {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--accent);
    color: var(--accent-ink);
}

.top .who {
    flex: 1;
    min-width: 0;
}

.top .who b {
    display: block;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top .who span {
    font-size: .8rem;
    opacity: .85;
}

.conn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    white-space: nowrap;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9e9e9e;
    flex: none;
}

.dot.on {
    background: #3ddc84;
}

.dot.off {
    background: #ff5252;
}

.icon-btn {
    border: 0;
    background: rgba(255, 255, 255, .16);
    color: inherit;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1.3rem;
    line-height: 1;
}

.banner {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--wait-soft);
    color: var(--wait);
    font-weight: 600;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.banner.bad {
    background: var(--ring-soft);
    color: var(--ring);
}

.banner button {
    border: 0;
    border-radius: 10px;
    padding: 8px 12px;
    background: currentColor;
    flex: none;
}

.banner button span {
    color: var(--card);
    font-weight: 700;
}

/* ---------- sections ---------- */

h2 {
    margin: 22px 0 10px;
    font-size: 1.05rem;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

h2 .ta {
    display: inline;
    font-size: .85rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.label {
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 14px 0 8px;
}

.label:first-child {
    margin-top: 0;
}

.label .ta {
    display: inline;
    text-transform: none;
    letter-spacing: 0;
}

/* ---------- tiles (tables, items, messages, waiters) ---------- */

.grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
}

.grid.wide {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.grid.list {
    grid-template-columns: 1fr;
}

.grid.two {
    grid-template-columns: 1fr 1fr;
}

.tile {
    position: relative;
    min-height: 52px;
    padding: 8px 6px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--soft);
    font-weight: 700;
    font-size: 1.05rem;
    text-align: center;
    line-height: 1.15;
    touch-action: manipulation;
}

.tile .ta {
    margin-top: 2px;
    font-size: .78rem;
}

.grid.two .tile {
    font-size: .95rem;
    text-align: left;
    padding: 10px 12px;
}

.grid.list .tile {
    text-align: left;
    padding: 10px 14px;
}

.tile.on {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.tile.on .ta {
    color: inherit;
    opacity: .85;
}

.tile:active {
    transform: scale(.97);
}

.tile .badge {
    position: absolute;
    top: -7px;
    right: -5px;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 13px;
    background: var(--ring);
    color: #fff;
    font-size: .9rem;
    line-height: 26px;
}

.tile .presence {
    position: absolute;
    top: 8px;
    right: 8px;
}

.tile.away {
    opacity: .55;
}

.chosen {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.chip {
    border: 0;
    border-radius: 999px;
    padding: 6px 10px 6px 12px;
    background: var(--accent-soft);
    color: var(--ink);
    font-weight: 600;
    font-size: .92rem;
}

.chip b {
    margin-left: 6px;
    color: var(--ring);
}

input[type=text],
input[type=password],
input[type=tel],
input[type=number],
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    font-size: 1rem;
}

input:focus,
textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.big {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 16px;
    border: 0;
    border-radius: 14px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.big .ta {
    color: inherit;
    opacity: .85;
}

.big:disabled {
    opacity: .4;
}

/* ---------- call cards ---------- */

.calls {
    display: grid;
    gap: 10px;
}

.call {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 6px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
}

.call.ringing {
    border-left-color: var(--ring);
}

.call.accepted {
    border-left-color: var(--ok);
}

.call.done,
.call.cancelled,
.call.missed {
    opacity: .7;
}

.call .row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.call .table {
    font-size: 1.5rem;
    font-weight: 800;
    min-width: 2ch;
}

.call .table small {
    display: block;
    font-size: .65rem;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
}

.call .what {
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.call .what .ta {
    display: inline;
}

.call .meta {
    margin-top: 6px;
    font-size: .85rem;
    color: var(--muted);
}

.pill {
    flex: none;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    background: var(--soft);
    color: var(--muted);
    white-space: nowrap;
}

.pill.ringing {
    background: var(--ring-soft);
    color: var(--ring);
}

.pill.accepted {
    background: var(--ok-soft);
    color: var(--ok);
}

.pill.missed {
    background: var(--wait-soft);
    color: var(--wait);
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.act {
    flex: 1 1 auto;
    min-height: 46px;
    padding: 8px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    background: var(--soft);
    font-weight: 700;
}

.act.go {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff;
}

.act.main {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.act .ta {
    display: inline;
    color: inherit;
    opacity: .85;
}

.items-list {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    font-size: 1.05rem;
    font-weight: 600;
}

.items-list li {
    display: inline-block;
    margin: 2px 10px 2px 0;
}

.items-list .q {
    color: var(--ring);
}

/* The call that is ringing right now: big, red, impossible to miss. */
.alert {
    margin-top: 12px;
    background: var(--ring);
    color: #fff;
    border-radius: 18px;
    padding: 16px;
    animation: pulse 1.2s ease-in-out infinite;
}

.alert .head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.alert .t {
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .08em;
    opacity: .9;
}

.alert .n {
    font-size: 3.2rem;
    font-weight: 900;
    line-height: 1;
}

.alert .msg {
    font-size: 1.25rem;
    font-weight: 800;
    margin-top: 8px;
}

.alert .ta,
.alert .items-list .q {
    color: #fff;
    opacity: .9;
}

.alert .meta {
    margin-top: 8px;
    font-size: .9rem;
    opacity: .9;
}

.alert .items-list {
    font-size: 1.3rem;
}

.alert .actions {
    margin-top: 14px;
    flex-wrap: nowrap;
}

.alert .ok {
    flex: 1.3 1 0;
    min-height: 58px;
    padding: 12px;
    border: 0;
    border-radius: 14px;
    background: #fff;
    color: var(--ring);
    font-size: 1.25rem;
    font-weight: 900;
}

.alert .act,
.alert .act.main {
    flex: 1 1 0;
    min-width: 0;
    background: rgba(255, 255, 255, .14);
    border: 1.5px solid rgba(255, 255, 255, .6);
    color: #fff;
}

.alert .act {
    padding: 8px 4px;
}

.alert .act .ta {
    display: block;
    font-size: .68rem;
}

.alert .ok .ta {
    display: inline;
    color: inherit;
}

@keyframes pulse {
    50% {
        box-shadow: 0 0 0 8px rgba(198, 40, 40, .25);
    }
}

@media (prefers-reduced-motion: reduce) {
    .alert {
        animation: none;
    }
}

.empty {
    padding: 14px;
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

/* ---------- join screen, menu, toast ---------- */

.join {
    max-width: 420px;
    margin: 0 auto;
    padding: 32px 16px 48px;
}

.join h1 {
    margin: 0;
    font-size: 1.7rem;
}

.join .lead {
    margin: 4px 0 24px;
    color: var(--muted);
}

.join .field {
    margin-bottom: 16px;
}

.join .roles {
    grid-template-columns: 1fr 1fr;
}

.join .roles .tile {
    min-height: 84px;
    font-size: 1.15rem;
}

.error {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--ring-soft);
    color: var(--ring);
    font-weight: 600;
}

.sheet-back {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sheet {
    width: 100%;
    max-width: 640px;
    background: var(--card);
    border-radius: 18px 18px 0 0;
    padding: 18px 16px 28px;
}

.sheet h3 {
    margin: 0 0 12px;
}

.sheet .line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.sheet .line:first-of-type {
    border-top: 0;
}

.check-ok {
    color: var(--ok);
    font-weight: 700;
}

.check-bad {
    color: var(--ring);
    font-weight: 700;
}

.toggle {
    min-width: 92px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 30;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    background: #222;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}

.toast.bad {
    background: var(--ring);
}

/* ---------- admin + install pages ---------- */

.page {
    max-width: 1040px;
    margin: 0 auto;
    padding: 20px 16px 64px;
}

.page header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.page h1 {
    margin: 0;
    font-size: 1.5rem;
}

.cols {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
}

.page .card h2 {
    margin-top: 0;
}

.stat {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    text-align: center;
}

.stat div {
    background: var(--soft);
    border-radius: 10px;
    padding: 10px 4px;
}

.stat b {
    display: block;
    font-size: 1.3rem;
}

.stat span {
    font-size: .78rem;
    color: var(--muted);
}

.pin {
    font-size: 2.4rem;
    font-weight: 900;
    letter-spacing: .15em;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

th,
td {
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.inline {
    display: flex;
    gap: 6px;
    align-items: center;
}

.inline input {
    padding: 6px 8px;
    max-width: 140px;
}

.btn {
    display: inline-block;
    padding: 9px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--soft);
    font-weight: 700;
    text-decoration: none;
    color: var(--ink);
}

.btn.main {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.btn.danger {
    color: var(--ring);
}

textarea {
    min-height: 150px;
    resize: vertical;
    font-family: inherit;
}

.flash {
    margin: 12px 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--ok-soft);
    color: var(--ok);
    font-weight: 600;
}

.steps {
    padding-left: 20px;
}

.steps li {
    margin-bottom: 10px;
}

.form-row {
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}
