/* style.css — Wholesale Sales Tracker */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0ede6;
  --border: #d8d4ca;
  --border2: #c4bfb4;
  --text: #1a1916;
  --text2: #5a5750;
  --text3: #8a8680;
  --accent: #1a1916;
  --green: #1a6640;
  --green-bg: #e6f4ec;
  --green-text: #0f4d2e;
  --amber: #92580a;
  --amber-bg: #fef3e0;
  --amber-text: #7a4408;
  --red: #8b1c1c;
  --red-bg: #fdeaea;
  --red-text: #6b1414;
  --blue: #1a4a8a;
  --blue-bg: #e8f0fb;
  --blue-text: #143a70;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 1.5rem;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  font-size: 13px;
}
.nav-brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-weight: 500; font-size: 13px;
  color: #fff; margin-right: 2rem; white-space: nowrap;
}
.nav-logo { color: #e8a020; font-size: 12px; }
.nav-links { display: flex; gap: 0; flex: 1; }
.nav-links a {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  padding: 0 14px;
  height: 52px;
  display: flex;
  align-items: center;
  font-weight: 500;
  transition: color .15s, background .15s;
  font-size: 13px;
}
.nav-links a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-links a.active { color: #fff; border-bottom: 2px solid #e8a020; }
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-role { font-family: var(--mono); font-size: 11px; padding: 3px 8px; border-radius: var(--radius); background: rgba(255,255,255,.12); color: rgba(255,255,255,.8); }
.user-role.admin { background: rgba(232,160,32,.2); color: #f0c060; }
.user-name { color: rgba(255,255,255,.8); font-size: 13px; }
.btn-logout { color: rgba(255,255,255,.5); text-decoration: none; font-size: 12px; padding: 4px 10px; border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius); transition: all .15s; }
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Layout ─────────────────────────────────────────── */
.main-content { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 600; }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-body { padding: 1.25rem; }
.card-header { padding: .875rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.card-title { font-weight: 600; font-size: 14px; }

/* ── Metrics Grid ───────────────────────────────────── */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.metric-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.25rem; box-shadow: var(--shadow); }
.metric-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: .06em; font-weight: 500; margin-bottom: 6px; }
.metric-value { font-size: 22px; font-weight: 600; font-family: var(--mono); line-height: 1.2; }
.metric-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.metric-value.success { color: var(--green); }
.metric-value.warning { color: var(--amber); }
.metric-value.danger  { color: var(--red); }

/* ── Tables ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13px; }
thead th { background: var(--surface2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf9f7; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; }
.badge-success { background: var(--green-bg); color: var(--green-text); }
.badge-warning { background: var(--amber-bg); color: var(--amber-text); }
.badge-danger  { background: var(--red-bg);   color: var(--red-text); }
.badge-info    { background: var(--blue-bg);  color: var(--blue-text); }
.badge-secondary { background: var(--surface2); color: var(--text2); }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; font-size: 13px; font-weight: 500; border-radius: var(--radius); cursor: pointer; text-decoration: none; border: 1px solid var(--border2); background: var(--surface); color: var(--text); transition: all .15s; white-space: nowrap; font-family: var(--sans); }
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn-primary:hover { background: #333; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: var(--green-text); }
.btn-warning { background: var(--amber); color: #fff; border-color: var(--amber); }
.btn-warning:hover { background: var(--amber-text); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-ghost { background: none; border-color: transparent; }
.btn-ghost:hover { background: var(--surface2); border-color: var(--border); }

/* ── Forms ──────────────────────────────────────────── */
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text2); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--sans);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--text2); box-shadow: 0 0 0 3px rgba(0,0,0,.06); }
.form-group textarea { resize: vertical; min-height: 70px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.form-note { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── Flash Messages ─────────────────────────────────── */
.flash { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: 13px; font-weight: 500; }
.flash button { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6; }
.flash-success { background: var(--green-bg); color: var(--green-text); border: 1px solid #b8dfc8; }
.flash-error   { background: var(--red-bg);   color: var(--red-text);   border: 1px solid #f0c0c0; }
.flash-info    { background: var(--blue-bg);  color: var(--blue-text);  border: 1px solid #b8cef0; }
.flash-warning { background: var(--amber-bg); color: var(--amber-text); border: 1px solid #f0d898; }

/* ── Modals ─────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,.18); width: 520px; max-width: 96vw; max-height: 90vh; overflow-y: auto; }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-weight: 600; font-size: 15px; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 22px; color: var(--text3); line-height: 1; padding: 2px; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .875rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Progress bar ───────────────────────────────────── */
.progress { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.progress-bar { height: 100%; background: var(--green); border-radius: 3px; }

/* ── Filter row ─────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { min-width: 0; }
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar select { min-width: 150px; }

/* ── Tabs ───────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab-link { padding: 10px 18px; font-size: 13px; font-weight: 500; color: var(--text2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab-link:hover { color: var(--text); }
.tab-link.active { color: var(--text); border-bottom-color: var(--text); }

/* ── Info box ───────────────────────────────────────── */
.info-box { background: var(--blue-bg); border: 1px solid #b8cef0; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; color: var(--blue-text); margin-bottom: 1rem; }
.warn-box { background: var(--amber-bg); border: 1px solid #f0d898; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; color: var(--amber-text); margin-bottom: 1rem; }
.lock-box { background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 10px 14px; font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 8px; }
.lock-icon { font-size: 16px; }

/* ── Amount display ─────────────────────────────────── */
.amount { font-family: var(--mono); font-size: 13px; }
.amount-paid { color: var(--green); font-family: var(--mono); }
.amount-due  { color: var(--red);   font-family: var(--mono); }
.amount-total { font-family: var(--mono); }

/* ── Timeline ───────────────────────────────────────── */
.timeline { border-left: 2px solid var(--border); padding-left: 1rem; }
.tl-item { position: relative; margin-bottom: .875rem; font-size: 13px; }
.tl-item::before { content: ''; position: absolute; left: -1.375rem; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--border2); border: 2px solid var(--surface); }
.tl-item.tl-success::before { background: var(--green); }
.tl-time { font-size: 11px; color: var(--text3); margin-top: 2px; font-family: var(--mono); }

/* ── Client avatar ──────────────────────────────────── */
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--blue-bg); color: var(--blue-text); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }

/* ── Login page ─────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 2rem; }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo h1 { font-size: 18px; font-weight: 600; margin-top: .5rem; }
.login-logo .logo-icon { font-size: 36px; color: #e8a020; font-family: var(--mono); }

/* ── Footer ─────────────────────────────────────────── */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--text3); flex-wrap: wrap; gap: 8px; margin-top: 2rem; }

/* ── Readonly badge ─────────────────────────────────── */
.readonly-notice { display: inline-flex; align-items: center; gap: 5px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius); padding: 4px 10px; font-size: 11px; color: var(--text2); font-family: var(--mono); }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .modal { width: 98vw; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
}
