/* =============================================
   THEME COMPLETO — POS El Mercadito
   Variables, layout, componentes, dark mode
   ============================================= */

/* ─── Fuentes ─── */
/* Fonts loaded via <link> in base.html and login.html */
/* ─── Variables ─── */
:root,
[data-theme="light"] {
    --font-body: 'Satoshi', Inter, system-ui, sans-serif;
    --font-display: 'General Sans', 'Satoshi', Inter, system-ui, sans-serif;

    --primary: #0f766e;
    --primary-hover: #115e59;
    --primary-soft: #dff6f3;

    --success: #2f855a;
    --warning: #b7791f;
    --danger: #c53030;
    --info: #0e7490;

    --bg: #f6f7f8;
    --surface: #ffffff;
    --surface-2: #f1f4f6;
    --surface-3: #e9eef2;

    --text: #17212b;
    --text-muted: #5d6b79;
    --text-faint: #8b98a5;

    --border: rgba(23, 33, 43, 0.10);
    --border-strong: rgba(23, 33, 43, 0.16);

    --shadow-sm: 0 6px 20px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 999px;

    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
}

[data-theme="dark"] {
    --bg: #0f1418;
    --surface: #151c21;
    --surface-2: #1b242b;
    --surface-3: #22303a;

    --text: #edf2f7;
    --text-muted: #a0aec0;
    --text-faint: #718096;

    --primary: #4fd1c5;
    --primary-hover: #38b2ac;
    --primary-soft: rgba(79, 209, 197, 0.10);

    --success: #68d391;
    --warning: #f6ad55;
    --danger: #fc8181;
    --info: #38bdf8;

    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);

    --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 20px 48px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 32px 64px rgba(0, 0, 0, 0.40);
}

/* ─── Reset / Base ─── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    color-scheme: light dark;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: radial-gradient(circle at top right, rgba(15, 118, 110, 0.06), transparent 22%), var(--bg);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    line-height: 1.15;
    color: var(--text);
}

p { color: var(--text-muted); }
a { color: inherit; text-decoration: none; }

/* ─── Layout ─── */
.body-wrapper .main-wrapper .page-wrapper .content-wrapper {
    min-height: calc(100vh - 84px - 62px);
}

.page-content-wrapper {
    padding: clamp(1rem, 2vw, 2rem);
    min-height: 100vh;
}

.page-shell {
    display: grid;
    gap: var(--space-6);
}

/* ─── Hero / Page Header ─── */
.page-hero,
.app-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(15, 118, 110, 0.02)), var(--surface);
    box-shadow: var(--shadow-sm);
}

.compact-hero { padding: 1.25rem; }

.warning-hero {
    background: linear-gradient(135deg, #7c2d12 0%, #ea580c 60%, #f59e0b 100%);
    color: #fff;
}
.warning-hero h1, .warning-hero h2, .warning-hero h3,
.warning-hero h4, .warning-hero p { color: #fff; }

.page-hero::after,
.app-hero::after {
    content: '';
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    right: -32px;
    bottom: -52px;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: .4rem .7rem;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: .85rem;
}

/* ─── Cards / Surfaces ─── */
.panel-card,
.table-card-modern,
.form-card-modern,
.metric-card,
.report-card,
.purchase-helper-card,
.highlight-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.mdc-card {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: box-shadow .2s ease;
}
.mdc-card:hover { box-shadow: var(--shadow-md); }

/* ─── Metrics ─── */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-4);
}

.metric-card {
    display: grid;
    gap: .45rem;
}

.metric-label {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
}

.metric-value {
    font-size: clamp(1.6rem, 2vw, 2.2rem);
    font-weight: 700;
    color: var(--text);
}

.metric-hint {
    font-size: .92rem;
    color: var(--text-muted);
}

/* ─── Dashboard Stats (home) ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-4);
}

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    flex-shrink: 0;
}
.stat-card-icon.primary   { background: linear-gradient(135deg, #2563eb, #1e40af); }
.stat-card-icon.success   { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card-icon.warning   { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card-icon.info      { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-card-icon.danger    { background: linear-gradient(135deg, #ef4444, #dc2626); }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .25rem;
}

.stat-label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.stat-description {
    font-size: .8125rem;
    color: var(--text-faint);
}

.stat-card a {
    font-weight: 600;
    color: var(--primary);
    display: inline-block;
    margin-top: var(--space-2);
}
.stat-card a:hover { text-decoration: underline; }

/* ─── Section Headings ─── */
.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.section-subtitle { color: var(--text-muted); font-size: .95rem; }

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.section-title i { color: var(--primary); font-size: 1.5rem; }

/* ─── Tables ─── */
.table-responsive { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}

.table thead th {
    padding: .8rem 1rem;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-faint);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
}

.table tbody td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.table tbody tr:hover td {
    background: color-mix(in srgb, var(--primary-soft) 35%, var(--surface));
}

.low-stock-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.low-stock-table table { width: 100%; border-collapse: collapse; }
.low-stock-table th {
    padding: .85rem 1rem;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
    color: var(--text-faint);
}
.low-stock-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.low-stock-table tr:last-child td { border-bottom: none; }
.low-stock-table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 35%, var(--surface)); }

/* ─── Stock Badges ─── */
.stock-badge {
    display: inline-block;
    padding: .35rem .75rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: .75rem;
}
.stock-badge.critical {
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    color: var(--danger);
}
.stock-badge.low {
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    color: var(--warning);
}

/* ─── Forms ─── */
.form-control,
.mdc-text-field__input,
input.form-control,
select.form-control {
    width: 100%;
    min-height: 46px;
    padding: .8rem .95rem;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.form-control:focus,
.mdc-text-field__input:focus,
input.form-control:focus,
select.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent);
}

.form-group { margin-bottom: var(--space-4); }
.form-group label,
.form-label {
    display: block;
    margin-bottom: .45rem;
    font-weight: 600;
    font-size: .875rem;
    color: var(--text);
}

.field-help,
.helper-copy {
    display: block;
    margin-top: .35rem;
    font-size: .78rem;
    color: var(--text-muted);
}

.field-block { min-width: 0; }
.field-block-wide { grid-column: 1 / -1; }
.field-block label {
    display: block;
    margin-bottom: .35rem;
    font-weight: 600;
    font-size: .875rem;
    color: var(--text);
}

.static-field {
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: .6rem .9rem;
    border-radius: 12px;
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
    color: var(--text-muted);
}

/* ─── Form Grids ─── */
.modern-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
}

.report-grid,
.form-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-4);
}

.quick-form-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: var(--space-4);
    align-items: start;
}

.actions-row {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-2);
    flex-wrap: wrap;
}

/* ─── Buttons ─── */
.btn,
.mdc-button,
.btn-modern-primary,
.btn-modern-secondary,
.btn-primary,
.btn-outline {
    min-height: 44px;
    padding: .75rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
    border: 1px solid var(--border-strong);
}

.btn-primary,
.mdc-button--raised,
.btn-modern-primary {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: transparent !important;
}
.btn-primary:hover,
.mdc-button--raised:hover,
.btn-modern-primary:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-1px);
}

.btn-outline,
.mdc-button--outlined,
.btn-modern-secondary {
    background: transparent !important;
    color: var(--text) !important;
}
.btn-modern-secondary:hover {
    background: var(--surface-2) !important;
}

.btn-sm { min-height: 36px; padding: .45rem .85rem; }

/* ─── Badges / Status Chips ─── */
.badge,
.status-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .35rem .65rem;
    border-radius: var(--radius-full);
    font-size: .75rem;
    font-weight: 700;
}

.status-chip.is-sale {
    background: color-mix(in srgb, var(--success) 15%, transparent);
    color: var(--success);
}
.status-chip.is-purchase {
    background: color-mix(in srgb, var(--primary) 15%, transparent);
    color: var(--primary);
}
.status-chip.is-profit {
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    color: var(--warning);
}

.badge-primary {
    background: color-mix(in srgb, var(--primary) 20%, transparent);
    color: var(--primary);
}
.badge-success {
    background: color-mix(in srgb, var(--success) 20%, transparent);
    color: var(--success);
}
.badge-danger {
    background: color-mix(in srgb, var(--danger) 20%, transparent);
    color: var(--danger);
}
.badge-warning {
    background: color-mix(in srgb, var(--warning) 20%, transparent);
    color: var(--warning);
}

/* ─── Alerts ─── */
.alert {
    padding: var(--space-4) var(--space-5);
    border-radius: 14px;
    border: 1px solid var(--border);
}
.alert-success { background: color-mix(in srgb, var(--success) 10%, transparent); color: var(--success); }
.alert-warning { background: color-mix(in srgb, var(--warning) 10%, transparent); color: var(--warning); }
.alert-danger  { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); }
.alert-info    { background: color-mix(in srgb, var(--info) 10%, transparent); color: var(--info); }

.error-message {
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    color: var(--danger);
    padding: var(--space-3) var(--space-4);
    border-radius: 12px;
    margin-bottom: var(--space-4);
    font-size: .875rem;
    border-left: 4px solid var(--danger);
}

/* ─── Currency Pill ─── */
.currency-pill {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .85rem;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    font-size: .8125rem;
    font-weight: 700;
}

/* ─── Report Cards ─── */
.report-card,
.purchase-helper-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.report-card h3,
.purchase-helper-card h4 { margin-bottom: .5rem; }
.report-card p,
.purchase-helper-card p { margin-bottom: .85rem; color: var(--text-muted); font-size: .875rem; }

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: .85rem;
}

.helper-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: .6rem;
}
.helper-list li { color: var(--text-muted); font-size: .875rem; }

.helper-list.ordered { counter-reset: helper-counter; }
.helper-list.ordered li {
    position: relative;
    padding-left: 2.25rem;
}
.helper-list.ordered li::before {
    counter-increment: helper-counter;
    content: counter(helper-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 800;
}

/* ─── POS Styles ─── */
#POS-field { height: 60vh; min-height: 0; }
#pos-cart-wrap { overflow-y: auto; height: 100%; min-height: 0; }
#pos-cart-wrap thead { position: sticky; top: 0; z-index: 1; }

.pos-search-shell {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.pos-search-shell__header { padding: var(--space-5) var(--space-6) var(--space-3); }
.pos-search-shell__body { padding: 0 var(--space-6) var(--space-6); }

.pos-search-box { position: relative; }
.pos-search-box__input {
    height: 60px;
    border-radius: 16px;
    border: 1px solid var(--border-strong);
    padding-left: 3.2rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
}
.pos-search-box__icon {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    color: var(--primary);
    font-size: 1.35rem;
}

.pos-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: none;
}
.pos-search-result {
    padding: .9rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .16s ease;
}
.pos-search-result:last-child { border-bottom: 0; }
.pos-search-result:hover,
.pos-search-result.is-active { background: var(--primary-soft); }
.pos-search-result__name { display: block; color: var(--text); font-weight: 700; }
.pos-search-result__meta {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    margin-top: .25rem;
    color: var(--text-muted);
    font-size: .84rem;
}
.pos-search-empty {
    padding: .9rem 1rem;
    color: var(--text-muted);
    font-size: .92rem;
}

.pos-qty-card {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    padding: var(--space-4);
    height: 100%;
}

.pos-summary-card {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.96));
}
.pos-summary-card dl { margin-bottom: 0; }
.pos-summary-card dd { border-radius: 12px; }

.pos-cart-table thead th { white-space: nowrap; }

/* ─── Operations Panel ─── */
.ops-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.ops-panel__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.ops-panel__body { padding: var(--space-4) var(--space-5); }

.ops-history-table td,
.ops-history-table th { vertical-align: middle; white-space: nowrap; }
.ops-history-wrap { max-height: 280px; overflow: auto; }

/* ─── No Data / Empty State ─── */
.no-data {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-faint);
}
.no-data i {
    font-size: 3rem;
    margin-bottom: .85rem;
    opacity: .4;
}

.empty-state {
    text-align: center;
    display: grid;
    gap: var(--space-3);
    justify-items: center;
    padding: 3rem 1.25rem;
}
.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    background: var(--surface-2);
    font-size: 1.6rem;
}

/* ─── Notes (operations) ─── */
.notes-composer {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.notes-composer textarea.form-control { min-height: 88px; resize: vertical; }

.notes-list {
    padding: var(--space-5) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-height: 60vh;
    overflow-y: auto;
}

.note-message {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}
.note-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}
.note-avatar--fallback {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
}
.note-bubble {
    background: var(--surface-2);
    border-radius: 16px 16px 16px 4px;
    padding: .75rem 1.1rem;
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.note-header {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 4px;
}
.note-author { font-weight: 600; font-size: .88rem; color: var(--text); }
.note-time {
    font-size: .75rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}
.note-text {
    font-size: .92rem;
    color: var(--text);
    line-height: 1.55;
    word-break: break-word;
}

.notes-empty { text-align: center; padding: 3rem 1.5rem; }
.notes-empty-icon { font-size: 2.8rem; margin-bottom: .6rem; }
.notes-empty h3 { margin-bottom: .35rem; color: var(--text); }
.notes-empty p { color: var(--text-muted); }

/* ─── Employee / Ranking ─── */
.winner-podium {
    background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 50%, #fde68a 100%);
    border-radius: var(--radius-lg);
    text-align: center;
    padding: 2rem 1.5rem 2.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.winner-podium::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(251, 191, 36, 0.12);
}
.winner-podium__trophy {
    font-size: 3.2rem;
    margin-bottom: .6rem;
    filter: drop-shadow(0 4px 8px rgba(217, 119, 6, 0.3));
}
.winner-podium__avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: var(--space-3);
    border: 4px solid #fbbf24;
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.25);
}
.winner-podium__name {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 2px;
    color: #1e293b;
}
.winner-podium__username { color: #78716c; font-size: .9rem; }
.winner-podium__stats {
    display: flex;
    justify-content: center;
    gap: 2.25rem;
    margin-top: 1.25rem;
}
.winner-podium__stat { text-align: center; }
.winner-podium__number {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}
.winner-podium__label {
    display: block;
    font-size: .78rem;
    color: #78716c;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.ranking-card__header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border);
}
.ranking-card__count {
    margin-left: auto;
    font-size: .8rem;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: 2px 10px;
    border-radius: var(--radius-full);
}
.ranking-table { margin-bottom: 0; }
.ranking-table th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    border-bottom: 0;
    padding: .6rem .75rem;
    background: var(--surface-2);
}
.ranking-row td {
    padding: .6rem .75rem;
    vertical-align: middle;
    border-top: 1px solid var(--border);
}
.ranking-row--gold td { background: color-mix(in srgb, #b7791f 10%, transparent); }
.ranking-row--silver td { background: color-mix(in srgb, #718096 8%, transparent); }
.ranking-row--bronze td { background: color-mix(in srgb, #b45309 8%, transparent); }
.ranking-rank { text-align: center; width: 44px; }

.ranking-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: .82rem;
    font-weight: 700;
    color: #fff;
}
.ranking-medal--gold   { background: linear-gradient(135deg, #d97706, #f59e0b); box-shadow: 0 2px 8px rgba(217,119,6,.3); }
.ranking-medal--silver { background: linear-gradient(135deg, #78716c, #a8a29e); box-shadow: 0 2px 8px rgba(120,113,108,.3); }
.ranking-medal--bronze { background: linear-gradient(135deg, #b45309, #d97706); box-shadow: 0 2px 8px rgba(180,83,9,.3); }

.ranking-rank-num { font-weight: 600; color: var(--text-faint); font-size: .88rem; }
.ranking-user {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.ranking-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.ranking-name { font-weight: 600; font-size: .9rem; color: var(--text); line-height: 1.2; }
.ranking-username { font-size: .78rem; color: var(--text-faint); line-height: 1.2; }
.ranking-total { font-weight: 700; color: var(--text); }

.employee-cell {
    display: flex;
    align-items: center;
    gap: .85rem;
}
.employee-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}
.employee-user { font-size: .9rem; color: var(--text-muted); }
.rank-badge {
    display: inline-flex;
    min-width: 56px;
    justify-content: center;
    align-items: center;
    padding: .45rem .7rem;
    border-radius: var(--radius-full);
    background: var(--surface-2);
    font-weight: 700;
}

/* ─── Login ─── */
body.auth-body {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-page {
    width: 100%;
    max-width: 450px;
    padding: var(--space-5);
}

.auth-container {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-header {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
    color: #fff;
    padding: 2.5rem 2rem;
    text-align: center;
}
.auth-header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: .6rem; color: #fff; }
.auth-header p { font-size: .875rem; opacity: .9; margin: 0; color: rgba(255,255,255,.9); }

.auth-content { padding: 2.5rem 2rem; }

.btn-login {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all .2s ease;
    margin-top: var(--space-5);
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px color-mix(in srgb, var(--primary) 25%, transparent);
}

.login-profiles-title {
    font-size: 1.05rem;
    color: var(--text);
    margin-bottom: var(--space-4);
    font-weight: 600;
    text-align: center;
}

.profile-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--space-4);
}

.profile-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--surface);
    cursor: pointer;
    transition: all .2s ease;
    text-align: center;
    color: var(--text);
}
.profile-card:hover,
.profile-card.active {
    border-color: var(--primary);
    box-shadow: 0 10px 25px color-mix(in srgb, var(--primary) 18%, transparent);
}

.profile-avatar-card {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-2);
    display: grid;
    place-items: center;
}
.profile-avatar-card img { width: 100%; height: 100%; object-fit: cover; }
.profile-card-body strong { display: block; font-size: 1rem; }
.profile-card-body span { display: block; font-size: .875rem; color: var(--text-muted); }

.login-note {
    margin-top: var(--space-5);
    padding: var(--space-4);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text-muted);
    text-align: center;
    font-size: .95rem;
}

.password-section {
    margin-top: var(--space-6);
    display: grid;
    gap: var(--space-4);
}
.password-section .form-group { margin-bottom: 0; }

/* ─── Purchase Batch ─── */
.purchase-batch-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface);
}
.batch-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    padding: var(--space-4) var(--space-5);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.batch-card-header h3 { margin: 0; font-size: 1.05rem; }
.batch-card-header p { margin: .25rem 0 0; font-size: .85rem; color: var(--text-muted); }
.batch-summary {
    background: var(--primary-soft);
    color: var(--primary);
    padding: .35rem .85rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: .85rem;
}
.purchase-batch-table td { vertical-align: middle; }

/* ─── DataTables ─── */
table.dataTable thead th,
table.dataTable thead td {
    border-bottom: 1px solid var(--border-strong) !important;
    color: var(--text-faint) !important;
    font-size: .78rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: .04em !important;
}
table.dataTable tbody td {
    border-bottom: 1px solid var(--border) !important;
    color: var(--text) !important;
}
table.dataTable.display tbody tr:hover {
    background: color-mix(in srgb, var(--primary-soft) 35%, var(--surface)) !important;
}
table.dataTable.row-border tbody th, table.dataTable.row-border tbody td,
table.dataTable.display tbody th, table.dataTable.display tbody td {
    border-top: 1px solid var(--border) !important;
}

div.dataTables_wrapper div.dataTables_filter input {
    border: 1px solid var(--border-strong) !important;
    border-radius: 12px !important;
    padding: .45rem .75rem !important;
    background: var(--surface) !important;
    color: var(--text) !important;
}
div.dataTables_wrapper div.dataTables_paginate {
    margin-top: var(--space-3) !important;
}
div.dataTables_wrapper div.dataTables_paginate .paginate_button {
    border-radius: 10px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
}
div.dataTables_wrapper div.dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #fff !important;
}

/* ─── DT buttons ─── */
.dt-buttons .btn {
    border-radius: 10px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text-muted) !important;
    font-size: .78rem !important;
    min-height: 36px !important;
}
.dt-buttons .btn:hover {
    background: var(--surface-2) !important;
}

/* ─── Links in table cells ─── */
.link-cell a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.link-cell a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ─── Modals ─── */
.modal-content {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
}
.modal-header,
.modal-footer {
    border-color: var(--border);
}
.modal-header .btn-close {
    filter: none;
}

/* ─── Loader ─── */
.loader-wrapper {
    background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
}

/* ─── Select2 ─── */
.select2-container--default .select2-selection--single {
    border: 1px solid var(--border-strong) !important;
    border-radius: 12px !important;
    min-height: 46px;
    background: var(--surface) !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
    line-height: 46px !important;
    padding-left: 12px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 46px !important;
}
.select2-dropdown {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
}

/* ─── Misc ─── */
.mid-large {
    width: 54vw !important;
    max-width: unset;
}

.bg-primary { background: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }

/* ─── Dark Mode ─── */
[data-theme="dark"] .bg-white { background: var(--surface) !important; }
[data-theme="dark"] .bg-light { background: var(--surface-2) !important; }
[data-theme="dark"] .text-dark { color: var(--text) !important; }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

[data-theme="dark"] .winner-podium {
    background: linear-gradient(180deg, #292524 0%, #1c1917 50%, #292524 100%);
}
[data-theme="dark"] .winner-podium__name { color: #fef3c7; }
[data-theme="dark"] .winner-podium__username { color: #a8a29e; }
[data-theme="dark"] .winner-podium__number { color: #34d399; }
[data-theme="dark"] .winner-podium__label { color: #a8a29e; }

[data-theme="dark"] .table-list-item { background: var(--surface-2); }

/* ─── Responsive ─── */
@media (max-width: 991.98px) {
    #POS-field { flex-direction: column; }
    #POS-field > .col-8,
    #POS-field > .col-4 { width: 100%; }
}

@media (max-width: 768px) {
    .auth-page { max-width: 100%; padding: var(--space-3); }
    .auth-header { padding: 2rem 1.25rem; }
    .auth-header h1 { font-size: 1.5rem; }
    .auth-content { padding: 1.5rem 1.25rem; }

    .page-content-wrapper { padding: .9rem; }
    .page-shell { gap: var(--space-4); }

    .page-hero, .app-hero, .panel-card, .table-card-modern,
    .form-card-modern, .metric-card, .report-card,
    .purchase-helper-card { padding: var(--space-4); border-radius: var(--radius-md); }

    .modern-form-grid, .report-grid, .metric-grid, .form-layout-grid,
    .quick-form-grid { grid-template-columns: 1fr; }

    .actions-row, .report-actions { display: grid; gap: var(--space-3); }
    .actions-row .btn, .report-actions .btn,
    .report-actions .mdc-button { width: 100%; }

    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }

    .stat-card { padding: var(--space-4); }
    .stat-value { font-size: 1.35rem; }
    .stat-card-icon { width: 40px; height: 40px; font-size: 1.25rem; }

    .section-title { font-size: 1.1rem; }
    .table th, .table td { padding: .6rem .5rem; font-size: .8125rem; }

    .profile-card-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }

    .notes-composer form.modern-form-grid { grid-template-columns: 1fr !important; }
    .notes-composer .actions-row .btn { width: 100%; }
    .note-header { align-items: flex-start; flex-direction: column; gap: 4px; }
    .note-time { margin-left: 0; }
}

@media (max-width: 576px) {
    .auth-header h1 { font-size: 1.25rem; }
    .auth-content { padding: 1.25rem; }
    .form-group input { padding: .6rem .75rem; font-size: 1rem; }
    .btn-login { padding: .6rem; font-size: .875rem; }

    .page-content-wrapper { padding: .5rem .25rem; }
    .page-hero, .app-hero { padding: var(--space-4); }

    .currency-pill { width: 100%; justify-content: center; }

    .stats-grid { grid-template-columns: 1fr; gap: var(--space-2); }
}
