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

/* ============================================================
   SH App Control — Dark Pro (green accent)
   ============================================================ */

:root {
  --font-sans: 'Tomorrow', system-ui, -apple-system, sans-serif;
  --sidebar-w: 252px;
  --topbar-h: 60px;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: all .15s cubic-bezier(.4,0,.2,1);

  --bg: #0a0a0d;
  --bg-page: #08080a;
  --bg-raised: #121216;
  --bg-elevated: #1a1a20;
  --bg-hover: #1f1f27;
  --border: rgba(255,255,255,.08);
  --border-light: rgba(255,255,255,.05);
  --border-strong: rgba(255,255,255,.14);
  --text: #f5f5f7;
  --text-sub: #cbcbd4;
  --text-muted: #8b8b9a;
  --text-dim: #55555f;
  --text-inverse: #06110d;

  --shadow-xs: 0 0 0 1px rgba(255,255,255,.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.35);
  --shadow: 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55);
  --shadow-glow: 0 0 0 1px rgba(28,200,138,.25), 0 8px 24px rgba(28,200,138,.08);

  --sb-bg: #0d0d11;
  --sb-border: rgba(255,255,255,.06);
  --sb-hover: rgba(255,255,255,.05);
  --sb-active-bg: linear-gradient(90deg, rgba(28,200,138,.16), rgba(28,200,138,.03));
  --sb-active-txt: #7ce8bf;
  --sb-active-icon: #1cc88a;
  --sb-text: #74748a;
  --sb-icon: #4a4a5a;
  --sb-section: #46465a;

  --primary: #1cc88a;
  --primary-dark: #16a673;
  --primary-light: #4ee0a8;
  --primary-soft: rgba(28,200,138,.12);
  --primary-soft-strong: rgba(28,200,138,.2);

  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --danger-soft: rgba(239,68,68,.12);
  --info: #38bdf8;
  --purple: #a78bfa;

  --stat-1: #1cc88a;
  --stat-2: #38bdf8;
  --stat-3: #a78bfa;
  --stat-4: #f472b6;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-page: #f4f6f8;
  --bg-raised: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-hover: #eef2f6;
  --border: rgba(15,23,42,.08);
  --border-light: rgba(15,23,42,.05);
  --border-strong: rgba(15,23,42,.14);
  --text: #0f172a;
  --text-sub: #334155;
  --text-muted: #64748b;
  --text-dim: #98a2b3;
  --text-inverse: #ffffff;

  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 2px 8px rgba(15,23,42,.06);
  --shadow: 0 8px 24px rgba(15,23,42,.08);
  --shadow-lg: 0 16px 48px rgba(15,23,42,.12);

  --sb-bg: #ffffff;
  --sb-border: rgba(15,23,42,.06);
  --sb-hover: rgba(15,23,42,.04);
}

/* ── Reset ─────────────────────────────────────────────────── */
* , *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-page);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-light); }
::selection { background: var(--primary-soft-strong); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: content-box; }

/* ── Preloader ─────────────────────────────────────────────── */
#pagePreloader { position: fixed; inset: 0; z-index: 9999; background: var(--bg-page); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; }
.pl-name { font-weight: 700; font-size: 15px; color: var(--text-sub); letter-spacing: .04em; }
.pl-bar-wrap { width: 140px; height: 3px; background: var(--border); border-radius: 10px; overflow: hidden; }
.pl-bar { width: 40%; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); border-radius: 10px; animation: plmove 1.1s ease-in-out infinite; }
@keyframes plmove { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* ── Auth page ─────────────────────────────────────────────── */
.auth-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background:
    radial-gradient(600px circle at 15% 20%, rgba(28,200,138,.10), transparent 60%),
    radial-gradient(600px circle at 85% 80%, rgba(56,189,248,.08), transparent 60%),
    var(--bg-page);
}
.auth-wrap { width: 100%; max-width: 380px; padding: 24px; }
.auth-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 36px 30px; box-shadow: var(--shadow-lg); }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: var(--radius-lg); background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 26px; box-shadow: 0 0 0 6px rgba(28,200,138,.05); }
.auth-brand-name { font-weight: 700; font-size: 19px; color: var(--text); letter-spacing: -.01em; }
.auth-brand-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* ── Layout ────────────────────────────────────────────────── */
.crm-layout { display: flex; min-height: 100vh; }
.crm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.crm-content { padding: 28px 32px 48px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ── Sidebar ───────────────────────────────────────────────── */
.crm-sidebar { width: var(--sidebar-w); min-height: 100vh; background: var(--sb-bg); border-right: 1px solid var(--sb-border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; transition: var(--transition); }
.sb-brand { padding: 18px 16px; border-bottom: 1px solid var(--sb-border); }
.sb-brand-link { display: flex; align-items: center; gap: 11px; }
.sb-brand-icon { width: 34px; height: 34px; border-radius: var(--radius); background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--text-inverse); display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 2px 10px rgba(28,200,138,.3); flex-shrink: 0; }
.sb-brand-name { font-weight: 700; color: var(--text); font-size: 14.5px; letter-spacing: -.01em; }
.sb-nav { padding: 14px 10px 24px; flex: 1; }
.sb-section { margin-bottom: 10px; }
.sb-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; color: var(--sb-section); padding: 10px 12px 6px; }
.sb-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.sb-nav-link { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--sb-text); font-size: 13.2px; font-weight: 500; transition: var(--transition); }
.sb-nav-link:hover { background: var(--sb-hover); color: var(--text); }
.sb-nav-link.active { background: var(--sb-active-bg); color: var(--sb-active-txt); font-weight: 600; }
.sb-nav-link.active::before { content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 16px; border-radius: 3px; background: var(--primary); }
.sb-nav-link.active .sb-nav-icon { color: var(--sb-active-icon); }
.sb-nav-icon { color: var(--sb-icon); width: 16px; text-align: center; font-size: 14px; flex-shrink: 0; }
.sb-nav-badge { margin-left: auto; background: var(--primary-soft); color: var(--primary); font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }

.sb-overlay { display: none; }

/* ── Topbar ────────────────────────────────────────────────── */
.crm-topbar { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 30; }
.topbar-title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.sidebar-toggle { display: none; background: transparent; border: 1px solid var(--border); color: var(--text-sub); border-radius: var(--radius-sm); width: 34px; height: 34px; align-items: center; justify-content: center; cursor: pointer; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; }

/* ── Page header ───────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header-titles { display: flex; align-items: center; gap: 12px; }
.page-header-icon { width: 40px; height: 40px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.page-header h1 { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -.01em; color: var(--text); }
.page-header-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Cards ─────────────────────────────────────────────────── */
.crm-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow-xs); }
.crm-card-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.crm-card-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; }
.crm-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Stat tiles ────────────────────────────────────────────── */
.stat-tile { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-xs); transition: var(--transition); }
.stat-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.stat-tile-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.stat-tile-icon.c1 { background: rgba(28,200,138,.14); color: var(--stat-1); }
.stat-tile-icon.c2 { background: rgba(56,189,248,.14); color: var(--stat-2); }
.stat-tile-icon.c3 { background: rgba(167,139,250,.14); color: var(--stat-3); }
.stat-tile-icon.c4 { background: rgba(244,114,182,.14); color: var(--stat-4); }
.stat-tile-value { font-size: 24px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-tile-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ── Tables ────────────────────────────────────────────────── */
.table { color: var(--text); margin-bottom: 0; }
.table > :not(caption) > * > * { border-color: var(--border); background: transparent; color: var(--text); padding: 12px 14px; vertical-align: middle; }
.table thead th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--bg-hover); }
.table-responsive-card { overflow-x: auto; margin: -22px; padding: 6px 22px 22px; }

.row-thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-elevated); border: 1px solid var(--border); flex-shrink: 0; }
.row-thumb-placeholder { width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-size: 16px; flex-shrink: 0; }
.row-title-cell { display: flex; align-items: center; gap: 12px; }
.row-title-main { font-weight: 600; color: var(--text); }
.row-title-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-control, .form-select { background: var(--bg-elevated); border-color: var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px; }
.form-control:focus, .form-select:focus { background: var(--bg-elevated); border-color: var(--primary); color: var(--text); box-shadow: 0 0 0 .2rem var(--primary-soft); }
.form-control::placeholder { color: var(--text-dim); }
.form-label { color: var(--text-sub); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.form-check-input { background-color: var(--bg-elevated); border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem var(--primary-soft); }
.form-text { color: var(--text-muted); font-size: 12px; }
textarea.form-control[style*="monospace"] { line-height: 1.5; }

.form-section-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 22px 0 12px; padding-top: 14px; border-top: 1px solid var(--border-light); }
.form-section-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.form-actions { display: flex; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border-light); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn { border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; padding: 8px 16px; transition: var(--transition); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-primary { background-color: var(--primary); border-color: var(--primary); color: var(--text-inverse); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--primary-dark); border-color: var(--primary-dark); color: var(--text-inverse); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(28,200,138,.25); }
.btn-outline-secondary { color: var(--text-sub); border-color: var(--border-strong); background: transparent; }
.btn-outline-secondary:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }
.btn-outline-danger { color: var(--danger); border-color: rgba(239,68,68,.3); background: transparent; }
.btn-outline-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* ── Badges ────────────────────────────────────────────────── */
.badge-status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px 3px 8px; border-radius: 20px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-status.published { background: rgba(34,197,94,.12); color: var(--success); }
.badge-status.draft { background: rgba(234,179,8,.12); color: var(--warning); }
.badge-status.failed { background: rgba(239,68,68,.12); color: var(--danger); }

.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--bg-elevated); color: var(--text-sub); border: 1px solid var(--border); }
.chip.featured { background: rgba(234,179,8,.12); color: var(--warning); border-color: transparent; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-elevated); color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-size: 22px; margin: 0 auto 16px; }
.empty-state-title { font-size: 14.5px; font-weight: 700; color: var(--text-sub); margin-bottom: 4px; }
.empty-state-text { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); border: 1px solid var(--border); font-size: 13.5px; padding: 12px 16px; }
.alert-success { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.25); color: #4ade80; }
.alert-danger { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.25); color: #f87171; }

/* ── Misc ──────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
hr { border-color: var(--border-light); opacity: 1; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 960px) {
  .crm-sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .crm-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .sb-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 39; }
  .crm-content { padding: 20px 16px 40px; }
  .crm-topbar { padding: 0 16px; }
}
