/* ============================================
   SureTariff Portal — Stylesheet
   Clean semantic CSS. No build step.
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1a1a2e;
  background: #f8fafb;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; display: block; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- CSS Variables (Design Tokens) --- */
:root {
  --primary: #0D9488;
  --primary-light: #14b8a6;
  --primary-dark: #0f766e;
  --primary-bg: #f0fdfa;
  --secondary: #5c588e;
  --accent: #e8b931;
  --navy: #0d1c2f;
  --navy-light: #1a2d45;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;

  --text: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --bg: #f8fafb;
  --bg-card: #ffffff;
  --bg-muted: #f1f5f9;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

  --font-heading: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono: 'Courier New', monospace;

  --nav-height: 64px;
}

/* --- Typography --- */
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; color: var(--text); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Layout --- */
.page-wrapper {
  padding-top: var(--nav-height);
  min-height: 100vh;
}
.page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.page-header h1 { margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 0.875rem; }

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3-1 { grid-template-columns: 2fr 1fr; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }
.hidden { display: none !important; }
.w-full { width: 100%; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-container { padding: 16px; }
  .hide-mobile { display: none !important; }
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}
.nav-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo { height: 28px; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 32px;
}
.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-muted); }
.nav-link.active { color: var(--primary); background: var(--primary-bg); }
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.875rem;
  width: 220px;
}
.nav-search input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  color: var(--text);
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
}
.nav-user:hover { background: var(--bg-muted); }
.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}
.nav-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 4px;
  display: none;
  z-index: 200;
}
.nav-dropdown.open { display: block; }
.nav-dropdown a, .nav-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  font-size: 0.875rem;
  color: var(--text);
  border-radius: 6px;
}
.nav-dropdown a:hover, .nav-dropdown button:hover { background: var(--bg-muted); }
.nav-dropdown .divider { height: 1px; background: var(--border); margin: 4px 0; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 20px 24px 0;
}
.card-header h3 { margin-bottom: 4px; }
.card-header p { color: var(--text-secondary); font-size: 0.875rem; }
.card-body { padding: 20px 24px 24px; }
.card-header + .card-body { padding-top: 16px; }

.card-glass {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(13, 148, 136, 0.15);
}

/* --- KPI Cards --- */
.kpi-card {
  padding: 20px 24px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
}
.kpi-card .kpi-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.kpi-card .kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}
.kpi-card .kpi-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-heading);
  line-height: 1.1;
}
.kpi-card .kpi-trend {
  font-size: 0.75rem;
  margin-top: 8px;
  color: var(--success);
}
.kpi-success { border-left: 3px solid var(--success); }
.kpi-success .kpi-value { color: var(--success); }
.kpi-success .kpi-icon { background: var(--success-bg); color: var(--success); }
.kpi-warning { border-left: 3px solid var(--warning); }
.kpi-warning .kpi-value { color: var(--warning); }
.kpi-warning .kpi-icon { background: var(--warning-bg); color: var(--warning); }
.kpi-primary .kpi-icon { background: var(--primary-bg); color: var(--primary); }

/* --- Welcome Banner --- */
.welcome-banner {
  padding: 28px 32px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(13, 148, 136, 0.15);
  margin-bottom: 24px;
}
.welcome-banner h1 { font-size: 1.6rem; margin-bottom: 4px; }
.welcome-banner .org-name { color: var(--text-secondary); font-size: 0.9rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
}
.btn-gradient:hover { opacity: 0.9; }
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-muted); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 6px 8px;
}
.btn-ghost:hover { background: var(--bg-muted); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: none; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-muted); color: var(--text); }

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--bg-muted); color: var(--text-secondary); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-owner { background: #fef3c7; color: #92400e; }
.badge-admin { background: var(--info-bg); color: var(--info); }
.badge-member { background: var(--bg-muted); color: var(--text-secondary); }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
tr:hover td { background: var(--bg-muted); }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.form-input::placeholder { color: var(--text-muted); }
.form-select {
  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='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Progress Bar --- */
.progress-bar {
  height: 8px;
  background: var(--bg-muted);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

/* --- Confidence Colors --- */
.confidence-high { color: var(--success); }
.confidence-medium { color: var(--warning); }
.confidence-low { color: var(--danger); }

/* --- Code Block --- */
.code-block {
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.6;
  position: relative;
}
.code-block .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
}

/* --- Loading & Empty States --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-state .icon { font-size: 2rem; margin-bottom: 12px; }

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  max-width: 360px;
  animation: slideIn 0.2s ease-out;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* --- Login Page --- */
.login-page { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-brand {
  background: var(--navy);
  color: white;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-brand h1 { font-size: 2.2rem; margin-bottom: 12px; color: white; }
.login-brand p { color: rgba(255,255,255,0.7); font-size: 1rem; margin-bottom: 32px; }
.login-brand .step { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.login-brand .step-num {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(13,148,136,0.2); color: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.login-brand .step-text { color: rgba(255,255,255,0.9); font-size: 0.9rem; }
.login-form-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.login-form { width: 100%; max-width: 400px; }
.login-form h2 { font-size: 1.5rem; margin-bottom: 8px; }
.login-form .subtitle { color: var(--text-secondary); margin-bottom: 24px; }
.password-wrapper { position: relative; }
.password-toggle {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer;
}

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

/* --- Upload Zone --- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-bg);
}
.upload-zone .icon { font-size: 2.5rem; color: var(--primary); margin-bottom: 12px; }

/* --- Modal / Dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 480px;
  padding: 24px;
}
.modal h3 { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* --- Radio Group --- */
.radio-group { display: flex; flex-direction: column; gap: 12px; }
.radio-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color 0.15s;
}
.radio-option:hover { border-color: var(--primary); }
.radio-option.selected { border-color: var(--primary); background: var(--primary-bg); }
.radio-option input { margin-top: 3px; accent-color: var(--primary); }

/* --- Chart Container --- */
.chart-container { position: relative; height: 300px; margin-top: 16px; }
.period-btns { display: flex; gap: 4px; }
.period-btn {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.75rem; font-weight: 600; background: transparent;
  color: var(--text-secondary); cursor: pointer;
}
.period-btn.active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }

/* --- Classification Detail --- */
.detail-header {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 20px; background: var(--bg-muted); border-radius: var(--radius); margin-bottom: 12px;
}
.detail-header-6 { grid-template-columns: repeat(6, 1fr); }
.detail-header .label { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 4px; }
.detail-header .value { font-size: 0.95rem; font-weight: 600; }

/* --- Expandable Product Rows --- */
.product-row { cursor: pointer; transition: background 0.1s; }
.product-row:hover td { background: var(--primary-bg); }
.product-row .expand-arrow { display: inline-block; transition: transform 0.2s; margin-right: 6px; font-size: 0.7rem; color: var(--text-muted); }
.product-row.expanded .expand-arrow { transform: rotate(90deg); }
.product-detail { display: none; }
.product-detail.open { display: table-row; }
.product-detail td { padding: 0; border-bottom: 2px solid var(--primary); }
.product-detail-inner {
  padding: 20px 24px;
  background: var(--bg-muted);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.product-detail-inner h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 12px; }
.detail-field { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.detail-field .field-label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.detail-field .field-value { font-size: 0.8rem; font-weight: 500; text-align: right; max-width: 60%; }
.reasoning-text { font-size: 0.85rem; line-height: 1.6; color: var(--text); white-space: pre-wrap; }
.path-step { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 0.8rem; }
.path-step .step-level { font-weight: 600; color: var(--primary); min-width: 70px; }
.path-step .step-arrow { color: var(--text-muted); }

/* Clickable alternative code cards */
.alt-code-card:hover { border-color: var(--primary) !important; background: var(--primary-bg) !important; }

/* --- Notification Dot (removed — bell icon removed from nav) --- */
/* .notification-dot removed */
.notification-dot-unused::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

/* --- Pagination --- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 24px;
}
.pagination button {
  width: 32px; height: 32px; border: 1px solid var(--border);
  border-radius: 6px; background: transparent; font-size: 0.8rem;
  color: var(--text-secondary); cursor: pointer;
}
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:hover:not(.active) { background: var(--bg-muted); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* --- Settings Nav --- */
.settings-nav {
  display: flex; gap: 4px; margin-bottom: 24px;
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.settings-nav a {
  padding: 8px 16px; font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary); border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.settings-nav a:hover { color: var(--text); }
.settings-nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
