/* ── Design tokens ── */
:root {
  --primary:       #6366F1;
  --primary-dark:  #4F46E5;
  --primary-light: #EEF2FF;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;

  --bg:            #F8FAFC;
  --surface:       #FFFFFF;
  --surface-2:     #F1F5F9;
  --border:        #E2E8F0;
  --border-hover:  #CBD5E1;

  --text:          #0F172A;
  --text-secondary:#475569;
  --text-muted:    #94A3B8;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 16px rgba(99,102,241,.08);
  --shadow-lg:  0 8px 32px rgba(99,102,241,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: -apple-system, 'Segoe UI', sans-serif; background: var(--bg);
       color: var(--text); line-height: 1.6; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border);
           display: flex; flex-direction: column; position: fixed; top:0; left:0; height:100vh; z-index:50; }
.main-content { margin-left: 220px; flex: 1; padding: 28px; max-width: 1100px; }

/* ── Sidebar ── */
.sidebar-brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--border); }
.sidebar-brand .icon { font-size: 24px; margin-bottom: 4px; }
.sidebar-brand h2 { font-size: 15px; font-weight: 700; color: var(--text); }
.sidebar-brand p  { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 700; color: var(--text-muted);
               text-transform: uppercase; letter-spacing: .06em;
               padding: 12px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px;
            border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px;
            color: var(--text-secondary); transition: .15s; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.badge { margin-left: auto; background: var(--danger); color: #fff;
         border-radius: 99px; font-size: 10px; font-weight: 700;
         padding: 1px 6px; min-width: 18px; text-align: center; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; background: var(--primary); border-radius: 50%;
          display: flex; align-items: center; justify-content: center;
          color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.user-info .name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-info .role { font-size: 11px; color: var(--text-muted); }
.btn-logout { margin-left: auto; background: none; border: none; cursor: pointer;
              color: var(--text-muted); font-size: 16px; padding: 4px; border-radius: 6px;
              transition: .15s; }
.btn-logout:hover { background: var(--surface-2); color: var(--danger); }

/* ── Cards ── */
.card { background: var(--surface); border-radius: var(--radius-lg);
        border: 1px solid var(--border); padding: 24px; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 16px;
              display: flex; align-items: center; gap: 8px; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border);
             padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-card .label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-card .sub   { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
       border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
       cursor: pointer; border: none; transition: .15s; text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost   { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600;
                    color: var(--text-secondary); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13.5px; background: var(--bg);
  color: var(--text); transition: .2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.form-group textarea { resize: vertical; min-height: 72px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--surface-2); }
th { padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text-secondary);
     font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
tr:hover td { background: #F8F7FF; }
tr:last-child td { border-bottom: none; }

/* ── Status badges ── */
.badge-status { display: inline-flex; align-items: center; gap: 4px;
                padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.badge-pending  { background: #FEF3C7; color: #92400E; }
.badge-approved { background: #D1FAE5; color: #065F46; }
.badge-rejected { background: #FEE2E2; color: #991B1B; }
.badge-cancelled{ background: #F1F5F9; color: #64748B; }

/* ── Balance bars ── */
.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.balance-item { background: var(--surface-2); border-radius: var(--radius); padding: 14px;
                border: 1px solid var(--border); }
.balance-item .type { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px;
                       display: flex; align-items: center; gap: 6px; }
.balance-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.balance-bar { background: var(--border); border-radius: 99px; height: 6px; margin: 6px 0 4px; overflow: hidden; }
.balance-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.balance-nums { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); }
.balance-nums strong { color: var(--text); font-size: 13px; }

/* ── Calendar ── */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day-name { text-align: center; font-size: 11px; font-weight: 700;
                color: var(--text-muted); padding: 6px 0; text-transform: uppercase; }
.cal-cell { min-height: 80px; background: var(--surface-2); border-radius: var(--radius-sm);
            padding: 6px; border: 1px solid var(--border); position: relative; }
.cal-cell.today { border-color: var(--primary); background: var(--primary-light); }
.cal-cell.other-month { opacity: .4; }
.cal-num { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.cal-cell.today .cal-num { color: var(--primary); }
.cal-event { font-size: 10px; font-weight: 600; padding: 2px 5px; border-radius: 4px;
             color: #fff; margin-bottom: 2px; white-space: nowrap; overflow: hidden;
             text-overflow: ellipsis; cursor: default; }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45);
                 backdrop-filter: blur(2px); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%;
         max-width: 500px; max-height: 90vh; overflow-y: auto; margin: 16px;
         box-shadow: var(--shadow-lg); animation: slideUp .2s ease; }
.modal-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
              display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer;
               color: var(--text-muted); border-radius: 6px; padding: 2px 6px; }
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border);
              display: flex; gap: 10px; justify-content: flex-end; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
       color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
       transition: .15s; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab:hover { color: var(--primary); background: var(--primary-light); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Page header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between;
               margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--text); }
.page-header p  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px;
         margin-bottom: 14px; display: flex; align-items: flex-start; gap: 8px; }
.alert-error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── Empty state ── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty .icon { font-size: 40px; margin-bottom: 12px; }
.empty p { font-size: 14px; }

/* ── Utilities ── */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); color: var(--text); }

@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }

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

.qr-wrap img { max-width: 200px; height: auto; }
