/* Packfora Timesheet - Design System v2
   Inspired by Linear, Vercel, Stripe, Notion + Apple HIG and Material 3
   Principles: clarity > decoration, depth via shadow + motion, restrained color, tabular numbers, generous whitespace */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Design tokens ---------- */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Neutral scale (Zinc) */
  --gray-50: #fafafa;
  --gray-100: #f4f4f5;
  --gray-150: #ececef;
  --gray-200: #e4e4e7;
  --gray-300: #d4d4d8;
  --gray-400: #a1a1aa;
  --gray-500: #71717a;
  --gray-600: #52525b;
  --gray-700: #3f3f46;
  --gray-800: #27272a;
  --gray-900: #18181b;
  --gray-950: #09090b;

  /* Accent */
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-800: #1e40af;

  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-900: #14532d;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-900: #78350f;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-900: #7f1d1d;

  --violet-500: #8b5cf6;
  --teal-500:   #14b8a6;
  --pink-500:   #ec4899;

  /* Semantic */
  --bg: var(--gray-50);
  --bg-elevated: white;
  --surface: white;
  --subtle: var(--gray-100);
  --border: var(--gray-200);
  --border-soft: var(--gray-150);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-400);
  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --primary-subtle: var(--blue-50);
  --primary-border: var(--blue-200);

  /* Legacy aliases (kept for chart/icon code) */
  --card-bg: white;
  --page-bg: var(--gray-50);
  --text-primary: var(--gray-900);
  --sidebar-bg: var(--gray-950);
  --sidebar-hover: var(--gray-800);
  --sidebar-active: var(--blue-800);
  --success: var(--green-600);
  --success-bg: var(--green-100);
  --warning: var(--amber-600);
  --warning-bg: var(--amber-100);
  --danger:  var(--red-600);
  --danger-bg: var(--red-100);
  --info: var(--blue-500);
  --info-bg: var(--blue-100);

  /* Elevation (Apple-style layered shadows) */
  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-sm: 0 1px 3px rgb(15 23 42 / 0.06), 0 1px 2px -1px rgb(15 23 42 / 0.04);
  --shadow-md: 0 4px 8px -2px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.04);
  --shadow-lg: 0 10px 20px -4px rgb(15 23 42 / 0.10), 0 4px 8px -4px rgb(15 23 42 / 0.04);
  --shadow-xl: 0 20px 32px -8px rgb(15 23 42 / 0.14), 0 8px 16px -8px rgb(15 23 42 / 0.06);
  --ring: 0 0 0 4px rgb(37 99 235 / 0.12);
  --ring-danger: 0 0 0 4px rgb(220 38 38 / 0.12);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Motion */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med:  200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-sans);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.011em;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: inherit; }
button { font-family: inherit; }

::selection { background: rgb(37 99 235 / 0.18); color: var(--blue-800); }

/* Tabular numerals everywhere it matters */
.font-mono, .table td.font-mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ---------- Layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar (Linear / Vercel-style dark) ---------- */
.sidebar {
  background: var(--gray-950);
  color: var(--gray-400);
  padding: 20px 0 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgb(255 255 255 / 0.05);
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.05); border-radius: 999px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.2), inset 0 1px 0 rgb(255 255 255 / 0.15);
}

.sidebar-section { padding: 6px 12px; }

.sidebar-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  padding: 12px 12px 6px;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--gray-300);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}

.sidebar-link svg { flex-shrink: 0; opacity: 0.7; transition: opacity var(--t-fast); }
.sidebar-link:hover { background: rgb(255 255 255 / 0.04); color: white; }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active {
  background: rgb(255 255 255 / 0.06);
  color: white;
}
.sidebar-link.active svg { opacity: 1; color: var(--blue-400, #60a5fa); }
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  height: 16px;
  width: 3px;
  background: var(--blue-500);
  border-radius: 0 2px 2px 0;
}

.sidebar-spacer { flex: 1; }

.sidebar-user {
  margin: auto 12px 16px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: rgb(255 255 255 / 0.04);
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgb(255 255 255 / 0.06);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.15);
}

.user-name { color: white; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.user-role { color: var(--gray-500); font-size: 11px; }

/* ---------- Topbar (frosted glass) ---------- */
.main { min-height: 100vh; min-width: 0; overflow-x: hidden; }
.card { min-width: 0; }

.topbar {
  background: rgb(250 250 250 / 0.7);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.topbar-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-content { padding: 20px 24px 28px; }

/* ---------- Typography ---------- */
.h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.caption { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med), border-color var(--t-med);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft);
}

.card-title { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.card-subtitle { font-size: 12.5px; color: var(--text-secondary); margin-top: 3px; line-height: 1.4; }

/* ---------- Buttons (refined micro-interactions) ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 7px 13px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-xs);
  user-select: none;
}

.btn svg { flex-shrink: 0; opacity: 0.7; }
.btn:hover { border-color: var(--gray-400); background: white; box-shadow: var(--shadow-sm); transform: translateY(-0.5px); }
.btn:active { transform: translateY(0.5px); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.btn:disabled:hover { transform: none; box-shadow: var(--shadow-xs); border-color: var(--border-strong); }

.btn-primary {
  background: linear-gradient(180deg, var(--blue-500) 0%, var(--blue-600) 100%);
  color: white;
  border-color: var(--blue-700);
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.15) inset, 0 1px 2px rgb(37 99 235 / 0.4);
}
.btn-primary svg { opacity: 0.9; }
.btn-primary:hover { background: linear-gradient(180deg, var(--blue-600) 0%, var(--blue-700) 100%); border-color: var(--blue-800); box-shadow: 0 1px 0 rgb(255 255 255 / 0.15) inset, 0 4px 12px rgb(37 99 235 / 0.3); }

.btn-danger { background: var(--red-600); color: white; border-color: var(--red-600); }
.btn-danger:hover { background: var(--red-500); border-color: var(--red-500); }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--subtle); border-color: transparent; }

.btn-sm { padding: 4px 10px; font-size: 12px; gap: 4px; }
.btn-lg { padding: 9px 16px; font-size: 14px; gap: 8px; }
.btn-icon { padding: 6px; }

/* ---------- Inputs / Forms ---------- */
.input, .select {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  letter-spacing: -0.005em;
  color: var(--text);
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  box-shadow: var(--shadow-xs);
}

.input::placeholder { color: var(--text-muted); }
.input:hover, .select:hover { border-color: var(--gray-400); }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  padding-right: 32px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); letter-spacing: -0.005em; }
.field-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }

.search-input { position: relative; display: inline-block; }
.search-input::before { content: none; }
.search-input svg.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input input { padding-left: 36px; }

input[type='checkbox'] {
  width: 16px; height: 16px; cursor: pointer;
  accent-color: var(--primary);
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--gray-50); }

.table .text-right { font-variant-numeric: tabular-nums; }

/* ---------- Timesheet grid ---------- */
.ts-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.ts-grid th, .ts-grid td {
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 6px;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.ts-grid thead th {
  background: var(--gray-50);
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}

.ts-grid tbody tr { transition: background var(--t-fast); }
.ts-grid tbody tr:hover { background: var(--gray-50); }
.ts-grid tbody tr:hover .row-actions { opacity: 1; }
.ts-grid tbody tr:last-child td { border-bottom: 1px solid var(--border-soft); }

.ts-grid .day-col { width: 56px; text-align: center; }
.ts-grid .day-col input { text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.ts-grid .total-col { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; width: 56px; }
.ts-grid .remarks-col { min-width: 140px; max-width: 200px; }
.ts-grid .remarks-input { text-overflow: ellipsis; overflow: hidden; }
.ts-grid .actions-col { width: 60px; text-align: center; }
.ts-grid .subtask-cell { white-space: normal; }
.ts-grid td.subtask-cell select.ts-cell-input { min-width: 0; }

.ts-cell-input {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 5px 6px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-family: inherit;
  letter-spacing: -0.005em;
  line-height: 1.4;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  width: 100%;
  text-overflow: ellipsis;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}

.ts-cell-input:hover { border-color: var(--border-strong); background: white; }
.ts-cell-input:focus { outline: none; border-color: var(--primary); background: white; box-shadow: var(--ring); }

select.ts-cell-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 12px;
  padding-right: 24px;
}

/* Number inputs - tight, explicit color to defend against browser quirks */
input.ts-cell-input[type="number"] {
  -moz-appearance: textfield;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text);
  font-weight: 600;
  font-size: 13px;
  padding: 5px 2px;
  opacity: 1;
}
input.ts-cell-input[type="number"]::-webkit-inner-spin-button,
input.ts-cell-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input.ts-cell-input.has-value {
  color: var(--blue-700) !important;
  -webkit-text-fill-color: var(--blue-700);
}
input.ts-cell-input[type="number"]:hover { background: white; border-color: var(--border-strong); }
input.ts-cell-input[type="number"]:focus { background: white; border-color: var(--primary); color: var(--text) !important; -webkit-text-fill-color: var(--text); }

.weekend-col { background: rgb(244 244 245 / 0.5); }
.today-col { background: rgb(254 243 199 / 0.5); }
.today-header { position: relative; padding-top: 18px !important; }
.today-header::after {
  content: 'TODAY';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8.5px;
  color: white;
  background: var(--amber-600);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

.row-actions { opacity: 0; transition: opacity var(--t-fast); display: inline-flex; gap: 2px; }
.row-action-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.row-action-btn:hover { background: var(--gray-100); color: var(--primary); }
.row-action-btn.danger:hover { color: var(--red-600); background: var(--red-50); }

/* Billable indicator under subtask */
.subtask-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  letter-spacing: 0.01em;
}
.subtask-pill::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.subtask-pill.b { background: var(--green-100); color: var(--green-700); }
.subtask-pill.nb { background: var(--gray-100); color: var(--gray-600); }

/* Row left accent based on billable */
.row-accent-b td:first-child { box-shadow: inset 3px 0 0 var(--green-500); }
.row-accent-nb td:first-child { box-shadow: inset 3px 0 0 var(--gray-300); }

/* ---------- Status grid (manager view) ---------- */
.status-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.status-grid th, .status-grid td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.status-grid th {
  background: var(--gray-50);
  font-weight: 500;
  font-size: 11px;
  color: var(--text-secondary);
}

.status-grid .name-col {
  text-align: left;
  font-weight: 500;
  background: white;
  position: sticky;
  left: 0;
  color: var(--text);
}

.cell-submitted { background: var(--green-100); color: var(--green-700); font-weight: 600; }
.cell-partial   { background: var(--amber-100); color: var(--amber-700); font-weight: 600; }
.cell-missing   { background: var(--red-100); color: var(--red-600); font-weight: 600; }
.cell-leave     { background: var(--gray-100); color: var(--text-secondary); font-style: italic; }
.cell-locked    { background: var(--gray-50); color: var(--text-muted); font-style: italic; }

/* ---------- Badges (refined) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-success { background: var(--green-100); color: var(--green-700); border-color: rgb(187 247 208); }
.badge-warning { background: var(--amber-100); color: var(--amber-700); border-color: rgb(253 230 138); }
.badge-danger  { background: var(--red-100);   color: var(--red-600);   border-color: rgb(254 202 202); }
.badge-info    { background: var(--blue-100);  color: var(--blue-700);  border-color: rgb(191 219 254); }
.badge-neutral { background: var(--gray-100);  color: var(--text-secondary); border-color: var(--border); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  transition: all var(--t-med);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }

.kpi-label { font-size: 11.5px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; letter-spacing: -0.005em; }
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.kpi-meta.up   { color: var(--green-600); }
.kpi-meta.down { color: var(--red-600); }

/* ---------- Week navigator ---------- */
.week-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.week-nav-current { font-weight: 600; font-size: 14.5px; flex: 1; letter-spacing: -0.015em; }
.week-nav-meta { color: var(--text-secondary); font-size: 12.5px; font-weight: 400; margin-left: 8px; }

/* ---------- Tabs (refined) ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab svg { opacity: 0.6; transition: opacity var(--t-fast); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab.active svg { opacity: 1; }
.tab:hover:not(.active) { color: var(--text); }
.tab:hover:not(.active) svg { opacity: 1; }

/* ---------- Validation banner ---------- */
.banner {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 16px;
  align-items: flex-start;
  border: 1px solid transparent;
  box-shadow: var(--shadow-xs);
}

.banner svg { flex-shrink: 0; margin-top: 1px; }
.banner-success { background: var(--green-50); color: var(--green-900); border-color: rgb(187 247 208); }
.banner-success svg { color: var(--green-600); }
.banner-warning { background: var(--amber-50); color: var(--amber-900); border-color: rgb(253 230 138); }
.banner-warning svg { color: var(--amber-600); }
.banner-danger  { background: var(--red-50);   color: var(--red-900);   border-color: rgb(254 202 202); }
.banner-danger svg { color: var(--red-600); }
.banner-info    { background: var(--blue-50);  color: var(--blue-800);  border-color: rgb(191 219 254); }
.banner-info svg { color: var(--blue-600); }

/* ---------- Summary bar (sticky) ---------- */
.summary-bar {
  position: sticky;
  bottom: 0;
  background: rgb(255 255 255 / 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 14px -24px -28px;
  box-shadow: 0 -8px 24px rgb(15 23 42 / 0.06);
  z-index: 10;
}

.summary-stats { display: flex; gap: 36px; }
.summary-stat-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; letter-spacing: 0.02em; text-transform: uppercase; }
.summary-stat-value { font-size: 19px; font-weight: 700; margin-top: 2px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.summary-actions { display: flex; gap: 8px; }

/* ---------- Chart cards ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.chart-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); }

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-med);
}

.chart-card-header { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.chart-card-title { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.chart-card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.chart-card-body { min-height: 180px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--text-secondary); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Toast notifications ---------- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--gray-900);
  color: white;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  animation: toast-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgb(255 255 255 / 0.08);
}

.toast svg { flex-shrink: 0; opacity: 0.9; }
.toast.success { background: var(--green-700); }
.toast.error   { background: var(--red-600); }
.toast.warning { background: var(--amber-700); }
.toast.info    { background: var(--gray-900); }
.toast.removing { animation: toast-out 0.22s cubic-bezier(0.7, 0, 0.84, 0) forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px) scale(0.96); }
}

/* ---------- Icons ---------- */
.btn svg { flex-shrink: 0; }
.icon-muted { color: var(--text-muted); }
.icon-success { color: var(--green-600); }
.icon-warning { color: var(--amber-600); }
.icon-danger  { color: var(--red-600); }
.icon-info    { color: var(--blue-600); }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-muted); }
.empty-state svg { color: var(--text-muted); opacity: 0.4; margin-bottom: 12px; }
.empty-state-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

/* ---------- Lock pill ---------- */
.lock-pill { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgb(37 99 235 / 0.25) 0%, transparent 60%),
              linear-gradient(180deg, #0a0a0b 0%, #050507 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgb(255 255 255 / 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: rgb(255 255 255 / 0.98);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.4), 0 0 0 1px rgb(255 255 255 / 0.08);
  text-align: center;
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
  border-radius: var(--r-lg);
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgb(37 99 235 / 0.4), inset 0 1px 0 rgb(255 255 255 / 0.2);
}

.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.025em; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 13.5px; }

.btn-sso {
  width: 100%;
  justify-content: center;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 500;
  background: white;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--r-md);
}

.btn-sso:hover { background: var(--gray-50); }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.login-footer { margin-top: 28px; font-size: 12px; color: var(--text-muted); }
.login-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.login-footer a:hover { text-decoration: underline; }

/* ---------- Gallery (index) ---------- */
.gallery-page {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgb(37 99 235 / 0.08) 0%, transparent 60%),
    var(--bg);
}

.gallery {
  max-width: 1200px;
  margin: 0 auto;
  padding: 72px 24px 64px;
}

.gallery-header { text-align: center; margin-bottom: 56px; }
.gallery-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}
.gallery-eyebrow .dot { background: var(--primary); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.gallery-header h1 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 14px;
  background: linear-gradient(180deg, var(--text) 0%, #475569 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.gallery-header p { color: var(--text-secondary); font-size: 16px; max-width: 560px; margin: 0 auto; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
}

.gallery-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all var(--t-med);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.gallery-item::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-lg);
  pointer-events: none;
  box-shadow: 0 0 0 0 var(--primary);
  transition: box-shadow var(--t-med);
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-border);
}
.gallery-item:hover::after { box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1); }

.gallery-preview {
  height: 168px;
  background:
    radial-gradient(circle at 20% 20%, rgb(37 99 235 / 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgb(139 92 246 / 0.05) 0%, transparent 50%),
    linear-gradient(180deg, var(--gray-50) 0%, white 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid var(--border-soft);
}

.gallery-preview svg { width: 48px; height: 48px; color: var(--primary); opacity: 0.85; }
.gallery-preview::before {
  content: '';
  position: absolute;
  inset: 16px;
  border-radius: var(--r-md);
  border: 1px dashed var(--border);
  pointer-events: none;
  opacity: 0.5;
}

.gallery-info { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.gallery-number { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.06em; font-family: var(--font-mono); }
.gallery-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.gallery-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; margin-top: 2px; }
.gallery-tag {
  display: inline-flex;
  margin-top: 10px;
  font-size: 10.5px;
  padding: 2px 8px;
  background: var(--gray-100);
  color: var(--text-secondary);
  border-radius: var(--r-pill);
  font-weight: 600;
  align-self: flex-start;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gallery-tag.new { background: var(--green-100); color: var(--green-700); }

.gallery-footer { text-align: center; margin-top: 56px; color: var(--text-muted); font-size: 12.5px; }

/* ---------- Utilities ---------- */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.required::after { content: ' *'; color: var(--red-600); }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; }

/* ---------- Responsiveness ---------- */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
