/*
  shared.css — Design tokens and shared components
  Used by all pages in the platform.
*/
:root {
  --pri:     #dc2626;
  --pri-d:   #b91c1c;
  --pri-l:   #fef2f2;
  --ok:      #16a34a;
  --warn:    #d97706;
  --danger:  #dc2626;
  --bg:      #f1f5f9;
  --sb:      #0f172a;
  --sbt:     #94a3b8;
  --card:    #ffffff;
  --border:  #e2e8f0;
  --text:    #0f172a;
  --muted:   #64748b;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  background: var(--sb);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sb-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sb-logo .app-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
}
.sb-logo .tagline {
  font-size: 10.5px;
  color: #475569;
  margin-top: 2px;
}

.sb-section { padding: 10px 0 4px; }
.sb-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #334155;
  padding: 0 14px;
  margin-bottom: 2px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--sbt);
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: background .1s, color .1s;
}
.sb-item:hover  { background: rgba(255,255,255,.05); color: #cbd5e1; }
.sb-item.active { background: rgba(220,38,38,.18); color: #fff; border-left-color: var(--pri); font-weight: 500; }
.sb-item .icon  { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.sb-item .locked-badge {
  margin-left: auto;
  font-size: 9px;
  background: rgba(255,255,255,.1);
  color: #94a3b8;
  padding: 1px 5px;
  border-radius: 10px;
}

.sb-footer {
  margin-top: auto;
  padding: 12px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 4px;
}
.sb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--pri);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sb-user-info .u-name  { font-size: 12px; font-weight: 600; color: #e2e8f0; }
.sb-user-info .u-role  { font-size: 10px; color: #64748b; }
.sb-btn {
  width: 100%;
  padding: 6px 10px;
  margin-top: 6px;
  font-size: 11.5px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: background .1s, color .1s;
  font-family: inherit;
}
.sb-btn:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }

/* ── Main layout ──────────────────────────────────────────────────────────── */
#main {
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 18px; font-weight: 700; }
.page-header p  { font-size: 12px; color: var(--muted); margin-top: 2px; }

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

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: background .12s, box-shadow .12s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary   { background: var(--pri); color: #fff; }
.btn-primary:hover { background: var(--pri-d); }
.btn-secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f8fafc; }
.btn-danger    { background: var(--card); color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fff5f5; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 5px 6px; background: none; border: none; color: var(--muted); border-radius: 5px; cursor: pointer; font-size: 13px; transition: background .1s; }
.btn-icon:hover { background: #f1f5f9; color: var(--text); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 5px;
}
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(220,38,38,.08);
}
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 9px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-lg { max-width: 680px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body   { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 9999;
  animation: toast-in .2s ease, toast-out .25s ease 2.4s forwards;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.toast-error { background: #b91c1c; }
@keyframes toast-in  { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty .empty-icon  { font-size: 40px; margin-bottom: 10px; }
.empty h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty p  { font-size: 13px; max-width: 300px; margin: 0 auto 14px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }
.flex   { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; gap: 8px; }
.gap-8  { gap: 8px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mb-16  { margin-bottom: 16px; }
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.font-bold  { font-weight: 700; }
.hidden     { display: none !important; }

/* ── Auth loading screen ──────────────────────────────────────────────────── */
#auth-loading {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  flex-direction: column;
  gap: 14px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--pri);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Upgrade prompt ──────────────────────────────────────────────────────── */
.upgrade-banner {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  margin: 40px auto;
  max-width: 480px;
}
.upgrade-banner .ub-icon { font-size: 42px; margin-bottom: 12px; }
.upgrade-banner h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.upgrade-banner p  { font-size: 13px; color: #94a3b8; margin-bottom: 20px; }

/* ── Login page ──────────────────────────────────────────────────────────── */
body.login-page {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .app-icon { font-size: 36px; margin-bottom: 8px; }
.login-logo h1 { font-size: 20px; font-weight: 800; color: var(--text); }
.login-logo p  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.login-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; border-radius: 7px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }
