/* Design system v2 — light, Swiss-minimal, navy/blue.
   Replaces the dark-gradient v1 system. Informed by mailchimp.com (warm,
   restrained editorial) and hub.oanda.com (clean sidebar SaaS dashboard). */

:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --ink: #0F172A;
  --muted: #475569;
  --muted-2: #64748B;
  --primary: #1D4ED8;
  --primary-hover: #1E40AF;
  --accent: #0EA5E9;
  --success: #16A34A;
  --success-bg: #F0FDF4;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body.ds2 {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; }

/* ── App shell: fixed sidebar + content ─────────────────────────── */
.ds2-shell { display: flex; min-height: 100vh; }

.ds2-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.9rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 40;
}

.ds2-brand {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem 1.25rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.ds2-brand span { color: var(--primary); }

.ds2-nav a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
  font-size: 0.86rem; font-weight: 500; color: var(--muted);
  text-decoration: none; margin-bottom: 0.15rem;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.ds2-nav a:hover { background: var(--surface-2); color: var(--ink); }
.ds2-nav a.active { background: #EFF6FF; color: var(--primary); font-weight: 600; }
.ds2-nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.ds2-nav .sep { height: 1px; background: var(--border); margin: 0.75rem 0.6rem; }

.ds2-main { margin-left: var(--sidebar-w); flex: 1; padding: 2rem 2.5rem 4rem; min-width: 0; }
.ds2-main.no-sidebar { margin-left: 0; width: 100%; }
.ds2-main.no-sidebar .ds2-wrap { margin: 0 auto; }

/* ── Typography & basic layout ──────────────────────────────────── */
.ds2-wrap { max-width: 900px; }
.ds2-wrap.narrow { max-width: 480px; }

.ds2-h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.2rem; color: var(--ink); }
.ds2-sub { color: var(--muted); font-size: 0.88rem; margin-bottom: 1.75rem; }
.ds2-sub a { color: var(--primary); font-weight: 600; text-decoration: none; }
.ds2-sub a:hover { text-decoration: underline; }

.ds2-topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.25rem; }
.ds2-logout {
  color: var(--muted); font-size: 0.82rem; text-decoration: none;
  padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  transition: all 0.15s var(--ease); background: var(--surface);
}
.ds2-logout:hover { color: var(--ink); border-color: var(--border-strong); background: var(--surface-2); }

/* ── Cards ───────────────────────────────────────────────────────── */
.ds2-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}
.ds2-card h2 {
  font-size: 0.95rem; font-weight: 700; margin: 0 0 1.1rem; color: var(--ink);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}

/* ── Stat cards ──────────────────────────────────────────────────── */
.ds2-stats { display: flex; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.ds2-stat {
  flex: 1; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.4rem;
}
.ds2-stat .num { font-size: 1.8rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.ds2-stat .label { color: var(--muted); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.25rem; font-weight: 600; }

/* ── Forms ───────────────────────────────────────────────────────── */
.ds2-label {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: var(--ink); margin: 1rem 0 0.35rem;
}
.ds2-label:first-child { margin-top: 0; }

.ds2-input, .ds2-select, .ds2-textarea {
  width: 100%; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  font-size: 0.88rem; font-family: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.ds2-input::placeholder, .ds2-textarea::placeholder { color: #94A3B8; }
.ds2-input:focus, .ds2-select:focus, .ds2-textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,0.12);
}
.ds2-textarea { min-height: 4rem; resize: vertical; }

.ds2-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.1rem; border: 1px solid var(--primary); border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; font-weight: 600; font-size: 0.86rem; cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.ds2-btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.ds2-btn.block { width: 100%; }
.ds2-btn.ghost {
  background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); font-weight: 500;
}
.ds2-btn.ghost:hover { background: var(--surface-2); }
.ds2-btn.small { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

/* ── Table ───────────────────────────────────────────────────────── */
.ds2-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ds2-table th, .ds2-table td { text-align: left; padding: 0.6rem 0.65rem; }
.ds2-table th {
  color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: 1px solid var(--border);
}
.ds2-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.ds2-table tbody tr { transition: background 0.15s var(--ease); }
.ds2-table tbody tr:hover { background: var(--surface-2); }

.ds2-empty { color: var(--muted-2); padding: 2.5rem 0; text-align: center; font-size: 0.86rem; }

/* ── Flash / alerts ──────────────────────────────────────────────── */
.ds2-flash {
  border-radius: var(--radius); padding: 0.85rem 1.1rem; margin-bottom: 1.25rem; font-size: 0.86rem;
  border: 1px solid; line-height: 1.5;
}
.ds2-flash.ok { background: var(--success-bg); border-color: #BBF7D0; color: #166534; }
.ds2-flash.err { background: var(--danger-bg); border-color: #FECACA; color: #991B1B; }
.ds2-flash h3 { margin: 0 0 0.5rem; font-size: 0.92rem; }
.ds2-flash ol { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.ds2-flash li { margin-bottom: 0.45rem; line-height: 1.45; }
.ds2-flash code { background: rgba(0,0,0,0.06); }

.ds2-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 0.35rem; border: 1px solid rgba(0,0,0,0.1); }

.ds2-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.ds2-badge.ok { background: var(--success-bg); color: #166534; }
.ds2-badge.pending { background: var(--warning-bg); color: #92400E; }
.ds2-badge.off { background: var(--surface-2); color: var(--muted-2); }

.ds2-hint { color: var(--muted-2); font-size: 0.76rem; margin-top: 0.3rem; line-height: 1.4; }

code { background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; border: 1px solid var(--border); }

.ds2-colorrow { display: flex; align-items: center; gap: 0.5rem; }
.ds2-colorrow span { font-size: 0.82rem; color: var(--muted); }
.ds2-color-input { width: 2.6rem; height: 2rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 2px; background: var(--surface); cursor: pointer; }

.ds2-dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 1.4rem;
  text-align: center; cursor: pointer; transition: all 0.15s var(--ease); background: var(--surface-2);
}
.ds2-dropzone.drag { border-color: var(--primary); background: #EFF6FF; }
.ds2-dropzone img { max-height: 64px; max-width: 200px; border-radius: 6px; }
