/* ===================================================
   Cafetería Liceo ERP — SAP Fiori Horizon Dark Theme
   =================================================== */
:root {
    --shell: #354a5f;
    --shell-hover: #3f5570;
    --bg: #1a2433;
    --surface: #223044;
    --surface-hover: #293a50;
    --surface-active: #2f4562;
    --elevated: #29374d;
    --border: rgba(255,255,255,.08);
    --border-strong: rgba(255,255,255,.14);
    --brand: #0070f2;
    --brand-hover: #0064d9;
    --brand-light: rgba(0,112,242,.12);
    --positive: #36a41d;
    --positive-bg: rgba(54,164,29,.1);
    --critical: #e76500;
    --critical-bg: rgba(231,101,0,.1);
    --negative: #ee3939;
    --negative-bg: rgba(238,57,57,.1);
    --info: #1b90ff;
    --info-bg: rgba(27,144,255,.1);
    --neutral: #8396a8;
    --neutral-bg: rgba(131,150,168,.1);
    --text: #edeff0;
    --text-secondary: #8b9bab;
    --text-placeholder: #566676;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 2px 8px rgba(0,0,0,.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.4);
    --transition: .18s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.screen { display: none; height: 100%; }
.screen.active { display: flex; flex-direction: column; }

/* ===========================
   LOGIN
   =========================== */
.login-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 20px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px 28px;
    width: 100%;
    max-width: 340px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}
.logo-icon {
    width: 48px; height: 48px;
    background: var(--brand);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.login-logo h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.3px; }
.login-sub { font-size: .7rem; color: var(--text-secondary); letter-spacing: .5px; }
.login-divider { height: 1px; background: var(--border); margin-bottom: 24px; }

.login-label {
    text-align: center;
    font-size: .78rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.pin-display {
    display: flex;
    justify-content: center;
    gap: 14px;
    margin-bottom: 6px;
}
.pin-dot {
    width: 13px; height: 13px;
    border-radius: 50%;
    border: 2px solid var(--text-placeholder);
    transition: var(--transition);
}
.pin-dot.filled { background: var(--brand); border-color: var(--brand); }
.pin-dot.error { border-color: var(--negative); background: var(--negative); animation: shake .35s ease; }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.pin-error {
    text-align: center;
    font-size: .72rem;
    color: var(--negative);
    height: 18px;
    line-height: 18px;
    margin-bottom: 6px;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 240px;
    margin: 0 auto;
}
.pin-key {
    height: 52px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.pin-key:active { background: var(--surface-active); transform: scale(.96); }
.pin-key-empty { background: transparent; border-color: transparent; pointer-events: none; }
.pin-key-fn { color: var(--text-secondary); font-size: .9rem; }

.login-env { text-align: center; margin-top: 20px; }
.env-tag {
    display: inline-block;
    font-size: .58rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    background: var(--critical-bg);
    color: var(--critical);
    letter-spacing: 1.2px;
}

/* ===========================
   SHELL BAR
   =========================== */
.shell-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: var(--shell);
    flex-shrink: 0;
    z-index: 100;
}
.shell-start, .shell-end { display: flex; align-items: center; gap: 10px; }
.shell-menu-btn {
    display: none;
    width: 36px; height: 36px;
    border: none; border-radius: var(--radius-xs);
    background: transparent;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    align-items: center; justify-content: center;
}
.shell-brand { display: flex; align-items: center; gap: 10px; }
.shell-logo {
    width: 32px; height: 32px;
    background: var(--brand);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}
.shell-title { font-size: .88rem; font-weight: 600; color: #fff; }
.shell-date { font-size: .72rem; color: rgba(255,255,255,.55); }

.shell-icon-btn {
    width: 36px; height: 36px;
    border: none; border-radius: var(--radius-xs);
    background: transparent;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.shell-icon-btn:hover { background: var(--shell-hover); color: #fff; }
.shell-icon-btn.syncing svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    transition: var(--transition);
}
.shell-avatar:hover { background: rgba(255,255,255,.2); }

/* ===========================
   LAYOUT
   =========================== */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Side Nav */
.side-nav {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    overflow-y: auto;
    flex-shrink: 0;
}
.nav-section-label {
    font-size: .6rem;
    font-weight: 700;
    color: var(--text-placeholder);
    letter-spacing: 1.2px;
    padding: 12px 12px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-size: .8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    text-align: left;
    width: 100%;
    position: relative;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
    background: var(--brand-light);
    color: var(--brand);
}
.nav-item.active svg { stroke: var(--brand); }
.nav-disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}
.nav-badge {
    margin-left: auto;
    font-size: .55rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--neutral-bg);
    color: var(--neutral);
    letter-spacing: .5px;
}

.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 149;
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.module { display: none; }
.module.active { display: block; }

/* Page Header */
.page-header { margin-bottom: 20px; }
.page-header h2 { font-size: 1.35rem; font-weight: 700; }
.page-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.page-sub { font-size: .82rem; color: var(--text-secondary); margin-top: 4px; }

.page-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: var(--text-placeholder);
    margin-bottom: 8px;
}
.breadcrumb-link {
    background: none; border: none;
    color: var(--brand); font-size: .75rem; font-family: inherit;
    cursor: pointer;
    padding: 0;
}
.breadcrumb-link:hover { text-decoration: underline; }

/* ===========================
   KPI CARDS
   =========================== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
}
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.kpi-title { font-size: .72rem; color: var(--text-secondary); font-weight: 500; }
.kpi-icon {
    width: 28px; height: 28px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}
.kpi-positive { background: var(--positive-bg); color: var(--positive); }
.kpi-info { background: var(--info-bg); color: var(--info); }
.kpi-warning { background: var(--critical-bg); color: var(--critical); }
.kpi-neutral { background: var(--neutral-bg); color: var(--neutral); }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-footer { font-size: .65rem; color: var(--text-placeholder); margin-top: 6px; }

/* ===========================
   TILES
   =========================== */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.tile:hover { border-color: var(--brand); background: var(--surface-hover); }
.tile:active { transform: scale(.98); }
.tile-locked { cursor: default; }
.tile-locked:hover { border-color: var(--border); background: var(--surface); }
.tile-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.tile-icon-blue { background: var(--brand-light); color: var(--brand); }
.tile-icon-teal { background: rgba(0,186,170,.1); color: #00baaa; }
.tile-icon-orange { background: var(--critical-bg); color: var(--critical); }
.tile-icon-purple { background: rgba(135,100,230,.1); color: #8764e6; }
.tile-label { font-size: .88rem; font-weight: 600; margin-bottom: 4px; }
.tile-desc { font-size: .72rem; color: var(--text-secondary); margin-bottom: 10px; }
.tile-status {
    font-size: .58rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: .3px;
}
.tile-active { background: var(--positive-bg); color: var(--positive); }
.tile-pending { background: var(--neutral-bg); color: var(--neutral); }

/* ===========================
   TAB BAR
   =========================== */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: .82rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

.ftab-panel { display: none; }
.ftab-panel.active { display: block; }

/* Toolbar */
.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

/* ===========================
   BUTTONS
   =========================== */
.f-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    font-size: .8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.f-btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.f-btn-primary:hover { background: var(--brand-hover); }
.f-btn-primary:active { transform: scale(.97); }
.f-btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.f-btn-ghost { background: transparent; color: var(--text-secondary); }
.f-btn-ghost:hover { background: var(--surface-hover); }
.f-btn-sm { padding: 6px 12px; font-size: .72rem; }
.f-btn-outline { background: transparent; color: var(--text-secondary); border-color: var(--border-strong); }
.f-btn-outline:hover { background: var(--surface-hover); }
.f-btn-positive { background: var(--positive); color: #fff; border-color: var(--positive); }

/* ===========================
   LIST ITEMS / TABLE ROWS
   =========================== */
.list-container { display: flex; flex-direction: column; gap: 1px; }

.list-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}
.list-row:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.list-row:active { background: var(--surface-active); }

.row-main { flex: 1; min-width: 0; }
.row-title { font-size: .82rem; font-weight: 600; margin-bottom: 2px; }
.row-meta { font-size: .7rem; color: var(--text-secondary); display: flex; gap: 10px; flex-wrap: wrap; }
.row-amount { font-size: 1rem; font-weight: 700; color: var(--positive); white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Status tags */
.status-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: .3px;
    text-transform: uppercase;
}
.st-positive { background: var(--positive-bg); color: var(--positive); }
.st-info { background: var(--info-bg); color: var(--info); }
.st-critical { background: var(--critical-bg); color: var(--critical); }
.st-negative { background: var(--negative-bg); color: var(--negative); }
.st-neutral { background: var(--neutral-bg); color: var(--neutral); }
.st-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
    padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn .2s ease;
}
.modal-lg { max-width: 520px; }
.modal-xl { max-width: 640px; }

@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: .92rem; font-weight: 700; }
.modal-close {
    width: 28px; height: 28px;
    border: none; border-radius: var(--radius-xs);
    background: var(--elevated);
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* Receipt banner in modal */
.receipt-banner {
    background: var(--elevated);
    border-radius: var(--radius-xs);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.rb-left { font-size: .82rem; color: var(--text-secondary); }
.rb-right { font-size: 1.2rem; font-weight: 700; color: var(--positive); }

/* Form */
.form-section-title {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-placeholder);
    text-transform: uppercase;
    letter-spacing: .8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.form-hint { font-size: .68rem; color: var(--text-placeholder); margin-bottom: 14px; }

.form-field { margin-bottom: 14px; }
.form-field label {
    display: block;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}
.form-field input,
.form-field select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .82rem;
    font-family: inherit;
    transition: var(--transition);
    -webkit-appearance: none;
}
.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px var(--brand-light);
}
.form-field input::placeholder { color: var(--text-placeholder); }
.form-row { display: flex; gap: 10px; }
.form-row .form-field { flex: 1; }

/* ===========================
   DTE DETAIL
   =========================== */
.dte-qr-block {
    text-align: center;
    padding: 20px;
    background: var(--elevated);
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
}
.dte-qr-block img {
    width: 150px; height: 150px;
    border-radius: var(--radius-xs);
    background: #fff;
    padding: 8px;
}
.dte-qr-text { font-size: .65rem; color: var(--text-placeholder); margin-top: 8px; }

.detail-grid { display: flex; flex-direction: column; }
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.detail-row:last-child { border-bottom: none; }
.dk { font-size: .75rem; color: var(--text-secondary); flex-shrink: 0; }
.dv { font-size: .8rem; font-weight: 500; text-align: right; word-break: break-all; max-width: 60%; }
.dv-lg { font-size: 1.1rem; font-weight: 700; color: var(--positive); }
.dv-mono { font-size: .65rem; color: var(--text-secondary); font-family: 'SF Mono', 'Cascadia Code', monospace; }

/* ===========================
   EMPTY STATE
   =========================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 48px 20px;
    text-align: center;
}
.empty-state p { font-size: .85rem; color: var(--text-secondary); font-weight: 500; }
.empty-state span { font-size: .72rem; color: var(--text-placeholder); }

/* ===========================
   TOAST
   =========================== */
#toastContainer {
    position: fixed;
    top: 56px;
    right: 20px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 320px;
}
.toast-item {
    background: var(--elevated);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--info);
    border-radius: var(--radius-xs);
    padding: 12px 14px;
    font-size: .78rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    animation: toastIn .25s ease;
    pointer-events: auto;
}
.toast-item.out { animation: toastOut .25s ease forwards; }
.toast-success { border-left-color: var(--positive); }
.toast-error { border-left-color: var(--negative); }
.toast-info { border-left-color: var(--info); }
.t-icon { flex-shrink: 0; width: 18px; height: 18px; }
.toast-success .t-icon { color: var(--positive); }
.toast-error .t-icon { color: var(--negative); }
.toast-info .t-icon { color: var(--info); }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

/* ===========================
   INVENTORY TABS
   =========================== */
.itab-panel { display: none; }
.itab-panel.active { display: block; }
.ptab-panel { display: none; }
.ptab-panel.active { display: block; }

/* Toolbar */
.toolbar-search { flex: 1; max-width: 320px; }
.toolbar-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .8rem;
    font-family: inherit;
    transition: var(--transition);
}
.toolbar-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
.toolbar-search input::placeholder { color: var(--text-placeholder); }

.toolbar select {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .78rem;
    font-family: inherit;
    -webkit-appearance: none;
    transition: var(--transition);
}
.toolbar select:focus { outline: none; border-color: var(--brand); }

/* ===========================
   DATA TABLE
   =========================== */
.inv-table-wrap { overflow-x: auto; margin-bottom: 8px; }
.inv-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .78rem;
}
.inv-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 2;
}
.inv-table tbody tr {
    transition: var(--transition);
}
.inv-table tbody tr:hover { background: var(--surface-hover); }
.inv-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.inv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.td-name { font-weight: 600; color: var(--text); }
.td-link { cursor: pointer; color: var(--brand); }
.td-link:hover { text-decoration: underline; }
.td-secondary { color: var(--text-secondary); font-size: .72rem; }
.td-empty { text-align: center; padding: 32px 12px !important; color: var(--text-placeholder); }
.td-danger { color: var(--negative); font-weight: 700; }

.row-low td { background: rgba(238,57,57,.04); }
.row-total td { border-top: 2px solid var(--border-strong); background: var(--surface); }

.cat-tag {
    display: inline-block;
    font-size: .62rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--neutral-bg);
    color: var(--neutral);
    letter-spacing: .2px;
    white-space: nowrap;
}

.inv-table-compact { font-size: .75rem; }
.inv-table-compact td { padding: 7px 10px; }

.table-footer {
    font-size: .7rem;
    color: var(--text-placeholder);
    padding: 8px 4px;
}

.margin-badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--neutral-bg);
    color: var(--neutral);
}
.margin-badge.positive { background: var(--positive-bg); color: var(--positive); }
.margin-badge.critical { background: var(--critical-bg); color: var(--critical); }

/* ===========================
   ALERTS
   =========================== */
.alert-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--critical-bg);
    border: 1px solid rgba(231,101,0,.2);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--critical);
}
.row-alert { border-left: 3px solid var(--critical); }

/* ===========================
   DASHBOARD CARDS
   =========================== */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
}
.dash-card-wide { grid-column: span 2; }
.dash-card-title {
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.dash-list { display: flex; flex-direction: column; gap: 10px; }
.dash-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.dash-row-main { flex: 1; min-width: 0; }
.dash-row-name { font-size: .8rem; font-weight: 600; display: block; }
.dash-row-cat { font-size: .65rem; color: var(--text-placeholder); }
.dash-row-val {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-width: 130px;
}
.margin-bar {
    display: block;
    height: 6px;
    border-radius: 3px;
    background: var(--positive);
    min-width: 4px;
    transition: width .3s ease;
}
.margin-bar-low { background: var(--critical); }
.margin-pct {
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 42px;
    text-align: right;
}
.margin-pct.positive { color: var(--positive); }
.margin-pct.critical { color: var(--critical); }

/* ===========================
   RECIPE DETAIL
   =========================== */
.recipe-summary { display: flex; flex-direction: column; }
.recipe-sum-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.recipe-sum-row:last-child { border-bottom: none; }
.recipe-notes {
    margin-top: 14px;
    padding: 12px;
    background: var(--elevated);
    border-radius: var(--radius-xs);
    font-size: .78rem;
    color: var(--text-secondary);
}

.positive { color: var(--positive); }
.critical { color: var(--critical); }

/* ===========================
   RECIPE EDITOR
   =========================== */
.recipe-calc-bar {
    display: flex;
    gap: 12px;
    margin-top: 14px;
    padding: 14px 16px;
    background: var(--elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.calc-item { flex: 1; text-align: center; }
.calc-label { display: block; font-size: .62rem; font-weight: 600; color: var(--text-placeholder); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.calc-value { font-size: 1rem; font-weight: 700; }

.rec-ing-input {
    width: 100%;
    padding: 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: .76rem;
    font-family: inherit;
    transition: var(--transition);
}
.rec-ing-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-light); }
.rec-ing-input::placeholder { color: var(--text-placeholder); }
.rec-ing-input.num { text-align: right; }
.rec-ing-del {
    width: 26px; height: 26px;
    border: none; border-radius: var(--radius-xs);
    background: var(--negative-bg);
    color: var(--negative);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    line-height: 1;
    transition: var(--transition);
}
.rec-ing-del:hover { background: var(--negative); color: #fff; }

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 768px) {
    .shell-menu-btn { display: flex; }
    .shell-date { display: none; }

    .side-nav {
        position: fixed;
        left: -260px;
        top: 48px;
        bottom: 0;
        width: 250px;
        z-index: 150;
        transition: left .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .side-nav.open { left: 0; }
    .nav-overlay.open { display: block; }

    .content { padding: 16px; }

    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .tile-grid { grid-template-columns: repeat(2, 1fr); }

    #toastContainer { right: 10px; left: 10px; width: auto; }

    .modal-overlay { padding: 10px; align-items: flex-end; }
    .modal-dialog { border-radius: var(--radius) var(--radius) 0 0; max-height: 90vh; }
}

@media (max-width: 420px) {
    .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .tile-grid { grid-template-columns: 1fr; }
    .kpi-value { font-size: 1.3rem; }
    .dash-grid { grid-template-columns: 1fr; }
    .dash-card-wide { grid-column: span 1; }
    .toolbar { flex-wrap: wrap; }
    .toolbar-search { max-width: 100%; }
    .inv-table { font-size: .7rem; }
    .inv-table thead th, .inv-table tbody td { padding: 8px 6px; }
}
