/* ============================================================
   Assure Build — Main stylesheet (production v2)
   Refined from the original app.css with new brand (forest green)
   and tightened hierarchy. Drop-in replacement for assets/css/app.css
   ============================================================ */

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

:root {
  /* Surfaces */
  --bg:          #f7f6f2;
  --bg2:         #efece4;
  --bg3:         #e6e3d8;
  --surface:     #ffffff;

  /* Ink */
  --ink:         #1a1916;
  --ink2:        #3a3934;
  --muted:       #6a6860;
  --dim:         #9c9a94;
  --border:      #e8e4d8;
  --border2:     #d6d1c4;

  /* Brand — forest green from the hex brick logo */
  --brand:       #1d5b3d;
  --brand-2:     #164a31;
  --brand-bg:    #eef6f1;
  --brand-light: #9cc6b0;

  /* Supporting palette (softened from v1) */
  --accent:      #1d5b3d;
  --accent-bg:   #eef6f1;

  --orange:      #c45f08;  --orange-bg:   #fff5ec;  --orange-light:#f5d4a8;
  --teal:        #0d7a5f;  --teal-bg:     #edf8f4;  --teal-light:  #8ed8c4;
  --blue:        #1a5fa8;  --blue-bg:     #eef5fc;  --blue-light:  #94c4f0;
  --red:         #b82c2c;  --red-bg:      #fdf0f0;  --red-light:   #f0a8a8;
  --green:       #237a42;  --green-bg:    #eef8f2;  --green-light: #8ed4a8;
  --gold:        #8a6a08;  --gold-bg:     #fdf8e8;  --gold-light:  #e0c868;
  --violet:      #5a38a0;  --violet-bg:   #f3f0fc;  --violet-light:#c0a8e8;

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

html { font-size: 14px; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

img, svg { display: block; max-width: 100%; }

/* ── TYPOGRAPHY ─────────────────────────────────────────── */
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; }
h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
h3 { font-size: 16px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 600; }

.mono        { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-feature-settings: 'tnum'; }
.text-muted  { color: var(--muted); }
.text-dim    { color: var(--dim); }
.text-brand  { color: var(--brand); }
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.text-blue   { color: var(--blue); }
.text-orange { color: var(--orange); }

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.app-topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.app-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.app-main {
  background: var(--bg);
  padding: 22px 28px 40px;
  overflow-y: auto;
}

/* ── TOPBAR ELEMENTS ────────────────────────────────────── */
.topbar-logo { display: flex; align-items: center; gap: 10px; width: 220px; }
.topbar-logo img, .topbar-logo svg { width: 30px; height: 30px; flex-shrink: 0; }
.topbar-logo .brand-name { font-size: 14px; font-weight: 800; color: var(--ink); letter-spacing: -0.2px; line-height: 1.1; }
.topbar-logo .brand-name .thin { font-weight: 500; }
.topbar-logo .brand-sub  { font-size: 10px; color: var(--dim); font-weight: 500; }

.topbar-search {
  flex: 1;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dim);
  font-size: 12px;
}
.topbar-search .kbd {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid; place-items: center;
  color: var(--muted);
  position: relative;
  cursor: pointer;
  font-size: 14px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--border2); }

.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; background: var(--brand);
  border-radius: 50%; border: 2px solid var(--surface);
}

.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px; border-radius: 8px;
  cursor: pointer;
}
.topbar-user:hover { background: var(--bg); }

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 11px; font-family: 'JetBrains Mono', monospace;
}
.user-name-small { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.user-role-small { font-size: 10px; color: var(--muted); }

/* ── SIDEBAR NAVIGATION ─────────────────────────────────── */
.nav-group { margin-bottom: 14px; }

.nav-group-label {
  padding: 6px 10px;
  font-size: 10px;
  color: var(--dim);
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--brand-bg); color: var(--ink); font-weight: 600; }
.nav-item .nav-icon { width: 18px; display: grid; place-items: center; font-size: 14px; color: var(--muted); flex-shrink: 0; }
.nav-item.active .nav-icon { color: var(--brand); }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: #fff;
}
.nav-badge-brand  { background: var(--brand); }
.nav-badge-red    { background: var(--red); }
.nav-badge-orange { background: var(--orange); }

/* ── PAGE HEADER ────────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px; gap: 20px;
}
.page-head .crumb { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.6px; }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; letter-spacing: -0.1px; color: var(--ink); }
.card-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.card-body  { padding: 18px; }

/* ── KPI CARDS (refined) ───────────────────────────────── */
.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.kpi-value {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-feature-settings: 'tnum';
  font-size: 32px; font-weight: 700;
  letter-spacing: -1px; line-height: 1;
  color: var(--ink);
}
.kpi-value.val-brand { color: var(--brand); }
.kpi-value.val-red   { color: var(--red); }
.kpi-value.val-orange{ color: var(--orange); }
.kpi-value.val-muted { color: var(--muted); }
.kpi-delta {
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.kpi-delta-pos { color: var(--green); background: var(--green-bg); }
.kpi-delta-neg { color: var(--brand); background: var(--brand-bg); }
.kpi-delta-neu { color: var(--muted); background: var(--bg2); }
.kpi-foot { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.kpi-foot a { color: var(--brand); font-weight: 600; }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer; font-family: inherit;
  transition: filter 0.15s, background 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(0.95); text-decoration: none; }
.btn-primary { background: var(--ink);   color: var(--surface); border-color: var(--ink); }
.btn-brand   { background: var(--brand); color: #fff;           border-color: var(--brand); }
.btn-green   { background: var(--green); color: #fff;           border-color: var(--green); }
.btn-red     { background: var(--red);   color: #fff;           border-color: var(--red); }
.btn-ghost   { background: var(--surface); color: var(--ink2); border-color: var(--border2); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 11px 18px; font-size: 13px; }

/* ── STATUS CHIPS (pill style, not mono-caps) ───────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.chip-active,  .chip-approved { background: var(--green-bg);  color: var(--green); }
.chip-planning,.chip-submitted{ background: var(--brand-bg);  color: var(--brand); }
.chip-pending, .chip-open     { background: var(--gold-bg);   color: var(--gold); }
.chip-overdue, .chip-rejected { background: var(--red-bg);    color: var(--red); }
.chip-closed,  .chip-hold     { background: var(--bg2);       color: var(--muted); }
.chip-info                    { background: var(--blue-bg);   color: var(--blue); }

/* Dotless tag variant for type labels */
.tag {
  display: inline-flex;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
  background: var(--bg2); color: var(--muted);
}

/* ── TABLES ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 9px 18px;
  font-size: 11px;
  color: var(--muted); font-weight: 600;
  letter-spacing: 0.2px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── FORMS ─────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,91,61,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 3px; }
.form-hint  { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── PROGRESS BARS ─────────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 10px; }
.progress-track {
  flex: 1; height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  min-width: 60px;
}
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.8s ease; }
.pf-brand  { background: var(--brand); }
.pf-green  { background: var(--green); }
.pf-orange { background: var(--orange); }
.pf-red    { background: var(--red); }
.pf-blue   { background: var(--blue); }
.pf-teal   { background: var(--teal); }
.progress-label {
  font-size: 11px; color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  width: 34px; text-align: right;
}

/* ── GRID UTILITIES ─────────────────────────────────────── */
.grid-2  { display: grid; grid-template-columns: 1fr 1fr;         gap: 16px; margin-bottom: 16px; }
.grid-3  { display: grid; grid-template-columns: repeat(3,1fr);   gap: 16px; margin-bottom: 16px; }
.grid-4  { display: grid; grid-template-columns: repeat(4,1fr);   gap: 12px; margin-bottom: 20px; }
.grid-32 { display: grid; grid-template-columns: 1.6fr 1fr;       gap: 16px; margin-bottom: 16px; }
.grid-23 { display: grid; grid-template-columns: 1fr 1.6fr;       gap: 16px; margin-bottom: 16px; }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
}
.alert-brand  { background: var(--brand-bg);  color: var(--brand);  border-color: var(--brand-light); }
.alert-red    { background: var(--red-bg);    color: var(--red);    border-color: var(--red-light); }
.alert-orange { background: var(--orange-bg); color: var(--orange); border-color: var(--orange-light); }
.alert-gold   { background: var(--gold-bg);   color: var(--gold);   border-color: var(--gold-light); }

/* ── TOAST ─────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--ink); color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s ease;
  max-width: 360px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red);   }
.toast-info    { border-left: 3px solid var(--brand); }
.toast-warning { border-left: 3px solid var(--orange); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ── MODAL ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(14,14,12,0.45);
  z-index: 400;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 560px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: scale(0.96) translateY(8px); }
  to   { opacity:1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--muted);
}
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── AVATARS ───────────────────────────────────────────── */
.avatar-sm {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm.unassigned {
  background: var(--border);
  color: var(--muted);
}

/* ── PAGINATION ─────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; margin-top: 14px; justify-content: center; }
.page-link {
  padding: 5px 10px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
}
.page-link:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.page-link.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
  .grid-2, .grid-3, .grid-4, .grid-32, .grid-23 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { display: none; }
}

/* ── UTILITY ────────────────────────────────────────────── */
.hidden   { display: none !important; }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; } .mb-4 { margin-bottom: 20px; }
.w-full { width: 100%; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; } .fw-600 { font-weight: 600; }
.fs-11  { font-size: 11px; }  .fs-12  { font-size: 12px; }

/* ── COMPATIBILITY ALIASES (v1 → v2) ───────────────────────── */
/* Button aliases */
.btn-orange { background: var(--orange); color: #fff; border-color: var(--orange); }
.btn-teal   { background: var(--teal);   color: #fff; border-color: var(--teal); }
.btn-blue   { background: var(--blue);   color: #fff; border-color: var(--blue); }
.btn-full   { width: 100%; justify-content: center; }

/* Alert aliases */
.alert-teal  { background: var(--teal-bg);  color: var(--teal);  border-color: var(--teal-light); }
.alert-blue  { background: var(--blue-bg);  color: var(--blue);  border-color: var(--blue-light); }
.alert-green { background: var(--green-bg); color: var(--green); border-color: var(--green-light);}

/* Chip colour aliases (dot-style from v2, keep all v1 colours) */
.chip-teal   { background: var(--teal-bg);   color: var(--teal); }
.chip-orange { background: var(--orange-bg); color: var(--orange); }
.chip-gray   { background: var(--bg2);       color: var(--muted); }
.chip-grey   { background: var(--bg2);       color: var(--muted); }
.chip-blue   { background: var(--blue-bg);   color: var(--blue); }
.chip-red    { background: var(--red-bg);    color: var(--red); }
.chip-violet { background: var(--violet-bg); color: var(--violet); }
.chip-gold   { background: var(--gold-bg);   color: var(--gold); }
.chip-green  { background: var(--green-bg);  color: var(--green); }

/* KPI helpers (v1 names still work) */
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.kpi-value { font-family: 'JetBrains Mono','Fira Code',monospace; font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1; margin-top: 4px; }

/* Section label */
.section-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 16px 0 8px; }

/* Form validation */
.is-invalid { border-color: var(--red) !important; }
.invalid-feedback { font-size: 11px; color: var(--red); margin-top: 3px; display: block; }

/* Progress aliases */
.progress-track { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; min-width: 40px; margin: 0; }
.progress-fill  { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.pf-orange { background: var(--orange); }
.pf-red    { background: var(--red); }

/* Photo upload zone */
.photo-upload-zone { border: 2px dashed var(--border2); border-radius: var(--radius-md); padding: 20px; text-align: center; cursor: pointer; color: var(--muted); font-size: 13px; }
.photo-upload-zone:hover { border-color: var(--brand); color: var(--brand); }
.photo-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }

/* Text utilities */
.text-teal   { color: var(--teal); }
.text-violet { color: var(--violet); }

/* Topbar logout (v1 compat) */
.topbar-logout { font-size: 12px; color: var(--muted); }

/* Dashboard filter buttons active state */
.btn-ghost.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Dashboard 2-column layout responsive fix */
.dash-2col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .dash-2col { grid-template-columns: 1fr; }
}
