/* ============================================================
   Venkat Golds — design system
   Philosophy: trust • clarity • calm
   ============================================================ */

:root {
  --brand:       #8b6914;   /* deep gold — primary */
  --brand-600:   #a87b00;   /* hover */
  --brand-50:    #fdf8ed;   /* subtle tint bg */
  --brand-100:   #faf0d6;
  --brand-200:   #f0dfae;

  --ink:         #1a1a1a;   /* headings */
  --ink-2:       #374151;   /* body */
  --ink-3:       #6b7280;   /* muted */
  --ink-4:       #9ca3af;   /* placeholder */

  --surface:     #ffffff;
  --bg:          #fafaf7;   /* warm off-white */
  --border:      #e5e7eb;
  --border-2:    #d1d5db;

  --red:         #dc2626;
  --red-50:      #fef2f2;
  --green:       #16a34a;
  --green-50:    #f0fdf4;
  --amber:       #d97706;
  --amber-50:    #fffbeb;
  --blue:        #2563eb;

  --shadow-sm:   0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow:      0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.04);
  --shadow-md:   0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg:   0 10px 15px -3px rgb(0 0 0 / 0.06), 0 4px 6px -4px rgb(0 0 0 / 0.04);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
}

/* Base =================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--ink); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); }

/* Layout =================================================== */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 768px) { .app { display: block !important; } .sidebar { display: none !important; } .sidebar.open { display: flex !important; position: fixed; inset: 0 auto 0 0; width: 80vw; max-width: 280px; z-index: 1000; box-shadow: 4px 0 24px rgba(0,0,0,0.18); overflow-y: auto; } }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 99; }
.sidebar-backdrop.open { display: block; }

/* Sidebar ================================================== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 12px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-600) 100%);
  display: grid; place-items: center; color: white; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 600; color: var(--ink); font-size: 15px; }
.brand-sub  { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px;
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--brand-50); color: var(--brand); }
.nav a.active { background: var(--brand-50); color: var(--brand); }
.nav-icon { width: 18px; text-align: center; }
.nav-section { font-size: 11px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.05em; padding: 16px 12px 6px; font-weight: 600; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }

/* Topbar (mobile) ========================================== */
.topbar {
  display: none; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 16px; position: sticky; top: 0; z-index: 20;
}
@media (max-width: 768px) { .topbar { display: flex; } }
.menu-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer;
}

/* Main content ============================================= */
.main { padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }
@media (max-width: 768px) { .main { padding: 16px; } }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.page-sub { color: var(--ink-3); font-size: 14px; margin-top: 2px; }

/* Cards ===================================================== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px; }
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--brand-200); transition: all 0.15s; }

/* KPI ======================================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; } }
.kpi { position: relative; overflow: hidden; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--ink); margin-top: 6px; letter-spacing: -0.02em; }
.kpi-delta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi.red .kpi-value { color: var(--red); }
.kpi.green .kpi-value { color: var(--green); }
.kpi.amber .kpi-value { color: var(--amber); }

/* Tables ==================================================== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fafafa; }
tbody td { padding: 14px 16px; font-size: 14px; color: var(--ink-2); border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--brand-50); cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
.td-strong { font-weight: 600; color: var(--ink); }
.td-num { font-variant-numeric: tabular-nums; }

/* Badges ==================================================== */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.badge-green { background: var(--green-50); color: var(--green); }
.badge-red { background: var(--red-50); color: var(--red); }
.badge-amber { background: var(--amber-50); color: var(--amber); }
.badge-gray { background: #f3f4f6; color: var(--ink-3); }

/* Buttons =================================================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: all 0.15s; min-height: 40px; text-decoration: none; }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-600); color: white; }
.btn-secondary { background: var(--surface); color: var(--ink-2); border-color: var(--border-2); }
.btn-secondary:hover { background: #f9fafb; }
.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; color: white; }
.btn-green { background: #25D366; color: white; border-color: #25D366; }
.btn-green:hover { filter: brightness(0.95); color: white; }
.btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }
.btn-block { width: 100%; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* File input as styled button ================================ */
.file-btn { position: relative; display: block; cursor: pointer; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-btn-inner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 16px; border: 2px dashed var(--border-2); border-radius: var(--r);
  background: #fafafa; color: var(--ink-2); font-weight: 600; font-size: 14px;
  transition: all 0.15s; text-align: center;
}
.file-btn:hover .file-btn-inner { border-color: var(--brand); color: var(--brand); background: var(--brand-50); }
.file-btn.has-file .file-btn-inner { border-style: solid; border-color: var(--green); background: var(--green-50); color: var(--green); }
.file-btn-icon { font-size: 20px; }
.file-btn-hint { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }

/* Forms ===================================================== */
.label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-2); border-radius: var(--r-sm); font-size: 14px; color: var(--ink); background: var(--surface); min-height: 42px; font-family: inherit; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.input::placeholder { color: var(--ink-4); }
textarea.input { min-height: auto; resize: vertical; }

/* Login ===================================================== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }
.auth-hero { background: linear-gradient(135deg, var(--brand) 0%, #6b4e0f 100%); color: white; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 700; }
.auth-hero-brand-mark { width: 44px; height: 44px; border-radius: 10px; background: rgba(255,255,255,0.15); display: grid; place-items: center; backdrop-filter: blur(10px); }
.auth-hero-title { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; color: white; margin-top: auto; }
.auth-hero-sub { font-size: 15px; color: rgba(255,255,255,0.85); margin-top: 12px; max-width: 420px; line-height: 1.6; }
.auth-hero-trust { display: flex; gap: 24px; margin-top: 32px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.2); font-size: 12px; color: rgba(255,255,255,0.8); }
.auth-hero-trust div { display: flex; align-items: center; gap: 6px; }

.auth-form { display: flex; align-items: center; justify-content: center; padding: 48px 32px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-title { font-size: 1.75rem; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.auth-sub { color: var(--ink-3); font-size: 14px; margin-top: 6px; margin-bottom: 28px; }

/* Alerts ==================================================== */
.alert { padding: 12px 14px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 12px; border: 1px solid transparent; }
.alert-success { background: var(--green-50); border-color: #bbf7d0; color: #15803d; }
.alert-error   { background: var(--red-50); border-color: #fecaca; color: #b91c1c; }

/* Toasts (bottom-right, auto-dismiss) ========================= */
.toast-stack { position: fixed; bottom: 20px; right: 20px; left: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
@media (max-width: 640px) { .toast-stack { bottom: 14px; left: 14px; right: 14px; align-items: stretch; } }
.toast { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: var(--r); background: white; box-shadow: 0 10px 25px rgba(0,0,0,0.15); border-left: 4px solid var(--green); min-width: 280px; max-width: 500px; font-size: 14px; font-weight: 500; color: var(--ink); pointer-events: auto; animation: toast-in 0.25s ease-out; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: white; flex-shrink: 0; }
.toast-success .toast-icon { background: var(--green); }
.toast-error .toast-icon { background: var(--red); }
.toast-close { margin-left: auto; background: none; border: 0; font-size: 20px; color: var(--ink-3); cursor: pointer; padding: 0 4px; line-height: 1; }
.toast-out { opacity: 0; transform: translateX(20px); transition: all 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* Utilities ================================================= */
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-col { flex-direction: column; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .grid-2 { grid-template-columns: 1fr; } .kpi-value { font-size: 1.5rem; } .page-title { font-size: 1.5rem; } }
@media (max-width: 540px) { .main { padding: 12px; } table thead th, table tbody td { padding: 10px 10px; font-size: 13px; } }
/* Prevent horizontal scroll from wide tables on phone */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.space-y-3 > * + * { margin-top: 12px; }
.space-y-4 > * + * { margin-top: 16px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search-input { background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%239ca3af'%3E%3Cpath fill-rule='evenodd' d='M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z' clip-rule='evenodd'/%3E%3C/svg%3E") no-repeat 12px center / 16px; padding-left: 36px; }
