/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #92400e;
  --warning-bg: #fef3c7;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #0ea5e9;
  --sidebar-hover: #334155;
}

/* ── Reset ─────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── Login ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ── Shell Layout ──────────────────────────────────────────── */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 210px;
  background: var(--sidebar-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid #334155;
}

.sidebar-brand .name {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.sidebar-brand .sub {
  font-size: 10px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 2px;
}

.nav-section {
  padding: 14px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #475569;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13px;
  transition: background .15s, color .15s;
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #ffffff;
}

.nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Main Area ─────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
}

.topbar-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* ── Page Content ──────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
  text-decoration: none;
}

.btn:hover {
  opacity: .88;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

.stat-value.green { color: var(--success); }
.stat-value.blue  { color: var(--primary); }
.stat-value.red   { color: var(--danger); }

.stat-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: #f8fafc;
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f8fafc;
}

.tfoot-row td {
  background: var(--border-light);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* ── Tags & Pills ──────────────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.tag-cash {
  background: var(--success-bg);
  color: var(--success);
}

.tag-card {
  background: #dbeafe;
  color: #1d4ed8;
}

.tag-owed {
  background: var(--warning-bg);
  color: var(--warning);
}

.pill {
  display: inline-block;
  background: var(--border-light);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ── Icon Buttons ──────────────────────────────────────────── */
.icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #ffffff;
  font-size: 12px;
  transition: background .15s;
}

.icon-btn:hover {
  background: var(--border-light);
}

.actions {
  display: flex;
  gap: 4px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
}

input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,.12);
}

/* ── Modals ────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal {
  background: #ffffff;
  border-radius: 10px;
  padding: 24px;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ── Week Navigation ───────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.week-nav select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: #ffffff;
  color: var(--text);
  font-family: inherit;
}

.week-arrow {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
  user-select: none;
}

.week-arrow:hover {
  background: var(--border-light);
}

/* ── Two Column Layout ─────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Balance Rows ──────────────────────────────────────────── */
.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}

.balance-row:last-child {
  border-bottom: none;
}

.balance-amount {
  font-weight: 700;
  color: var(--danger);
}

/* ── Staff Rows ────────────────────────────────────────────── */
.staff-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}

.staff-row:last-child {
  border-bottom: none;
}

.staff-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-faint   { color: var(--text-faint); }
.font-mono    { font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace; }
.hidden       { display: none !important; }
.flex         { display: flex; }
.gap-2        { gap: 8px; }
.mt-1         { margin-top: 8px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .stats    { grid-template-columns: repeat(2, 1fr); }
  .two-col  { grid-template-columns: 1fr; }
  .sidebar  { display: none; }
}
