/* ═══════════════════════════════════════════════════════════════════
   Teamly Design System v1 — Claude-inspired premium light theme
   ─────────────────────────────────────────────────────────────────── */

/* ── 1. Tokens ─────────────────────────────────────────────────────── */
:root {
  /* Palette — Claude/Anthropic inspired */
  --bg:          #FAF9F5;   /* cream off-white (page bg) */
  --surface:     #FFFFFF;   /* cards, panels */
  --surface-2:   #F5F4ED;   /* nested surfaces */
  --fg:          #1F1E1B;   /* primary text */
  --fg-2:        #3A3833;   /* secondary text */
  --muted:       #757370;   /* tertiary text */
  --subtle:      #A6A39E;   /* placeholder, captions */

  --accent:      #CC785C;   /* Claude coral */
  --accent-fg:   #FFFFFF;
  --accent-soft: #F2DCCE;   /* accent on light bg */
  --accent-line: #E5BFA9;

  --success:     #5C8C5B;
  --success-soft:#E6EEE5;
  --warn:        #C99457;
  --warn-soft:   #F5E6D0;
  --danger:      #C5564C;
  --danger-soft: #F5D9D3;

  --border:      #E8E5DC;
  --border-2:    #D8D3C5;
  --line:        #F0EDE3;

  /* Shadows — soft, premium */
  --shadow-sm:   0 1px 2px rgba(31,30,27,0.04), 0 1px 1px rgba(31,30,27,0.03);
  --shadow-md:   0 2px 8px rgba(31,30,27,0.06), 0 1px 2px rgba(31,30,27,0.04);
  --shadow-lg:   0 8px 24px rgba(31,30,27,0.08), 0 2px 6px rgba(31,30,27,0.05);
  --shadow-xl:   0 16px 40px rgba(31,30,27,0.10);

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

  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-serif: "Source Serif 4", "Tiempos Headline", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --t-xs: 11px; --t-sm: 13px; --t-base: 14px; --t-md: 15px;
  --t-lg: 17px; --t-xl: 20px; --t-2xl: 24px; --t-3xl: 32px; --t-4xl: 44px;

  /* Layout */
  --header-h: 64px;
  --container: 1280px;

  /* Motion */
  --tr: 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ── 2. Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body {
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }

/* ── 3. Typography ─────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: var(--t-4xl); letter-spacing: -0.02em; }
h2 { font-size: var(--t-3xl); }
h3 { font-size: var(--t-2xl); font-weight: 600; }
h4 { font-size: var(--t-xl); font-weight: 600; font-family: var(--font-sans); letter-spacing: -0.005em; }
h5 { font-size: var(--t-lg); font-weight: 600; font-family: var(--font-sans); }
h6 { font-size: var(--t-base); font-weight: 600; font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.text-xs { font-size: var(--t-xs); } .text-sm { font-size: var(--t-sm); }
.text-md { font-size: var(--t-md); } .text-lg { font-size: var(--t-lg); }
.text-muted { color: var(--muted); } .text-subtle { color: var(--subtle); }
.text-fg2 { color: var(--fg-2); }
.text-mono { font-family: var(--font-mono); }
.font-serif { font-family: var(--font-serif); }

/* ── 4. Layout shell ──────────────────────────────────────────────── */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: var(--header-h) 1fr auto;
}

.header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s-6);
  background: rgba(250, 249, 245, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-brand {
  display: flex; align-items: center; gap: var(--s-3);
  font-family: var(--font-serif); font-weight: 500; font-size: var(--t-lg);
  letter-spacing: -0.01em;
}
.header-brand-mark {
  width: 28px; height: 28px;
  background: var(--accent); color: var(--accent-fg);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-sans); font-size: 14px;
}
.header-brand-sub {
  color: var(--muted); font-family: var(--font-sans); font-size: var(--t-sm);
  font-weight: 400; letter-spacing: 0;
}

.header-nav { display: flex; gap: var(--s-1); }
.header-nav a {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  font-size: var(--t-sm); font-weight: 500;
  color: var(--fg-2);
  transition: background var(--tr), color var(--tr);
}
.header-nav a:hover { background: var(--surface-2); color: var(--fg); }
.header-nav a.active { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }

.header-actions { display: flex; align-items: center; gap: var(--s-3); }

.main { padding: var(--s-8) var(--s-6); width: 100%; }
.container { max-width: var(--container); margin: 0 auto; }
.container-narrow { max-width: 880px; margin: 0 auto; }

.footer {
  border-top: 1px solid var(--line);
  padding: var(--s-6);
  color: var(--muted);
  font-size: var(--t-sm);
  text-align: center;
}

/* ── 5. Cards / surfaces ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-md { padding: var(--s-6); }
.card-lg { padding: var(--s-8); }
.card-hover { transition: box-shadow var(--tr), transform var(--tr); }
.card-hover:hover { box-shadow: var(--shadow-md); }

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
}

.divider { height: 1px; background: var(--line); border: none; margin: var(--s-5) 0; }

/* ── 6. Grid utilities ────────────────────────────────────────────── */
.row { display: flex; gap: var(--s-4); }
.row-md { gap: var(--s-6); }
.col { display: flex; flex-direction: column; gap: var(--s-4); }
.col-md { gap: var(--s-6); }
.col-lg { gap: var(--s-8); }
.grow { flex: 1; }
.between { justify-content: space-between; }
.center { align-items: center; }
.middle { display: flex; align-items: center; }
.stack { display: flex; flex-direction: column; gap: var(--s-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
@media (max-width: 800px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ── 7. Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: var(--t-sm); font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--tr), border-color var(--tr), color var(--tr), transform var(--tr);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: #B66950; }
.btn-secondary { background: var(--surface); border-color: var(--border-2); color: var(--fg); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--fg-2); }
.btn-ghost { color: var(--fg-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #AC4940; }
.btn-sm { padding: 5px 10px; font-size: var(--t-xs); border-radius: var(--r-xs); }
.btn-lg { padding: 12px 22px; font-size: var(--t-md); border-radius: var(--r-md); }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--r-sm); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ── 8. Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: var(--t-xs); font-weight: 600;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-neutral  { background: var(--surface-2); color: var(--fg-2); border-color: var(--border); }
.badge-accent   { background: var(--accent-soft); color: #8C4A35; border-color: var(--accent-line); }
.badge-success  { background: var(--success-soft); color: #355434; border-color: #B8D2B7; }
.badge-warn     { background: var(--warn-soft); color: #7E5A2C; border-color: #E0C58F; }
.badge-danger   { background: var(--danger-soft); color: #7A332C; border-color: #E0A89F; }
.badge-info     { background: #E7EEF3; color: #2C4A5D; border-color: #C5D5E0; }
.badge-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: var(--r-full);
  background: currentColor;
}

/* ── 9. Forms ─────────────────────────────────────────────────────── */
.input, .textarea, .select {
  display: block; width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  font-size: var(--t-sm); color: var(--fg);
  transition: border-color var(--tr), box-shadow var(--tr);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 80px; resize: vertical; font-family: var(--font-mono); font-size: var(--t-xs); }
.label { display: block; font-size: var(--t-xs); font-weight: 600; color: var(--fg-2); margin-bottom: var(--s-1); text-transform: uppercase; letter-spacing: 0.04em; }
.hint { font-size: var(--t-xs); color: var(--muted); margin-top: var(--s-1); }

/* ── 10. Tables ───────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.table th, .table td {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.table th {
  font-size: var(--t-xs); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface-2);
}
.table tbody tr { transition: background var(--tr); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table.compact th, .table.compact td { padding: var(--s-2) var(--s-3); }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ── 11. Stats ────────────────────────────────────────────────────── */
.stat {
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.stat-label {
  font-size: var(--t-xs); font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.stat-value {
  font-family: var(--font-serif); font-size: var(--t-3xl); font-weight: 500;
  letter-spacing: -0.02em; line-height: 1; color: var(--fg);
}
.stat-trend { font-size: var(--t-xs); color: var(--muted); }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend::before { content: ""; display: inline-block; width: 0; height: 0; margin-right: 4px; vertical-align: middle; }
.stat-trend.up::before { border: 4px solid transparent; border-bottom-color: var(--success); }
.stat-trend.down::before { border: 4px solid transparent; border-top-color: var(--danger); }
.stat-accent { border-left: 3px solid var(--accent); }
.stat-success { border-left: 3px solid var(--success); }
.stat-warn { border-left: 3px solid var(--warn); }

/* ── 12. Progress ─────────────────────────────────────────────────── */
.progress {
  height: 6px; background: var(--surface-2);
  border-radius: var(--r-full); overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--accent);
  border-radius: var(--r-full);
  transition: width var(--tr);
}
.progress-bar.success { background: var(--success); }
.progress-bar.warn { background: var(--warn); }

/* Ring progress (SVG-friendly) */
.ring {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0;
}
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--line); stroke-width: 4; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset var(--tr); }
.ring-fill.success { stroke: var(--success); }
.ring-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: var(--fg-2);
}

/* ── 13. Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  border: 1px solid;
}
.alert-success { background: var(--success-soft); color: #2D472D; border-color: #B8D2B7; }
.alert-error { background: var(--danger-soft); color: #6E2E27; border-color: #E0A89F; }
.alert-warn { background: var(--warn-soft); color: #6E4E25; border-color: #E0C58F; }
.alert-info { background: #E7EEF3; color: #2C4A5D; border-color: #C5D5E0; }

/* ── 14. Empty state ──────────────────────────────────────────────── */
.empty {
  text-align: center; padding: var(--s-12) var(--s-6);
  color: var(--muted); font-size: var(--t-sm);
}
.empty-icon { font-size: 32px; margin-bottom: var(--s-3); opacity: 0.5; }

/* ── 15. Scrollbars ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: var(--r-full); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── 16. Misc ─────────────────────────────────────────────────────── */
.kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--fg-2);
}
.sep { color: var(--subtle); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--accent-soft); color: #8C4A35;
  font-weight: 600; font-size: var(--t-sm);
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: var(--t-xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--t-md); }

.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: var(--r-full);
  vertical-align: middle; margin-right: 6px;
}
.dot.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* Spacing utils */
.mt-1{margin-top:var(--s-1)}.mt-2{margin-top:var(--s-2)}.mt-3{margin-top:var(--s-3)}.mt-4{margin-top:var(--s-4)}.mt-6{margin-top:var(--s-6)}.mt-8{margin-top:var(--s-8)}.mt-10{margin-top:var(--s-10)}.mt-12{margin-top:var(--s-12)}
.mb-1{margin-bottom:var(--s-1)}.mb-2{margin-bottom:var(--s-2)}.mb-3{margin-bottom:var(--s-3)}.mb-4{margin-bottom:var(--s-4)}.mb-6{margin-bottom:var(--s-6)}.mb-8{margin-bottom:var(--s-8)}
.p-4{padding:var(--s-4)}.p-6{padding:var(--s-6)}.p-8{padding:var(--s-8)}
.gap-1{gap:var(--s-1)}.gap-2{gap:var(--s-2)}.gap-3{gap:var(--s-3)}.gap-4{gap:var(--s-4)}.gap-6{gap:var(--s-6)}.gap-8{gap:var(--s-8)}
