/* ── Apple Design System Variables ──────────────────────────────── */
:root {
  --apple-blue: #007AFF;
  --apple-blue-hover: #0063D1;
  --apple-gray: #8E8E93;
  --apple-gray-light: #AEAEB2;
  --apple-bg: #F2F2F7;
  --apple-card: #FFFFFF;
  --apple-text: #1D1D1F;
  --apple-text-secondary: #6E6E73;
  --apple-separator: #C6C6C8;
  --apple-red: #FF3B30;
  --apple-green: #34C759;
  --apple-orange: #FF9500;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --transition: 0.2s ease;
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-stack);
  background: var(--apple-bg);
  color: var(--apple-text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--apple-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }

/* ── Typography ────────────────────────────────────────────────── */
.text-large   { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.text-title   { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.text-heading  { font-size: 17px; font-weight: 600; }
.text-body     { font-size: 17px; font-weight: 400; }
.text-caption  { font-size: 13px; font-weight: 400; color: var(--apple-text-secondary); }
.text-center   { text-align: center; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px;
  font-size: 17px; font-weight: 500;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  font-family: var(--font-stack);
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--apple-blue); color: #fff;
}
.btn-primary:hover { background: var(--apple-blue-hover); box-shadow: 0 2px 8px rgba(0,122,255,0.3); }
.btn-primary:disabled { background: var(--apple-gray-light); cursor: not-allowed; box-shadow: none; }
.btn-secondary {
  background: var(--apple-bg); color: var(--apple-blue);
}
.btn-secondary:hover { background: #E5E5EA; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 15px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  border-radius: 50%; background: transparent; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--apple-gray);
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--apple-bg); color: var(--apple-text); }

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-flat { box-shadow: none; }
.card-flat:hover { box-shadow: none; }

/* ── Form Elements ─────────────────────────────────────────────── */
.input-group { margin-bottom: 16px; }
.input-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--apple-text-secondary); margin-bottom: 6px;
}
.input {
  width: 100%; padding: 14px 16px;
  font-size: 17px; font-family: var(--font-stack);
  background: var(--apple-bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.input:focus {
  border-color: var(--apple-blue);
  background: #fff;
}
.input::placeholder { color: var(--apple-gray-light); }

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
  background: rgba(255,255,255,0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--apple-separator);
  position: sticky; top: 0; z-index: 100;
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 600; color: var(--apple-text);
}
.navbar-brand svg { width: 28px; height: 28px; }
.navbar-actions {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px; color: var(--apple-text-secondary);
}
.navbar-actions .username { font-weight: 500; color: var(--apple-text); }

/* ── Sidebar + Tabs ────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  background: var(--apple-card);
  padding: 8px 16px;
  border-bottom: 0.5px solid var(--apple-separator);
}
.tab-item {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500;
  color: var(--apple-text-secondary);
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; user-select: none;
}
.tab-item:hover { background: var(--apple-bg); color: var(--apple-text); text-decoration: none; }
.tab-item.active { background: var(--apple-blue); color: #fff; }
.tab-item.active:hover { background: var(--apple-blue-hover); color: #fff; }

/* ── Stat Cards ────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-number {
  font-size: 36px; font-weight: 700; letter-spacing: -1px;
  color: var(--apple-text); margin-bottom: 4px;
}
.stat-label {
  font-size: 15px; color: var(--apple-text-secondary); font-weight: 400;
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; font-size: 22px;
}
.stat-icon.blue   { background: rgba(0,122,255,0.1); color: var(--apple-blue); }
.stat-icon.green  { background: rgba(52,199,89,0.1);  color: var(--apple-green); }
.stat-icon.orange { background: rgba(255,149,0,0.1);  color: var(--apple-orange); }
.stat-icon.red    { background: rgba(255,59,48,0.1);  color: var(--apple-red); }

/* ── Status Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
}
.badge-green  { background: rgba(52,199,89,0.12);  color: #248A3D; }
.badge-orange { background: rgba(255,149,0,0.12);  color: #C93400; }
.badge-red    { background: rgba(255,59,48,0.12);  color: #D70015; }
.badge-blue   { background: rgba(0,122,255,0.12);  color: #0040DD; }
.badge-gray   { background: var(--apple-bg);        color: var(--apple-gray); }
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.badge-green .badge-dot  { background: var(--apple-green); }
.badge-orange .badge-dot { background: var(--apple-orange); }
.badge-red .badge-dot    { background: var(--apple-red); }

/* ── List Items ────────────────────────────────────────────────── */
.list-group {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  border-bottom: 0.5px solid var(--apple-separator);
  transition: background var(--transition);
  cursor: pointer;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--apple-bg); }
.list-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--apple-bg); color: var(--apple-gray);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; flex-shrink: 0;
}
.list-content { flex: 1; min-width: 0; }
.list-title { font-size: 17px; font-weight: 400; }
.list-subtitle { font-size: 15px; color: var(--apple-text-secondary); }
.list-meta { font-size: 13px; color: var(--apple-gray); flex-shrink: 0; }

/* ── Empty State ───────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 24px; color: var(--apple-gray);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.3; }
.empty-state p { font-size: 17px; margin-top: 8px; }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 380px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.modal p.desc { font-size: 15px; color: var(--apple-text-secondary); margin-bottom: 20px; }

/* ── Toast ─────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 64px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--apple-card);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  font-size: 15px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease;
  max-width: 360px;
}
.toast.error { border-left: 3px solid var(--apple-red); }
.toast.success { border-left: 3px solid var(--apple-green); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Search ────────────────────────────────────────────────────── */
.search-bar {
  position: relative;
}
.search-bar .input { padding-left: 40px; }
.search-bar svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--apple-gray);
  pointer-events: none;
}

/* ── Layout Helpers ────────────────────────────────────────────── */
.container { max-width: 1080px; margin: 0 auto; padding: 24px; }
.page-header { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ── Login Layout ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--apple-card);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 400px; max-width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 20px;
  background: var(--apple-green);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo svg { width: 36px; height: 36px; color: #fff; }
.login-card h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.login-card .subtitle {
  font-size: 17px; color: var(--apple-text-secondary);
  margin-bottom: 32px;
}
.login-error {
  color: var(--apple-red); font-size: 14px;
  margin-top: 12px; min-height: 20px;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .navbar { padding: 0 16px; }
  .tab-bar { overflow-x: auto; padding: 8px 12px; }
  .login-card { padding: 32px 24px; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
