/* ═══════════════════════════════════════════
   EMAN COLLECTION — Clean & Minimal Theme
   ═══════════════════════════════════════════ */

:root {
    --bg: #f6f5f1;
    --surface: #ffffff;
    --surface-2: #f0efeb;
    --surface-3: #e8e6e1;
    --primary: #1a1a2e;
    --primary-light: #2d2d4a;
    --accent: #c8956c;
    --accent-light: #dbb799;
    --accent-dark: #a07450;
    --text: #1a1a2e;
    --text-muted: #7a7a8e;
    --text-light: #a0a0b0;
    --border: #e2e0db;
    --border-light: #eeece8;
    --red: #d45454;
    --red-bg: #fef2f2;
    --green: #3a9a5c;
    --green-bg: #f0faf4;
    --blue: #4a7fd4;
    --blue-bg: #f0f5fe;
    --orange: #d48a3a;
    --orange-bg: #fef8f0;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.main {
    margin-left: 250px;
    flex: 1;
    min-height: 100vh;
    padding: 24px 28px;
}

/* ── Sidebar ── */
.brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand h1 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-light);
    letter-spacing: -0.01em;
}
.brand small {
    display: block;
    font-size: 0.68rem;
    color: rgba(255,255,255,0.4);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-section { padding: 14px 10px 4px; }
.nav-label {
    font-size: 0.62rem;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0 10px 6px;
    font-weight: 600;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.87rem;
    transition: all var(--transition);
    margin-bottom: 1px;
}
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.nav-item.active {
    background: rgba(200,149,108,0.15);
    color: var(--accent-light);
}
.nav-item .icon { font-size: 1rem; width: 22px; text-align: center; }
.nav-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 0.62rem;
    padding: 1px 7px;
    border-radius: 20px;
    font-weight: 700;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    text-decoration: none;
    color: rgba(255,255,255,0.7);
    font-size: 0.82rem;
}
.user-pill:hover { background: rgba(255,255,255,0.08); }
.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}
.user-info { flex: 1; }
.user-info .name { font-weight: 600; font-size: 0.8rem; color: #fff; }
.user-info .role { font-size: 0.65rem; color: rgba(255,255,255,0.4); text-transform: capitalize; }

/* ── Mobile Top Bar ── */
.topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    background: var(--primary);
    color: #fff;
    z-index: 101;
    align-items: center;
    padding: 0 14px;
    gap: 12px;
}
.topbar h1 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    color: var(--accent-light);
    flex: 1;
}
.menu-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
}
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}
.overlay.open { display: block; }

/* ── Page Structure ── */
.page { display: none; }
.page.active { display: block; }

.page-header {
    margin-bottom: 22px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 {
    font-family: var(--font-display);
    font-size: 1.55rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
}
.page-header p {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 2px;
}

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}
.card-title {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 10px;
}

/* ── Stat Cards ── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.stat-card.accent::before { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.stat-card.green::before { background: linear-gradient(90deg, var(--green), #5cb87a); }
.stat-card.red::before { background: linear-gradient(90deg, var(--red), #e88); }
.stat-card.blue::before { background: linear-gradient(90deg, var(--blue), #80b4f0); }
.stat-card.orange::before { background: linear-gradient(90deg, var(--orange), #e8a86a); }

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 4px 0 2px;
    color: var(--text);
}
.stat-sub { font-size: 0.72rem; color: var(--text-light); }
.stat-icon {
    position: absolute;
    top: 16px; right: 16px;
    font-size: 1.4rem;
    opacity: 0.2;
}

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.gap-b { margin-bottom: 18px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.84rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-accent {
    background: var(--accent);
    color: #fff;
}
.btn-accent:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--text-muted); }
.btn-red { background: var(--red); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 500;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    transition: border-color var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,149,108,0.1);
}
.form-textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-hint { font-size: 0.72rem; color: var(--text-light); margin-top: 3px; }

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
}
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface-2); }
th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 10px 14px;
    font-size: 0.84rem;
    border-bottom: 1px solid var(--border-light);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(200,149,108,0.02); }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-accent { background: rgba(200,149,108,0.12); color: var(--accent-dark); }

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--surface-2);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.tab {
    padding: 7px 16px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: all var(--transition);
    text-decoration: none;
    font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 26px;
    width: 540px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
}
.modal-lg { width: 720px; }
.modal h3 {
    font-family: var(--font-display);
    color: var(--text);
    margin-bottom: 18px;
    font-size: 1.2rem;
}
.modal-close {
    position: absolute;
    top: 16px; right: 16px;
    background: var(--surface-2);
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--surface-3); color: var(--text); }

/* ── Search ── */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.search-bar input { flex: 1; }
.search-bar select { width: 200px; }

/* ── Alert ── */
.alert {
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 0.84rem;
    margin-bottom: 14px;
    display: flex;
    gap: 8px;
    align-items: center;
}
.alert-success { background: var(--green-bg); border: 1px solid rgba(58,154,92,0.2); color: var(--green); }
.alert-error { background: var(--red-bg); border: 1px solid rgba(212,84,84,0.2); color: var(--red); }
.alert-warn { background: var(--orange-bg); border: 1px solid rgba(212,138,58,0.2); color: var(--orange); }
.alert-info { background: var(--blue-bg); border: 1px solid rgba(74,127,212,0.2); color: var(--blue); }

/* ── Receipt ── */
.receipt {
    background: #fff;
    color: #1a1a1a;
    padding: 28px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    max-width: 380px;
    margin: 0 auto;
    border: 1px solid var(--border);
}
.receipt-header { text-align: center; margin-bottom: 14px; border-bottom: 2px dashed #ccc; padding-bottom: 12px; }
.receipt-header h2 { font-size: 1.15rem; font-weight: 800; }
.receipt-header p { font-size: 0.72rem; color: #666; }
.receipt-row { display: flex; justify-content: space-between; margin: 3px 0; }
.receipt-section { border-top: 1px dashed #ccc; margin-top: 8px; padding-top: 8px; }
.receipt-total { font-weight: 800; font-size: 1rem; }

/* ── Chart Bars ── */
.chart-bar-wrap { display: flex; align-items: flex-end; gap: 6px; height: 100px; padding: 0 4px; }
.chart-bar {
    flex: 1;
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    border-radius: 4px 4px 0 0;
    min-height: 3px;
    transition: height 0.5s ease;
    cursor: pointer;
    position: relative;
}
.chart-bar:hover { opacity: 0.85; }
.chart-bar .tooltip {
    display: none;
    position: absolute;
    top: -26px; left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}
.chart-bar:hover .tooltip { display: block; }
.chart-labels { display: flex; gap: 6px; padding: 4px 4px 0; }
.chart-labels span { flex: 1; text-align: center; font-size: 0.64rem; color: var(--text-light); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Account Pill ── */
.account-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 6px;
}
.account-pill .acc-icon { font-size: 1.2rem; }
.account-pill .acc-info { flex: 1; }
.account-pill .acc-name { font-size: 0.82rem; font-weight: 600; }
.account-pill .acc-amount { font-size: 0.95rem; font-weight: 700; color: var(--green); }

/* ── Login ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    width: 380px;
    max-width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-box h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 4px;
}
.login-box .subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}
.login-box .form-group { text-align: left; }
.login-box .btn { width: 100%; justify-content: center; padding: 11px; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: var(--text-light);
}
.empty-state .icon { font-size: 2.2rem; margin-bottom: 8px; opacity: 0.5; }
.empty-state p { font-size: 0.85rem; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Utilities ── */
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 14px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 14px; }
.d-flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 14px; }
.flex-1 { flex: 1; }
.nowrap { white-space: nowrap; }

/* ── Print ── */
@media print {
    .sidebar, .topbar, .btn, .modal-close, .no-print { display: none !important; }
    .main { margin-left: 0; padding: 0; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .topbar { display: flex; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; padding: 14px; padding-top: 68px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .search-bar { flex-direction: column; }
    .search-bar select { width: 100%; }
    .tabs { gap: 0; }
    .tab { padding: 6px 12px; font-size: 0.78rem; }
    .stat-value { font-size: 1.25rem; }
}

@media (max-width: 480px) {
    .main { padding: 10px; padding-top: 62px; }
    .card { padding: 14px; }
    .modal { padding: 20px; }
    td, th { padding: 8px 10px; font-size: 0.78rem; }
}

/* ── PWA Standalone ── */
@media (display-mode: standalone) {
    .topbar { padding-top: env(safe-area-inset-top); height: calc(54px + env(safe-area-inset-top)); }
    .main { padding-top: calc(68px + env(safe-area-inset-top)); }
    body { padding-bottom: env(safe-area-inset-bottom); }
}
