/* ─────────────────────────────────────────────
   Rendly App UI — Design System
   Shared across all app pages
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Inter+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── TOKENS ── */
:root {
  --bg:          #07070a;
  --surface:     #0e0e0f;
  --surface-2:   #141415;
  --border:      #1e1e20;
  --border-hi:   #2d2d30;
  --accent:      #e8ff47;
  --accent-hi:   #d4eb30;
  --accent-dim:  rgba(232,255,71,0.10);
  --text:        #f0f0ee;
  --muted:       #6b6b6b;
  --muted-2:     #3a3a3c;
  --success:     #22c55e;
  --err:         #ef4444;
  --warn:        #f59e0b;

  --sp-1:  4px;  --sp-2:  8px;  --sp-3:  12px; --sp-4:  16px;
  --sp-6:  24px; --sp-8:  32px; --sp-10: 40px; --sp-12: 48px;
  --sp-16: 64px;

  --r-sm: 8px; --r: 14px; --r-lg: 22px; --r-pill: 9999px;

  --font-display: 'Inter Display', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
  --dur-xs: 120ms; --dur-sm: 220ms; --dur-md: 400ms;
}

@supports (color: oklch(0.5 0.1 120)) {
  :root {
    --bg:        oklch(0.08 0.005 95);
    --surface:   oklch(0.11 0.004 95);
    --surface-2: oklch(0.14 0.004 95);
    --border:    oklch(0.22 0.005 95);
    --border-hi: oklch(0.30 0.005 95);
    --accent:    oklch(0.95 0.220 110);
    --accent-hi: oklch(0.90 0.220 110);
    --text:      oklch(0.96 0.005 95);
    --muted:     oklch(0.52 0.008 95);
    --muted-2:   oklch(0.36 0.007 95);
  }
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

/* ── NAV ── */
#app-nav {
  display: flex; align-items: center;
  height: 52px; padding: 0 var(--sp-6);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  gap: var(--sp-2);
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text); margin-right: var(--sp-4);
  text-decoration: none; flex-shrink: 0;
}
.nav-logo em { color: var(--accent); font-style: normal; }
.nav-links { display: flex; gap: 2px; }
.nav-link {
  padding: 6px 11px;
  font-size: 13px; font-weight: 400;
  color: var(--muted);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: color var(--dur-xs) var(--ease), background var(--dur-xs) var(--ease), border-color var(--dur-xs) var(--ease);
  text-decoration: none; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(232,255,71,0.18);
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.nav-user { font-size: 12px; color: var(--muted); }
.nav-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); display: inline-block; }
.nav-dot.online { background: var(--success); box-shadow: 0 0 5px var(--success); }
.nav-dot.offline { background: var(--err); }

/* ── PAGE LAYOUT ── */
.page { max-width: 1100px; margin: 0 auto; padding: var(--sp-8) var(--sp-6); }
.page-sm { max-width: 740px; }
.page-header { margin-bottom: var(--sp-8); }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--text);
  margin-bottom: var(--sp-2); line-height: 1.2;
}
.page-header p { font-size: 13px; color: var(--muted); line-height: 1.65; max-width: 60ch; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: var(--sp-2);
}
.card-head h3 {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted);
}
.card-body { padding: var(--sp-4); }
.card-body-lg { padding: var(--sp-6); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; border: none; text-decoration: none;
  transition: background var(--dur-xs) var(--ease),
              transform var(--dur-xs) var(--ease),
              border-color var(--dur-xs) var(--ease),
              color var(--dur-xs) var(--ease),
              opacity var(--dur-xs) var(--ease);
  white-space: nowrap; line-height: 1;
}
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--accent); color: #0a0a0a; border: none; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hi); transform: translateY(-1px); }

.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-hi);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-dim);
}

.btn-danger {
  background: transparent; color: var(--err);
  border: 1px solid rgba(239,68,68,0.35);
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.08); border-color: var(--err); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 3px 9px; font-size: 11px; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-group.full { grid-column: 1 / -1; }
.form-group.col3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-3); }

.fl {
  font-size: 12px; font-weight: 500;
  color: var(--muted); display: block;
}
.fi, .fs {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13px; font-weight: 400;
  color: var(--text); font-family: var(--font-body);
  transition: border-color var(--dur-xs) var(--ease);
  outline: none;
}
.fi:focus, .fs:focus { border-color: var(--accent); }
.fi::placeholder { color: var(--muted-2); }
.fs { cursor: pointer; }
.form-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.form-actions { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; padding-top: var(--sp-2); }

/* ── TOGGLE ── */
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border-hi); border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider:before {
  content: ''; position: absolute;
  width: 14px; height: 14px; left: 3px; top: 3px;
  background: var(--muted); border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider:before { transform: translateX(16px); background: #0a0a0a; }
.toggle-row { display: flex; align-items: center; gap: var(--sp-3); }
.toggle-label { font-size: 13px; color: var(--muted); }

/* ── SAVE ROW ── */
.save-row { display: flex; align-items: center; gap: var(--sp-3); }
.save-msg  { font-size: 12px; color: var(--success); opacity: 0; transition: opacity 0.3s; }
.save-msg.show { opacity: 1; }
.err-msg   { font-size: 12px; color: var(--err); opacity: 0; transition: opacity 0.3s; }
.err-msg.show { opacity: 1; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 500;
  padding: 3px 9px; border-radius: var(--r-pill);
  letter-spacing: 0.03em;
}
.badge.done, .badge.success      { background: rgba(34,197,94,0.12); color: var(--success); }
.badge.running, .badge.active    { background: var(--accent-dim); color: var(--accent); }
.badge.failed, .badge.error      { background: rgba(239,68,68,0.12); color: var(--err); }
.badge.pending                   { background: rgba(107,107,107,0.12); color: var(--muted); }
.badge.cancelled, .badge.interrupted { background: rgba(245,158,11,0.12); color: var(--warn); }
.badge.admin { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(232,255,71,0.25); }
.badge.user  { background: rgba(255,255,255,0.04); color: var(--muted); border: 1px solid var(--border); }

/* ── DATA TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.data-table td {
  font-size: 13px; color: var(--muted);
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table td.hi { color: var(--text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.015); }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--sp-3); margin-bottom: var(--sp-6); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px var(--sp-4);
}
.stat-label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: var(--sp-3);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--text);
  line-height: 1; margin-bottom: var(--sp-2);
}
.stat-value.accent  { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warn    { color: var(--warn); }
.stat-sub { font-size: 12px; color: var(--muted); }

/* ── PROGRESS BAR ── */
.prog-wrap { background: var(--surface-2); border-radius: var(--r-pill); height: 5px; overflow: hidden; margin-bottom: var(--sp-3); }
.prog-bar { height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width 0.4s var(--ease); width: 0; }
.prog-bar.done { background: var(--success); }

/* ── EMPTY STATE ── */
.empty {
  padding: var(--sp-8);
  text-align: center; color: var(--muted);
  font-size: 13px; line-height: 1.8;
}

/* ── TOAST ── */
#toast {
  position: fixed; bottom: var(--sp-6); left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--surface-2); border: 1px solid var(--border-hi);
  color: var(--text); font-size: 13px;
  padding: 9px 18px; border-radius: var(--r-pill);
  opacity: 0;
  transition: opacity var(--dur-sm) var(--ease), transform var(--dur-sm) var(--ease);
  pointer-events: none; z-index: 500; white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error, #toast.err { border-color: rgba(239,68,68,0.45); color: var(--err); }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-lg);
  padding: var(--sp-8); width: 400px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
}
.modal-box h3 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text); margin-bottom: var(--sp-6);
}
.modal-field { margin-bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); }
.modal-field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.modal-check { display: flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: 13px; color: var(--muted); }
.modal-check input { accent-color: var(--accent); cursor: pointer; }
.modal-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-6); }
.modal-actions .btn { flex: 1; justify-content: center; }
.modal-error {
  font-size: 12px; color: var(--err);
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--r-sm);
  padding: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-3);
  display: none;
}
.modal-error.show { display: block; }
