:root {
  --navy: #073849;
  --navy-light: #0d4f65;
  --navy-dark: #052a37;
  --lime: #A9D300;
  --lime-dark: #8bb000;
  --white: #ffffff;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-600: #2563eb;
  --green-50: #f0fdf4;
  --green-600: #16a34a;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --red-50: #fef2f2;
  --red-600: #dc2626;
  --purple-50: #faf5ff;
  --purple-600: #9333ea;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 3px rgb(0 0 0/0.05), 0 1px 2px rgb(0 0 0/0.05);
  --shadow-panel: 0 4px 24px rgb(0 0 0/0.08);
  --font-body: 'DM Sans', sans-serif;
  --font-display: 'DM Serif Display', serif;
  --sidebar-width: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font-body); background: var(--slate-50); color: var(--slate-900); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1,h2,h3 { font-family: var(--font-display); letter-spacing: -0.01em; }
a { text-decoration: none; color: inherit; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }
input,select,textarea { font-family: var(--font-body); }
.hidden { display: none !important; }

/* ====== LAYOUT ====== */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--sidebar-width); background: var(--navy); display: flex; flex-direction: column; flex-shrink: 0; }
.main { flex: 1; overflow-y: auto; background: var(--slate-50); }
.page { padding: 2rem; max-width: 1200px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-title { font-size: 2rem; color: var(--slate-900); }
.page-sub { font-size: 0.875rem; color: var(--slate-500); margin-top: 0.25rem; }

/* ====== SIDEBAR ====== */
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-icon { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--lime); border-radius: 10px; flex-shrink: 0; }
.logo-icon svg path { stroke: var(--navy); }
.logo-icon-sm { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; background: var(--lime); border-radius: 8px; flex-shrink: 0; }
.sidebar-title { font-family: var(--font-display); font-size: 1.25rem; color: white; }
.sidebar-nav { flex: 1; padding: 0.75rem 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 0.75rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500; color: rgba(255,255,255,0.55); transition: all 0.15s; position: relative; }
.nav-link:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-link.active { color: white; background: rgba(255,255,255,0.12); }
.sidebar-footer { padding: 0.75rem; border-top: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 0.5rem; }
.user-chip { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--lime); color: var(--navy); font-size: 0.75rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-info { min-width: 0; }
.user-info span { display: block; font-size: 0.75rem; }
#user-name { color: white; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#user-email { color: rgba(255,255,255,0.4); font-size: 0.65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ====== LOGIN ====== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; position: relative; }
.login-bg { position: absolute; inset: 0; background: var(--slate-50); }
.login-card { position: relative; width: 100%; max-width: 380px; }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo .logo-icon { margin: 0 auto 1rem; width: 56px; height: 56px; border-radius: 16px; background: var(--navy); }
.login-logo h1 { font-size: 1.875rem; color: var(--slate-900); }
.login-logo p { color: var(--slate-500); font-size: 0.875rem; margin-top: 0.25rem; }
.login-form { background: white; border-radius: var(--radius-lg); border: 1px solid var(--slate-200); box-shadow: var(--shadow-panel); padding: 2rem; }
.login-form h2 { font-family: var(--font-body); font-size: 1.125rem; font-weight: 600; margin-bottom: 0.25rem; }
.login-sub { font-size: 0.875rem; color: var(--slate-500); margin-bottom: 1.5rem; }
.btn-harvest { width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 0.875rem 1rem; background: #FA5A28; color: white; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; transition: all 0.15s; }
.btn-harvest:hover { background: #e04e20; }

/* ====== CARDS ====== */
.card { background: white; border-radius: var(--radius); border: 1px solid var(--slate-200); box-shadow: var(--shadow-card); }
.card:hover { box-shadow: 0 4px 12px rgb(0 0 0/0.08); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--slate-100); }
.card-title { font-family: var(--font-body); font-size: 0.9375rem; font-weight: 600; color: var(--slate-900); }

/* ====== STATS GRID ====== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: white; border-radius: var(--radius); border: 1px solid var(--slate-200); padding: 1.25rem; box-shadow: var(--shadow-card); }
.stat-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 0.75rem; }
.stat-value { font-size: 1.75rem; font-weight: 600; color: var(--slate-900); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--slate-500); margin-top: 0.25rem; }

/* ====== BUTTONS ====== */
.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; transition: all 0.15s; cursor: pointer; }
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-light); }
.btn-lime { background: var(--lime); color: var(--navy); }
.btn-lime:hover { background: var(--lime-dark); }
.btn-secondary { background: white; color: var(--slate-700); border: 1px solid var(--slate-200); }
.btn-secondary:hover { background: var(--slate-50); border-color: var(--slate-300); }
.btn-danger { background: var(--red-600); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: rgba(255,255,255,0.5); transition: all 0.15s; }
.btn-icon:hover { background: rgba(255,255,255,0.1); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ====== FORMS ====== */
.input { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--slate-200); border-radius: var(--radius); font-size: 0.875rem; color: var(--slate-900); background: white; transition: border-color 0.15s, box-shadow 0.15s; }
.input:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(7,56,73,0.08); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.375rem; }
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ====== TAGS ====== */
.tag { display: inline-flex; align-items: center; padding: 0.2rem 0.6rem; border-radius: 9999px; font-size: 0.7rem; font-weight: 600; gap: 0.25rem; white-space: nowrap; }
.tag-improve  { background: #dbeafe; color: #1d4ed8; }
.tag-engage   { background: #d1fae5; color: #065f46; }
.tag-cultivate{ background: #ede9fe; color: #6d28d9; }
.tag-convert  { background: #fce7f3; color: #9d174d; }
.tag-promote  { background: #fed7aa; color: #9a3412; }
.tag-measure  { background: #e0e7ff; color: #3730a3; }
.tag-popular  { background: #fee2e2; color: #b91c1c; }
.tag-new      { background: var(--navy); color: var(--lime); }
.tags-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* ====== TABLE ====== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { text-align: left; padding: 0.625rem 1rem; font-size: 0.75rem; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--slate-100); background: var(--slate-50); white-space: nowrap; }
td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--slate-50); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--slate-50)/50; }

/* ====== STAR RATING ====== */
.star-rating { display: inline-flex; gap: 2px; align-items: center; }
.star { width: 18px; height: 18px; cursor: pointer; position: relative; }
.star svg { width: 18px; height: 18px; }
.star-val { font-size: 0.8125rem; color: var(--slate-500); margin-left: 4px; }
.star-rating.readonly .star { cursor: default; }

/* ====== MATCH STATUS ====== */
.status-chip { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.625rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.status-unmatched   { background: var(--amber-100); color: var(--amber-600); }
.status-auto_matched{ background: var(--blue-100); color: var(--blue-600); }
.status-confirmed   { background: #d1fae5; color: #065f46; }
.status-rejected    { background: #fee2e2; color: var(--red-600); }

/* ====== MODAL ====== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal { background: white; border-radius: var(--radius-lg); box-shadow: 0 20px 60px rgb(0 0 0/0.2); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--slate-100); }
.modal-header h3 { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.5rem; }
.modal-footer { display: flex; gap: 0.75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--slate-100); }
.modal-close { position: absolute; top: 1rem; right: 1rem; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--slate-400); font-size: 1.25rem; line-height: 1; }
.modal-close:hover { background: var(--slate-100); color: var(--slate-700); }

/* ====== TOAST ====== */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { padding: 0.75rem 1.25rem; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; box-shadow: 0 4px 16px rgb(0 0 0/0.15); animation: slideIn 0.2s ease; display: flex; align-items: center; gap: 0.5rem; min-width: 240px; }
.toast-success { background: #052a37; color: white; }
.toast-error { background: var(--red-600); color: white; }
.toast-info { background: var(--slate-800); color: white; }
@keyframes slideIn { from { opacity:0; transform: translateX(1rem); } to { opacity:1; transform: translateX(0); } }

/* ====== BADGE ====== */
.badge { background: var(--red-600); color: white; font-size: 0.65rem; font-weight: 700; padding: 0.1rem 0.4rem; border-radius: 9999px; min-width: 18px; text-align: center; }

/* ====== TABS ====== */
.tabs { display: flex; gap: 2px; background: var(--slate-100); border-radius: 10px; padding: 3px; margin-bottom: 1.5rem; width: fit-content; }
.tab { padding: 0.5rem 1rem; border-radius: 8px; font-size: 0.875rem; font-weight: 500; color: var(--slate-500); transition: all 0.15s; cursor: pointer; }
.tab.active { background: white; color: var(--slate-900); box-shadow: var(--shadow-card); }

/* ====== FILTER BAR ====== */
.filter-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; }
.filter-group .label { margin-bottom: 0.25rem; }
.filter-group .input { min-width: 160px; }

/* ====== PROGRESS BAR ====== */
.progress-bar { background: var(--slate-100); border-radius: 9999px; height: 6px; overflow: hidden; }
.progress-fill { background: var(--navy); height: 100%; border-radius: 9999px; transition: width 0.3s; }

/* ====== EMPTY STATE ====== */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4rem 2rem; text-align: center; }
.empty-state svg { color: var(--slate-300); margin-bottom: 1rem; }
.empty-state p { color: var(--slate-500); font-size: 0.9375rem; }

/* ====== SYNC BAR ====== */
.sync-bar { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: var(--blue-50); border: 1px solid var(--blue-100); border-radius: var(--radius); margin-bottom: 1.25rem; font-size: 0.875rem; color: var(--blue-600); }

/* ====== SPINNER ====== */
.spinner { width: 20px; height: 20px; border: 2px solid var(--slate-200); border-top-color: var(--navy); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== MISC ====== */
.text-muted { color: var(--slate-400); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
