:root {
    --green: #1b8f4c;
    --red: #d1302f;
    --orange: #e07b1a;
    --yellow: #e0b400;
    --blue: #2563eb;
    --purple: #7c3aed;
    --grey: #6b7280;
    --bg: #f1f3f7;
    --card-bg: #fff;
    --text: #0f172a;
    --muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-bg: #0f1b2d;
    --sidebar-bg2: #16263d;
    --sidebar-active: #1e3a5f;
    --felt-dark: #123a1f;
    --felt-light: #1d5a32;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; }

/* ===== App shell: sidebar + main ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg2));
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-ball {
    width: 36px; height: 36px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff 0 8%, #fbbf24 10% 55%, #92400e 100%);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; color: #1c1c1c; font-size: 14px;
    flex-shrink: 0;
}

.brand-title { font-weight: 700; font-size: 14px; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.sidebar__nav { display: flex; flex-direction: column; padding: 10px; gap: 2px; flex: 1; }

.sidebar__nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px;
    color: #cbd5e1; text-decoration: none; font-size: 14px;
}

.sidebar__nav a:hover { background: rgba(255,255,255,.06); }
.sidebar__nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 13px; opacity: .85; }

.sidebar__logout { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar__logout button {
    width: 100%; display: flex; align-items: center; gap: 10px;
    background: none; border: none; color: #cbd5e1; padding: 10px 12px;
    cursor: pointer; font-size: 14px; border-radius: 8px;
}
.sidebar__logout button:hover { background: rgba(255,255,255,.06); color: #fff; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 14px;
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 14px 24px; position: sticky; top: 0; z-index: 10;
}

.burger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.page-title { font-size: 19px; margin: 0; flex: 1; }

.topbar__right { display: flex; align-items: center; gap: 18px; }
.topbar__clock { font-size: 13px; color: var(--muted); white-space: nowrap; }

.topbar__profile { display: flex; align-items: center; gap: 8px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}
.profile-name { font-size: 13px; font-weight: 600; line-height: 1.1; }
.profile-role { font-size: 11px; color: var(--muted); }

.app-content { padding: 20px 24px; flex: 1; }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 100; transition: left .2s; box-shadow: 4px 0 16px rgba(0,0,0,.2); }
    body.sidebar-open .sidebar { left: 0; }
    .burger { display: block; }
    .topbar__clock { display: none; }
}

/* ===== Generic UI ===== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.status { padding: 10px 14px; border-radius: 8px; background: #ecfdf5; color: #065f46; margin-bottom: 16px; }
.alert { padding: 10px 14px; border-radius: 8px; background: #fef2f2; color: #991b1b; margin-bottom: 12px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.data th { background: #f9fafb; color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }

.btn {
    display: inline-block;
    background: #e5e7eb;
    color: #111827;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    margin: 4px 4px 4px 0;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }

.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Shared page chrome ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    margin-bottom: 18px;
}
.page-header h1 { font-size: 20px; margin: 0; display: flex; align-items: center; gap: 10px; }
.page-header .page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-header .muted { margin-top: 2px; }

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

.toolbar {
    display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
    margin-bottom: 16px;
}
.toolbar .field { margin-bottom: 0; min-width: 160px; }

.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-grey { background: #e5e7eb; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

.card-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.card-head h3 { margin: 0; font-size: 15px; }

.table-wrap { overflow-x: auto; }
table.data tbody tr:hover { background: #f9fafb; }
table.data .text-right { text-align: right; }
table.data .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .ico { font-size: 34px; margin-bottom: 10px; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f9fafb; }

.tab-nav { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-nav a {
    padding: 8px 14px; border-radius: 8px; font-size: 13.5px; text-decoration: none; color: var(--muted);
    background: #fff; border: 1px solid var(--border);
}
.tab-nav a.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.section-card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin: 0 0 12px; }

/* ===== Dashboard stat cards ===== */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    border-radius: 12px; padding: 18px; color: #fff;
    display: flex; align-items: center; gap: 14px;
}
.stat-card .ico { font-size: 22px; width: 46px; height: 46px; border-radius: 10px; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-card .value { font-size: 24px; font-weight: 800; line-height: 1; }
.stat-card .label { font-size: 12.5px; opacity: .92; margin-top: 4px; }

.stat-card--blue { background: linear-gradient(135deg,#2563eb,#1e40af); }
.stat-card--green { background: linear-gradient(135deg,#22c55e,#15803d); }
.stat-card--red { background: linear-gradient(135deg,#ef4444,#b91c1c); }
.stat-card--yellow { background: linear-gradient(135deg,#f59e0b,#b45309); }
.stat-card--grey { background: linear-gradient(135deg,#6b7280,#374151); }
.stat-card--purple { background: linear-gradient(135deg,#8b5cf6,#5b21b6); }

.dash-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .dash-grid, .dash-grid-2 { grid-template-columns: 1fr; } }

.kv-list { display: flex; flex-direction: column; gap: 10px; }
.kv-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 8px; background: #f9fafb; }
.kv-row .kv-label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.kv-row .kv-value { font-weight: 700; }
.kv-row.danger .kv-value { color: var(--red); }

.mini-status-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr)); gap: 10px; }
.mini-status-card { border-radius: 10px; padding: 14px; text-align: center; }
.mini-status-card .value { font-size: 22px; font-weight: 800; }
.mini-status-card .label { font-size: 12px; margin-top: 2px; }
.mini-status-card--green { background: #dcfce7; color: #166534; }
.mini-status-card--red { background: #fee2e2; color: #991b1b; }
.mini-status-card--yellow { background: #fef3c7; color: #92400e; }
.mini-status-card--grey { background: #e5e7eb; color: #374151; }

.pill-badge { padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; color: #fff; }
.pill-badge--red { background: var(--red); }
.pill-badge--green { background: var(--green); }
.pill-badge--yellow { background: var(--yellow); color: #111; }

/* ===== Cashier dashboard ===== */
.cashier { padding: 0; }
.cashier-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
    background: linear-gradient(135deg, #14532d, #166534);
    color: #fff; padding: 14px 20px; border-radius: 12px;
}
.cashier-header h1 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.cashier-header .muted { color: #d1fae5; }

.header-counts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { padding: 7px 14px; border-radius: 20px; font-size: 13px; font-weight: 700; color: #fff; }
.pill-green { background: #22c55e; }
.pill-red { background: #ef4444; }
.pill-yellow { background: #eab308; color: #111; }
.pill-grey { background: #9ca3af; }

.view-toggle { display: flex; gap: 2px; background: rgba(255,255,255,.15); border-radius: 20px; padding: 3px; margin-left: 4px; }
.view-toggle button {
    border: none; background: none; color: #fff; padding: 6px 14px; border-radius: 18px;
    font-size: 12.5px; font-weight: 600; cursor: pointer; opacity: .75;
}
.view-toggle button.active { background: #fff; color: #14532d; opacity: 1; }

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

.cashier-floor {
    position: relative;
    width: 100%;
    min-height: 560px;
    background:
        linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px) 0 0 / 40px 40px,
        linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px) 0 0 / 40px 40px,
        #eef1f5;
    border: 2px dashed var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.table-card--floor { width: 160px; }

@media (max-width: 640px) {
    .cashier-floor { min-height: 820px; }
    .table-card--floor { width: 130px; padding: 12px 10px; }
}

.table-card {
    position: relative;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 16px 14px;
    text-align: left;
    cursor: pointer;
    color: #fff;
    min-height: 118px;
    font-family: inherit;
    background:
        radial-gradient(circle at 20% 10%, rgba(255,255,255,.12), transparent 40%),
        linear-gradient(160deg, var(--felt-light), var(--felt-dark));
    box-shadow: inset 0 0 0 6px rgba(120,53,15,.55), 0 3px 8px rgba(0,0,0,.25);
}

.table-card::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: 14px;
    box-shadow: inset 0 0 20px rgba(0,0,0,.25);
    pointer-events: none;
}

.table-card--green { box-shadow: inset 0 0 0 6px rgba(21,128,61,.6), 0 3px 8px rgba(0,0,0,.25); }
.table-card--red { background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.14), transparent 40%), linear-gradient(160deg,#b91c1c,#5c0a0a); box-shadow: inset 0 0 0 6px rgba(127,29,29,.6), 0 3px 8px rgba(0,0,0,.25); }
.table-card--orange { background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.14), transparent 40%), linear-gradient(160deg,#ea580c,#7c2d12); box-shadow: inset 0 0 0 6px rgba(124,45,18,.6), 0 3px 8px rgba(0,0,0,.25); }
.table-card--yellow { background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.18), transparent 40%), linear-gradient(160deg,#d97706,#78350f); box-shadow: inset 0 0 0 6px rgba(120,53,15,.6), 0 3px 8px rgba(0,0,0,.25); }
.table-card--blue { background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.14), transparent 40%), linear-gradient(160deg,#1d4ed8,#1e3a8a); box-shadow: inset 0 0 0 6px rgba(30,58,138,.6), 0 3px 8px rgba(0,0,0,.25); }
.table-card--grey { background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.1), transparent 40%), linear-gradient(160deg,#6b7280,#374151); box-shadow: inset 0 0 0 6px rgba(55,65,81,.6), 0 3px 8px rgba(0,0,0,.25); }
.table-card--purple { background: radial-gradient(circle at 20% 10%, rgba(255,255,255,.14), transparent 40%), linear-gradient(160deg,#9333ea,#4c1d95); box-shadow: inset 0 0 0 6px rgba(76,29,149,.6), 0 3px 8px rgba(0,0,0,.25); }

.table-card.is-selected { border-color: #fbbf24; }

.table-card--shake {
    animation: table-shake 0.4s infinite;
    border-color: #fbbf24 !important;
    box-shadow: 0 0 0 3px rgba(251,191,36,.6), 0 3px 10px rgba(0,0,0,.3) !important;
}
@keyframes table-shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    20% { transform: translateX(-3px) rotate(-1.5deg); }
    40% { transform: translateX(3px) rotate(1.5deg); }
    60% { transform: translateX(-3px) rotate(-1deg); }
    80% { transform: translateX(3px) rotate(1deg); }
}

.table-card__number { font-weight: 800; font-size: 15px; margin-bottom: 10px; letter-spacing: .02em; }
.table-card__status {
    font-size: 11.5px; font-weight: 700; margin-bottom: 14px;
    display: inline-block; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.25);
}
.table-card__amount { font-size: 18px; font-weight: 800; }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-green { background: #22c55e; } .dot-red { background: #ef4444; } .dot-yellow { background: #eab308; }
.dot-orange { background: #ea580c; } .dot-blue { background: #1d4ed8; } .dot-grey { background: #6b7280; }
.dot-purple { background: #9333ea; }

.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
    overflow-y: auto;
    z-index: 50;
}

.side-panel__head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #14532d, #166534);
    color: #fff;
}
.side-panel__head h2 { font-size: 16px; margin: 0; }
.side-panel__body { padding: 20px; }
.btn-close { background: rgba(255,255,255,.15); border: none; color: #fff; font-size: 18px; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; }

.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.info-row .k { color: var(--muted); }
.info-row .v { font-weight: 600; }

.timer-box { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 14px; text-align: center; margin: 14px 0; }
.timer-box .timer-value { font-size: 30px; font-weight: 800; color: #15803d; font-variant-numeric: tabular-nums; }
.timer-box .timer-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.timer-box--alert { background: #fef2f2; border-color: #fecaca; animation: timer-pulse 1s infinite; }
.timer-box--alert .timer-value, .timer-box--alert .timer-label { color: #b91c1c; }

.timer-box--ended { background: #fef2f2; border-color: #fca5a5; animation: none; }
.timer-box--ended .timer-value, .timer-box--ended .timer-label { color: #991b1b; }
@keyframes timer-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.45); }
    50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.bill { font-size: 22px; font-weight: 800; margin: 14px 0; color: #0f172a; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions .btn { flex: 1; min-width: 120px; text-align: center; }
.invoice-box { background: #f9fafb; border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 14px; }
.credit-sale-box { background: #fffbeb; border: 1px dashed #fcd34d; border-radius: 8px; padding: 12px; margin-top: 14px; }

.header-action-btn { margin-left: 6px; }

/* Day Summary / Add Expense modals */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 20px;
}
.modal-box {
    background: #fff; border-radius: 14px; width: 100%; max-width: 420px;
    max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.modal-box--wide { max-width: 760px; }
.modal-box__head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; background: linear-gradient(135deg, #14532d, #166534); color: #fff;
    border-radius: 14px 14px 0 0; position: sticky; top: 0; z-index: 1;
}
.modal-box__head h2 { font-size: 16px; margin: 0; }
.modal-box__subhead { padding: 10px 20px; background: #f0fdf4; color: #166534; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.modal-box__body { padding: 20px; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.summary-section {
    background: #f9fafb; border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.summary-section h3 { margin: 0 0 10px; font-size: 14px; }
.summary-section--balance { grid-column: 1 / -1; background: #fffbeb; border-color: #fcd34d; }
.balance-row { font-weight: 800; font-size: 16px; border-top: 2px solid #fcd34d; padding-top: 10px; margin-top: 4px; }
.balance-row .v { color: #b45309; }

@media (max-width: 640px) {
    .summary-grid { grid-template-columns: 1fr; }
}
.suggestions { list-style: none; padding: 0; margin: 4px 0; border: 1px solid var(--border); border-radius: 6px; max-height: 140px; overflow-y: auto; }
.suggestions li { padding: 8px; cursor: pointer; font-size: 13px; }
.suggestions li:hover { background: #f3f4f6; }

.btn-ico { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

@media (max-width: 640px) {
    .side-panel { width: 100%; }
}

/* Receipt */
.receipt { width: 280px; margin: 20px auto; font-family: "Courier New", monospace; font-size: 12px; }
.receipt h2 { text-align: center; margin: 0; }
.receipt .center { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #000; }
.receipt table { width: 100%; }
.receipt td { padding: 2px 0; }

/* Floor plan editor */
.floor-canvas {
    position: relative;
    width: 100%;
    height: 520px;
    background:
        linear-gradient(rgba(0,0,0,.04) 1px, transparent 1px) 0 0 / 40px 40px,
        linear-gradient(90deg, rgba(0,0,0,.04) 1px, transparent 1px) 0 0 / 40px 40px,
        #f3f4f6;
    border: 2px dashed var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.floor-table {
    position: absolute;
    width: 110px;
    min-height: 70px;
    border-radius: 10px;
    color: #fff;
    padding: 10px;
    cursor: grab;
    box-shadow: 0 3px 8px rgba(0,0,0,.25);
    user-select: none;
}
.floor-table:active { cursor: grabbing; }
.floor-table__num { font-weight: 800; font-size: 14px; }
.floor-table__name { font-size: 11.5px; opacity: .9; margin-top: 2px; }

.floor-edit-panel {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #f9fafb;
    max-width: 320px;
}
