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

:root {
  --gold:       #C9972E;
  --gold-light: #F5E6C3;
  --gold-dark:  #8B6914;
  --sidebar-bg: #1A1A2E;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #C9972E;
  --bg:         #F7F8FA;
  --card-bg:    #FFFFFF;
  --border:     #E2E8F0;
  --text:       #1E293B;
  --text-muted: #64748B;
  --green:      #16A34A;
  --red:        #DC2626;
  --yellow:     #D97706;
  --radius:     10px;
  --shadow:     0 1px 4px rgba(0,0,0,.07), 0 4px 12px rgba(0,0,0,.04);
}

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

a { color: var(--gold-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-size: 12px; background: #F1F5F9; padding: 2px 6px; border-radius: 4px; font-family: 'Menlo', 'Consolas', monospace; }
pre { background: #F1F5F9; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.6; }
ol.setup-steps { padding-left: 18px; }
ol.setup-steps li { margin: 6px 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.p-4 { padding: 16px; }
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }

/* ===== Login =============================================== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1A1A2E 0%, #16213E 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 36px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo p  { color: var(--text-muted); font-size: 13px; }
.login-hint { text-align: center; margin-top: 20px; font-size: 12px; color: var(--text-muted); }

/* ===== Layout ============================================== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto; z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 16px;
  font-size: 14px; font-weight: 700; color: var(--gold);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo-icon { font-size: 20px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 7px;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px; transition: all .15s;
  cursor: pointer; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--gold); color: #fff; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; }
.sidebar-footer { padding: 12px 8px 20px; border-top: 1px solid rgba(255,255,255,.07); }

.main-content { margin-left: 220px; flex: 1; padding: 28px 32px; max-width: 1280px; }

/* ===== Page header ========================================= */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== Cards =============================================== */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-meta { padding: 10px 20px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); background: #FAFBFC; }

/* ===== Stat grid =========================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 4px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.gold-card { background: linear-gradient(135deg, #FFF8E7, #FFF0C8); border-color: #E8D5A0; }
.silver-card { background: linear-gradient(135deg, #F8F9FA, #ECEFF4); border-color: #D1D9E6; }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-sub a { color: var(--gold-dark); }

/* ===== Tables ============================================== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-bottom: 1px solid var(--border); background: #FAFBFC; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #F9FAFB; }
.table-scroll { overflow-x: auto; }
.td-actions { white-space: nowrap; }
.row-gold td { background: #FFFEF5 !important; }
.row-disabled { opacity: .6; }
.table-footer { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: #FAFBFC; }

/* ===== Products table ======================================= */
.products-table .input-sm { width: 100%; min-width: 60px; max-width: 90px; }
.products-table td { padding: 7px 10px; }
.products-table th { padding: 8px 10px; }
.product-title { font-weight: 600; font-size: 13px; }
.product-variant { font-size: 12px; color: var(--text-muted); }
.product-actions { margin-top: 2px; }
.link-sm { font-size: 11px; color: var(--gold-dark); }
.est-price { font-weight: 700; color: var(--gold-dark); white-space: nowrap; }
.price-breakdown { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===== Forms =============================================== */
.form-body { padding: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-group small { display: block; font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 8px; padding-top: 8px; }

input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 14px; color: var(--text);
  background: #fff; transition: border-color .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,151,46,.15);
}
.input-sm { padding: 5px 7px; font-size: 13px; border-radius: 5px; }
.select-sm { width: auto; padding: 6px 10px; font-size: 13px; }
.btn-full { width: 100%; }

/* ===== Buttons ============================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 7px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; transition: all .15s; text-decoration: none;
  white-space: nowrap; gap: 6px;
}
.btn:hover { background: #F1F5F9; text-decoration: none; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-dark); border-color: var(--gold-dark); color: #fff; }
.btn-danger { background: #FEF2F2; border-color: #FECACA; color: var(--red); }
.btn-danger:hover { background: #FEE2E2; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }

/* ===== Badges ============================================== */
.badge-ok   { display: inline-block; padding: 2px 8px; background: #D1FAE5; color: #065F46; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-warn { display: inline-block; padding: 2px 8px; background: #FEF3C7; color: #92400E; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-muted{ display: inline-block; padding: 2px 8px; background: #F1F5F9; color: var(--text-muted); border-radius: 20px; font-size: 12px; }

/* ===== Alerts ============================================== */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-ok, .alert-info { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warn { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* ===== Help box ============================================ */
.help-box { background: #F8FAFC; border: 1px solid var(--border); border-left: 3px solid var(--gold); border-radius: 6px; padding: 12px 14px; font-size: 13px; line-height: 1.7; }
.help-text { font-size: 12px; color: var(--text-muted); }

/* ===== Toggle switch ======================================== */
.toggle { display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { display: none; }
.toggle-slider { width: 36px; height: 20px; background: #CBD5E1; border-radius: 10px; position: relative; transition: background .2s; }
.toggle-slider::after { content: ''; position: absolute; width: 14px; height: 14px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-slider { background: var(--gold); }
.toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

/* ===== Empty state ========================================= */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); margin-bottom: 20px; }

/* ===== Two-col grid ========================================= */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ===== Calculator =========================================== */
.calculator {}
.calc-result { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.calc-row { display: flex; justify-content: space-between; padding: 9px 16px; border-bottom: 1px solid var(--border); }
.calc-row:last-child { border-bottom: none; }
.calc-row.final { background: var(--gold-light); font-weight: 700; font-size: 16px; color: var(--gold-dark); }

/* ===== Derived rates ======================================== */
.derived-rates { background: var(--gold-light); border-radius: 7px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }

/* ===== Code block =========================================== */
.code-block { max-height: 300px; overflow-y: auto; border-radius: 8px; border: 1px solid var(--border); }
.code-block pre { margin: 0; border-radius: 0; }

/* ===== Responsive =========================================== */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav { display: flex; flex-wrap: wrap; padding: 8px; }
  .nav-item { padding: 6px 10px; font-size: 12px; }
  .main-content { margin-left: 0; padding: 16px; }
  .two-col-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
