/* Katch Leads — Navy Green Theme */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg: #0A1628;
  --surface: #1e293b;
  --surface2: #1e293b;
  --border: rgba(16,185,129,0.2);
  --shadow: rgba(0,0,0,0.4);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-xmuted: #64748b;
  --primary: #10B981;
  --primary-hover: #0EA573;
  --primary-dim: rgba(16,185,129,0.12);
  --success: #10B981;
  --success-bg: rgba(16,185,129,0.1);
  --warning: #F59E0B;
  --warning-bg: rgba(245,158,11,0.1);
  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── Layout ─────────────────────────────────────── */
.app-container { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ─────────────────────────────────────── */
.app-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 100;
}
.app-header .badge {
  background: var(--primary); color: var(--bg); font-weight: 700;
  font-size: 11px; padding: 4px 12px; border-radius: 20px;
  letter-spacing: 0.5px; white-space: nowrap;
}
.app-header .company-name { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.app-header .user-info {
  margin-left: auto; color: var(--text-xmuted); font-size: 12px;
  display: flex; align-items: center; gap: 12px;
}
.btn-logout {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  padding: 5px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12px; transition: all 0.15s;
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ── Tab Bar ────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 2px; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky; top: 44px; z-index: 99;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-link {
  padding: 10px 16px; font-size: 12px; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  white-space: nowrap; cursor: pointer; transition: all 0.15s;
  text-decoration: none; display: block;
  flex-shrink: 0;
}
.tab-link:hover { color: var(--primary); background: var(--primary-dim); }
.tab-link.active {
  color: var(--primary); border-bottom-color: var(--primary);
  background: var(--primary-dim); font-weight: 600;
}

/* ── Content ────────────────────────────────────── */
.tab-content { padding: 24px; flex: 1; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px var(--shadow);
  overflow-x: auto;
}
.card-header {
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px;
}

/* ── Metrics ────────────────────────────────────── */
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  box-shadow: 0 1px 3px var(--shadow); transition: box-shadow 0.2s;
}
.metric-card:hover { box-shadow: 0 4px 16px var(--shadow); }
.metric-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 4px;
}
.metric-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.metric-delta { font-size: 12px; font-weight: 500; margin-top: 2px; }
.metric-delta.positive { color: var(--success); }
.metric-delta.negative { color: var(--danger); }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.15s; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  text-decoration: none;
}
.btn:hover { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.btn-primary {
  background: var(--primary); color: var(--bg); border-color: var(--primary); font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover); border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(16,185,129,0.35); color: var(--bg);
}
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { border-color: var(--success); color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 14px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; min-height: 44px; font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.form-textarea { min-height: 80px; resize: vertical; }
.form-select { cursor: pointer; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* ── Tables ─────────────────────────────────────── */
.data-table-wrapper {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 0 -4px; padding: 0 4px;
}
.data-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 600px;
}
.data-table thead { background: var(--bg); }
.data-table th {
  padding: 12px 14px; text-align: left; font-weight: 700;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--primary); border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--text); vertical-align: middle;
}
.data-table tr:hover td { background: rgba(16,185,129,0.04); }
.data-table .editable {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; width: 100%;
  border-radius: 6px; font-size: 14px; min-height: 40px;
}
.data-table .editable:focus {
  border-color: var(--primary); background: var(--bg-secondary);
  outline: none; box-shadow: 0 0 0 3px var(--primary-dim);
}

/* ── Alerts ─────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px;
  font-size: 13px; font-weight: 500; border-left: 4px solid;
}
.alert-success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.alert-info { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); }

/* ── Toast (auto-dismiss) ───────────────────────── */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px var(--shadow);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}
.toast-success { background: #065f46; color: #6ee7b7; }
.toast-error { background: #7f1d1d; color: #fca5a5; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

/* ── Section Headers ────────────────────────────── */
.section-header {
  font-size: 20px; font-weight: 700; margin-bottom: 16px;
  display: flex; align-items: center; gap: 10px;
}

/* ── Two Column Layout ──────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Cart ───────────────────────────────────────── */
.cart-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cart-item-name { font-weight: 500; }
.cart-item-qty { color: var(--text-muted); font-size: 12px; }
.cart-item-price { font-weight: 600; color: var(--primary); }
.cart-total {
  margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--primary);
  display: flex; justify-content: space-between;
  font-size: 16px; font-weight: 700;
}

/* ── KDS Cards ──────────────────────────────────── */
.kds-card {
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px;
  border: 1px solid var(--border); border-left: 4px solid;
}
.kds-pending { background: var(--warning-bg); border-left-color: var(--warning); }
.kds-in_progress { background: var(--primary-dim); border-left-color: var(--primary); }
.kds-done { background: var(--success-bg); border-left-color: var(--success); opacity: 0.7; }

/* ── Badge ──────────────────────────────────────── */
.badge-sm {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-unpaid { background: var(--danger-bg); color: var(--danger); }
.badge-overdue { background: var(--warning-bg); color: var(--warning); }
.badge-trial { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-open { background: var(--primary-dim); color: var(--primary); }
.badge-received { background: var(--success-bg); color: var(--success); }

/* ── Trust Cards ────────────────────────────────── */
.trust-card {
  background: var(--surface); padding: 22px; border-radius: var(--radius);
  box-shadow: 0 1px 3px var(--shadow); margin-bottom: 14px;
  border: 1px solid var(--border);
}

/* ── Sub Tabs (within a tab) ────────────────────── */
.sub-tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; white-space: nowrap; }
.sub-tab {
  padding: 8px 16px; font-size: 12px; font-weight: 500; flex-shrink: 0; white-space: nowrap;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.15s;
}
.sub-tab:hover { color: var(--primary); }
.sub-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-content { display: none; }
.sub-content.active { display: block; }

/* ── Chart Container ────────────────────────────── */
.chart-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}

/* ── Expander/Accordion ─────────────────────────── */
.expander {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden;
}
.expander-header {
  padding: 12px 16px; cursor: pointer; font-weight: 600;
  font-size: 13px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); transition: background 0.15s;
}
.expander-header:hover { background: var(--primary-dim); }
.expander-header .arrow { transition: transform 0.2s; }
.expander.open .expander-header .arrow { transform: rotate(90deg); }
.expander-body { display: none; padding: 16px; background: var(--bg); }
.expander.open .expander-body { display: block; }

/* ── Empty State ────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px; color: var(--text-muted);
  font-size: 14px;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

/* ── Login Page ─────────────────────────────────── */
.login-container {
  display: flex; min-height: 100vh;
}
.login-left {
  flex: 0 0 55%; background: var(--bg); padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-right {
  flex: 1; background: #0f1d32; padding: 60px 48px;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 500px;
}
.login-badge {
  display: inline-block; background: var(--primary); color: var(--bg);
  font-size: 11px; font-weight: 800; letter-spacing: 3px;
  text-transform: uppercase; padding: 6px 14px; margin-bottom: 28px;
}
.login-h1 {
  font-size: clamp(2rem, 3.5vw, 3rem); font-weight: 800;
  line-height: 1.1; margin-bottom: 20px; color: #fff;
}
.login-h1 span { color: var(--primary); }
.login-sub {
  color: var(--text-muted); font-size: 1.05rem; margin-bottom: 36px;
  max-width: 480px; line-height: 1.7;
}
.login-pills { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 44px; }
.login-pill {
  background: var(--primary-dim); border: 1px solid rgba(16,185,129,0.35);
  color: var(--primary); font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 20px;
}
.login-props { display: flex; flex-direction: column; gap: 18px; }
.login-prop { display: flex; align-items: flex-start; gap: 14px; }
.login-prop-icon {
  flex-shrink: 0; width: 36px; height: 36px; background: var(--primary-dim);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-size: 16px;
}
.login-prop-title { color: #fff; font-weight: 700; font-size: 0.95rem; display: block; margin-bottom: 3px; }
.login-prop-text { color: #cbd5e1; font-size: 0.9rem; line-height: 1.5; }

.login-form { max-width: 400px; }
.login-form h3 { margin-bottom: 20px; font-weight: 700; }
.login-error {
  background: var(--danger-bg); border: 1px solid var(--danger);
  color: #fca5a5; padding: 10px 14px; border-radius: var(--radius-sm);
  margin-bottom: 14px; font-size: 13px;
}

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Mobile ─────────────────────────────────────── */
@media (max-width: 768px) {
  .login-container { flex-direction: column; }
  .login-left { padding: 40px 24px; flex: none; }
  .login-right { padding: 40px 24px; max-width: 100%; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: repeat(2, 1fr); }
  .tab-content { padding: 16px; }
  .app-header { padding: 8px 16px; }
  .btn { min-height: 44px; font-size: 15px; }
  input, select, textarea { font-size: 16px !important; }
  .form-row { grid-template-columns: 1fr !important; }
  .form-input, .form-select, .form-textarea,
  input, select, textarea {
    padding: 14px 16px !important;
    min-height: 48px !important;
    border-radius: 10px !important;
  }
  .form-textarea { min-height: 100px !important; resize: vertical; }
  .form-label { font-size: 14px !important; margin-bottom: 6px !important; }
  .form-group { margin-bottom: 16px; }
  .btn { min-height: 48px; font-size: 16px; padding: 14px 20px; border-radius: 10px; }
  .data-table .editable {
    font-size: 16px !important;
    padding: 12px 14px !important;
    min-height: 48px !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    background: var(--bg) !important;
  }
  .data-table th, .data-table td { padding: 12px 10px; }
  .data-table { font-size: 14px; }
  .card { padding: 14px; overflow-x: auto; }
  .section-header { font-size: 18px; margin-bottom: 16px; }
  .checkbox-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .checkbox-item { padding: 10px 12px; font-size: 14px; }
  .checkbox-item input[type="checkbox"] { width: 20px; height: 20px; }
}

/* ── Checkbox ───────────────────────────────────── */
.checkbox-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.checkbox-item {
  display: flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
}
.checkbox-item:hover { background: var(--primary-dim); }
.checkbox-item input[type="checkbox"] {
  accent-color: var(--primary); width: 16px; height: 16px;
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px; max-width: 500px;
  width: 90%; box-shadow: 0 20px 60px var(--shadow);
}
.modal-header { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

/* ── Utilities ──────────────────────────────────── */
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.fw-700 { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-2 { margin-bottom: 8px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }

/* ── Loading Spinner ────────────────────────────── */
.loading-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn.loading { pointer-events: none; opacity: 0.7; }
.btn.loading::after {
  content: ""; display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.6s linear infinite;
  margin-left: 8px; vertical-align: middle;
}

/* ── Improved Focus Styles (Accessibility) ──────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Skip to content (Accessibility) ────────────── */
.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--primary); color: var(--bg);
  padding: 8px 16px; z-index: 9999; font-weight: 600;
}
.skip-link:focus { top: 0; }

/* ── Mobile Tab Bar Fade Edges ──────────────────── */
@media (max-width: 768px) {
  .tab-bar {
    -webkit-mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
    mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
    padding-left: 20px; padding-right: 20px;
  }
  .tab-link { padding: 10px 14px; font-size: 13px; }
  .modal { width: 95%; max-width: 95%; padding: 20px; }
  .metric-value { font-size: 1.25rem; }
}

/* ── Print Styles ───────────────────────────────── */
@media print {
  .app-header, .tab-bar, .btn-logout { display: none; }
  .tab-content { padding: 0; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ccc; box-shadow: none; }
}
