/* ════════════════════════════════════════════════════════════════
   KORAVI CONSTRUCTION CRM — Design System
   Modern construction-SaaS. Light, clean, scannable.
   One brand color (Koravi navy/blue) + semantic accents (green/amber/red).
   NOTE: legacy CSS variable names (--navy, --blue2, --green …) are kept
   because inline JS templates reference them. Values are modernized.
═══════════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ─────────────────────────────────────────────── */
:root {
  /* Brand */
  --navy:    #0f1d31;   /* sidebar / deep brand */
  --navy2:   #16273f;   /* sidebar hover surface */
  --blue:    #1d4ed8;   /* primary brand action */
  --blue2:   #2563eb;   /* primary (lighter / hover text) */
  --gold:    #d99a2b;   /* construction accent — used sparingly */

  /* Semantic */
  --green:   #15924f;
  --red:     #d92d20;
  --amber:   #e08600;

  /* Neutrals */
  --gray-1:  #f4f6f9;   /* app background */
  --gray-2:  #e5e9f0;   /* borders / dividers */
  --gray-3:  #98a4b6;   /* muted text / icons */
  --text:    #14202e;   /* primary text */
  --text2:   #5a6b7e;   /* secondary text */
  --white:   #ffffff;

  /* Surfaces & effects */
  --surface:    #ffffff;
  --surface-2:  #f8fafc;  /* table head / subtle fill */
  --line:       #e5e9f0;
  --radius:     12px;
  --radius-sm:  8px;
  --radius-lg:  16px;
  --shadow2:    0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow:     0 8px 24px rgba(16,24,40,.10), 0 2px 6px rgba(16,24,40,.06);
  --shadow-lg:  0 24px 64px rgba(16,24,40,.20);
  --ring:       0 0 0 3px rgba(37,99,235,.18);

  /* Layout */
  --sidebar-w:  248px;
  --topbar-h:   60px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  font-family: var(--font);
  color: var(--text);
  background: var(--gray-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

html, body { min-height: 100vh; }
body { background: var(--gray-1); color: var(--text); font-size: 14px; line-height: 1.5; display: flex; flex-direction: column; }

a { color: var(--blue2); text-decoration: none; }
::selection { background: rgba(37,99,235,.18); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--gray-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--gray-2); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gray-3); }

/* ── INLINE SVG ICON HELPERS ───────────────────────────────────── */
.ic { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 0; vertical-align: -0.18em; }
.ic svg { display: block; width: 1em; height: 1em; }
.ic svg, .ic svg *, .btn svg, .nav-item svg, .nav-icon svg, button svg, a svg { pointer-events: none; }   /* B14: taps register on the button, not svg children */
.ic-inline { width: 1.05em; height: 1.05em; margin-right: .12em; color: var(--gray-3); }
.ic-dot { width: .62em; height: .62em; border-radius: 50%; display: inline-block; vertical-align: middle; }
.ic-dot.green { background: var(--green); }
.ic-dot.red   { background: var(--red); }
.ic-dot.amber { background: var(--amber); }
.ic-dot.gray  { background: var(--gray-3); }

/* ── BUTTONS ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; font-family: var(--font); font-size: .84rem; font-weight: 600;
  line-height: 1.1; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:active { transform: translateY(.5px); }
.btn .ic { font-size: 1.05em; }

.btn-primary, .btn-blue { background: var(--blue); color: #fff; }
.btn-primary:hover, .btn-blue:hover { background: #1b44c0; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #117a41; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #bd241a; }
.btn-gold { background: var(--gold); color: #3a2a06; }
.btn-gold:hover { background: #c98a1f; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy2); }

.btn-outline {
  background: var(--surface); border-color: var(--line); color: var(--text2);
}
.btn-outline:hover { border-color: var(--gray-3); color: var(--text); background: var(--surface-2); }

/* Outline button on dark backgrounds (login/topbar variants) */
.btn-ghost-light { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.16); }

.btn-sm { padding: 5px 11px; font-size: .78rem; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: .92rem; }
.btn-block { width: 100%; }

/* ── APP SHELL ─────────────────────────────────────────────────── */
.app-layout { display: flex; flex: 1; min-height: calc(100vh - var(--topbar-h)); }

/* TOPBAR — light, bordered */
.topbar {
  background: var(--surface); color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 20px; height: var(--topbar-h);
  position: sticky; top: 0; z-index: 200;
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.nav-toggle {
  display: none; width: 38px; height: 38px; border: 1px solid var(--line);
  background: var(--surface); border-radius: var(--radius-sm); cursor: pointer;
  align-items: center; justify-content: center; color: var(--text2); font-size: 1.2rem;
}
.nav-toggle:hover { background: var(--surface-2); color: var(--text); }
.topbar-logo { display: flex; align-items: center; gap: 10px; }
.topbar-logo .brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy);
  display: flex; align-items: center; justify-content: center; color: var(--gold);
  flex: none;
}
.topbar-logo .brand-mark svg { width: 20px; height: 20px; }
.topbar-logo .brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
.topbar-logo h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; color: var(--navy); line-height: 1.1; }
.topbar-logo h1 span { color: var(--gold); }
.topbar-logo .brand-sub { font-size: .66rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gray-3); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-date { font-size: .78rem; color: var(--text2); font-family: var(--mono); white-space: nowrap; }
.topbar-divider { width: 1px; height: 26px; background: var(--line); }
.topbar-user { display: flex; align-items: center; gap: 9px; padding-left: 2px; }
.topbar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gray-1);
  border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  color: var(--text2); flex: none;
}
.topbar-user .avatar svg { width: 18px; height: 18px; }
.topbar-user .u-meta { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-user .u-name { font-size: .82rem; font-weight: 600; color: var(--text); }

/* SIDEBAR — deep navy brand */
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; padding: 14px 0 22px;
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-section-title {
  font-size: .66rem; font-weight: 700; letter-spacing: .14em;
  color: rgba(255,255,255,.38); text-transform: uppercase;
  padding: 16px 22px 7px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  margin: 1px 10px; padding: 9px 12px; cursor: pointer; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.74); font-size: .86rem; font-weight: 500;
  transition: background .14s, color .14s;
}
.nav-item .nav-icon { width: 19px; height: 19px; display: inline-flex; align-items: center; justify-content: center; color: rgba(255,255,255,.55); flex: none; }
.nav-item .nav-icon svg { width: 19px; height: 19px; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item:hover .nav-icon { color: rgba(255,255,255,.85); }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item.active .nav-icon { color: #fff; }
.nav-item .nav-badge {
  margin-left: auto; font-size: .66rem; font-weight: 700; padding: 1px 7px;
  border-radius: 99px; background: rgba(255,255,255,.14); color: #fff;
}

.project-nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 1px 10px; padding: 8px 12px; cursor: pointer; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.66); font-size: .8rem; transition: background .14s, color .14s;
}
.project-nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.project-nav-item.active { background: rgba(217,154,43,.16); color: #f2c879; }
.proj-badge { font-size: .62rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: rgba(255,255,255,.12); color: rgba(255,255,255,.7); }
.proj-badge.green { background: rgba(21,146,79,.28); color: #6fe6a8; }
.proj-badge.amber { background: rgba(224,134,0,.28); color: #f5c270; }
.sidebar-add-btn {
  margin: 12px 14px 4px; background: rgba(217,154,43,.12);
  border: 1px dashed rgba(217,154,43,.42); color: #f0bd66; border-radius: var(--radius-sm);
  padding: 9px; text-align: center; cursor: pointer; font-size: .8rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px; transition: background .15s;
}
.sidebar-add-btn:hover { background: rgba(217,154,43,.2); }
.sidebar-spacer { flex: 1; }

/* MAIN */
.main { flex: 1; min-width: 0; padding: 26px 30px 60px; overflow-x: hidden; }

/* ── PAGE HEADER ───────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--navy); letter-spacing: -.02em; line-height: 1.15; }
.page-subtitle { font-size: .86rem; color: var(--text2); margin-top: 4px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ── CARD / SURFACE ────────────────────────────────────────────── */
.card, .surface {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow2);
}
.card-pad-lg { padding: 24px; }

/* ── KPI GRID ──────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 16px; margin-bottom: 26px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow2); position: relative;
}
.kpi-card::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 99px; background: var(--gray-2); }
.kpi-card.green::before  { background: var(--green); }
.kpi-card.red::before    { background: var(--red); }
.kpi-card.amber::before  { background: var(--amber); }
.kpi-card.blue::before   { background: var(--blue2); }
.kpi-card.navy::before   { background: var(--navy); }
.kpi-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text2); margin-bottom: 9px; }
.kpi-value { font-size: 1.95rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--navy); }
.kpi-value.green { color: var(--green); }
.kpi-value.red   { color: var(--red); }
.kpi-value.amber { color: var(--amber); }
.kpi-value.blue  { color: var(--blue2); }
.kpi-value.navy  { color: var(--navy); }
.kpi-sub { font-size: .74rem; color: var(--gray-3); margin-top: 6px; }

/* ── PROGRESS BAR ──────────────────────────────────────────────── */
.progress-bar-wrap { height: 7px; background: var(--gray-2); border-radius: 99px; margin-top: 9px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 99px; background: var(--blue); transition: width .6s ease; }

/* ── SECTION TITLE ─────────────────────────────────────────────── */
.section-title {
  font-size: .98rem; font-weight: 700; color: var(--navy); margin-bottom: 14px;
  display: flex; align-items: center; gap: 9px;
}
.section-title .ic { color: var(--blue2); }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── FILTER BAR / INPUTS ───────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.filter-select, .search-box {
  padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  font-family: var(--font); font-size: .83rem; color: var(--text); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.filter-select { cursor: pointer; }
.search-box { width: 220px; max-width: 100%; }
.filter-select:focus, .search-box:focus { outline: none; border-color: var(--blue2); box-shadow: var(--ring); }

/* Custom-styled dropdowns (kill native chevron / OS look) */
select.filter-select, select.form-select, select.status-select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398a4b6' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 13px;
  padding-right: 32px; cursor: pointer;
}
select.status-select { background-position: right 7px center; padding-right: 26px; }
select.filter-select::-ms-expand, select.form-select::-ms-expand { display: none; }

/* ── TABLE ─────────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow2); overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.qc-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.qc-table thead tr { background: var(--surface-2); }
.qc-table th {
  padding: 11px 15px; text-align: left; font-size: .69rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text2);
  white-space: nowrap; border-bottom: 1px solid var(--line);
}
.qc-table tbody tr { border-bottom: 1px solid var(--gray-1); transition: background .12s; }
.qc-table tbody tr:last-child { border-bottom: none; }
.qc-table tbody tr:hover { background: var(--surface-2); }
.qc-table td { padding: 11px 15px; vertical-align: middle; color: var(--text); }
.qc-table td.num, .qc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stage-row { background: #eef3fb !important; }
.stage-row td { font-weight: 700; color: var(--navy2); font-size: .78rem; letter-spacing: .03em; }

/* ── BADGES ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 99px; font-size: .72rem; font-weight: 600; white-space: nowrap; line-height: 1.3;
}
.badge-pass    { background: #dcf5e8; color: #0e7a4a; }
.badge-fail    { background: #fde4e2; color: #b42318; }
.badge-pending { background: #fdf0ce; color: #93600a; }
.badge-na      { background: #eef1f5; color: #667085; }

/* ── SCORE PILL ────────────────────────────────────────────────── */
.score-pill { display: inline-block; padding: 2px 9px; border-radius: 6px; font-family: var(--mono); font-size: .79rem; font-weight: 600; }
.score-pill.high  { background: #dcf5e8; color: #0e7a4a; }
.score-pill.mid   { background: #fdf0ce; color: #93600a; }
.score-pill.low   { background: #fde4e2; color: #b42318; }
.score-pill.empty { background: var(--gray-1); color: var(--gray-3); }

/* ── MODALS ────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10,18,30,.5);
  backdrop-filter: blur(3px); z-index: 1000; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg); width: 620px; max-width: 96vw;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.99); } }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-title { font-size: 1.08rem; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 9px; }
.modal-title .ic { color: var(--blue2); }
.modal-close {
  background: var(--surface-2); border: 1px solid var(--line); width: 30px; height: 30px;
  border-radius: 8px; cursor: pointer; color: var(--gray-3); font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex: none; transition: all .15s;
}
.modal-close:hover { color: var(--red); border-color: #f3c7c3; background: #fdecea; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); }

/* ── FORMS ─────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.single { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-label { font-size: .78rem; font-weight: 600; color: var(--text2); }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  font-family: var(--font); font-size: .86rem; color: var(--text); background: var(--surface);
  width: 100%; transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--blue2); box-shadow: var(--ring); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--gray-3); }
.form-textarea { resize: vertical; min-height: 76px; }
.form-hint { font-size: .73rem; color: var(--gray-3); }
.form-error { color: var(--red); font-size: .8rem; font-weight: 500; }

/* ── IMAGE UPLOAD ──────────────────────────────────────────────── */
.img-upload-area { border: 2px dashed var(--gray-2); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer; transition: all .18s; background: var(--surface-2); color: var(--text2); }
.img-upload-area:hover { border-color: var(--blue2); background: #eef4ff; }
.img-upload-area.drag-over { border-color: var(--gold); background: #fff8ec; }
.img-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; margin-top: 12px; }
.img-preview-item { position: relative; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1; border: 1px solid var(--line); }
.img-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-item .img-remove { position: absolute; top: 3px; right: 3px; background: rgba(217,45,32,.9); color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: .7rem; }

/* ── IN-TABLE STATUS SELECT & REMARK & IMG BTN ─────────────────── */
.status-select { padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line); font-size: .78rem; font-weight: 600; cursor: pointer; font-family: var(--font); }
.status-select.pass    { background: #dcf5e8; color: #0e7a4a; border-color: #9ae6c4; }
.status-select.fail    { background: #fde4e2; color: #b42318; border-color: #f3b4ae; }
.status-select.pending { background: #fdf0ce; color: #93600a; border-color: #f1d790; }
.status-select.na      { background: #eef1f5; color: #667085; border-color: #d4dae3; }
.remark-input { width: 100%; padding: 5px 9px; border-radius: 7px; border: 1px solid var(--line); font-size: .78rem; font-family: var(--font); color: var(--text); }
.remark-input.has-remark { border-color: var(--amber); background: #fffaf0; }
.remark-input:focus { outline: none; border-color: var(--blue2); box-shadow: var(--ring); }
.img-btn { padding: 5px 10px; border-radius: 7px; border: 1px solid var(--line); font-size: .75rem; cursor: pointer; background: var(--surface); transition: all .15s; display: inline-flex; align-items: center; gap: 5px; font-family: var(--font); color: var(--text2); }
.img-btn:hover { border-color: var(--blue2); color: var(--blue2); }
.img-btn.has-img { background: #eef4ff; border-color: var(--blue2); color: var(--blue2); }

/* ── DAILY REPORT CARD ─────────────────────────────────────────── */
.dqr-card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--blue2); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow2); margin-bottom: 14px; }
.dqr-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.dqr-date { font-family: var(--mono); font-size: .8rem; color: var(--text2); }
.dqr-project { font-weight: 700; font-size: .9rem; color: var(--navy); }
.dqr-stage { font-size: .78rem; color: var(--blue2); font-weight: 600; }
.dqr-summary { font-size: .84rem; color: var(--text2); margin-top: 6px; }
.dqr-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.dqr-pill { padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
.dqr-pill.pass   { background: #dcf5e8; color: #0e7a4a; }
.dqr-pill.fail   { background: #fde4e2; color: #b42318; }
.dqr-pill.issues { background: #fdf0ce; color: #93600a; }

/* ── PROJECT CARDS ─────────────────────────────────────────────── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 18px; }
.proj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow2); cursor: pointer; transition: border-color .18s, box-shadow .18s; }
.proj-card:hover { border-color: var(--blue2); box-shadow: var(--shadow); }
.proj-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.proj-card-name { font-size: 1.02rem; font-weight: 700; color: var(--navy); }
.proj-card-location, .proj-card-contractor { font-size: .78rem; color: var(--text2); margin-top: 3px; }
.proj-pct { font-size: 1.35rem; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.proj-stats { display: flex; gap: 10px; margin-top: 14px; }
.proj-stat { text-align: center; flex: 1; background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 6px; }
.proj-stat-val { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.proj-stat-lbl { font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-3); font-weight: 600; margin-top: 2px; }
.proj-stat-val.green { color: var(--green); }
.proj-stat-val.red   { color: var(--red); }
.proj-stat-val.amber { color: var(--amber); }

/* ── SNAG CARDS ────────────────────────────────────────────────── */
.snag-card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow2); margin-bottom: 10px; }
.snag-card.medium { border-left-color: var(--amber); }
.snag-card.low    { border-left-color: var(--gray-3); }
.snag-card.closed { border-left-color: var(--green); opacity: .72; }
.snag-header { display: flex; gap: 10px; align-items: flex-start; }
.snag-num { font-family: var(--mono); font-size: .74rem; color: var(--gray-3); }
.snag-desc { font-size: .88rem; font-weight: 600; color: var(--text); flex: 1; }
.snag-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 9px; font-size: .75rem; color: var(--text2); }

/* ── SIMPLE BAR CHART ──────────────────────────────────────────── */
.chart-bar-wrap { display: flex; gap: 10px; align-items: flex-end; height: 130px; margin-top: 12px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; justify-content: flex-end; }
.chart-bar { width: 100%; max-width: 46px; border-radius: 6px 6px 0 0; background: var(--blue); transition: height .5s ease; }
.chart-bar-label { font-size: .66rem; font-weight: 600; color: var(--text2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.chart-bar-val { font-family: var(--mono); font-size: .72rem; font-weight: 700; }

/* ── TOAST ─────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); font-size: .85rem; box-shadow: var(--shadow); animation: toastIn .25s ease; display: flex; align-items: center; gap: 10px; max-width: 360px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── FLOATING CALL BUTTON (CRM) ────────────────────────────────── */
.fab-call-wrap { position: fixed; bottom: 28px; right: 28px; z-index: 9990; display: flex; align-items: center; }
.fab-call { background: var(--green); color: #fff; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(21,146,79,.4); border: none; cursor: pointer; transition: transform .16s, box-shadow .16s; }
.fab-call svg { width: 24px; height: 24px; }
.fab-call:hover { transform: scale(1.06); box-shadow: 0 10px 30px rgba(21,146,79,.55); }
.fab-call-label { position: absolute; right: 70px; background: var(--navy); color: #fff; padding: 6px 12px; border-radius: 8px; font-size: .78rem; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateX(6px); transition: opacity .2s, transform .2s; }
.fab-call-wrap:hover .fab-call-label { opacity: 1; transform: translateX(0); }

/* ── LOGIN ─────────────────────────────────────────────────────── */
#loginPage {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
  background: radial-gradient(1200px 600px at 80% -10%, #1c3354 0%, transparent 60%), var(--navy);
}
.login-card { background: var(--surface); border-radius: var(--radius-lg); padding: 36px 38px; width: 408px; max-width: 96vw; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .brand-mark { width: 46px; height: 46px; border-radius: 12px; background: var(--navy); display: flex; align-items: center; justify-content: center; color: var(--gold); flex: none; }
.login-brand .brand-mark svg { width: 26px; height: 26px; }
.login-brand .brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.login-brand h1 { font-size: 1.18rem; font-weight: 700; color: var(--navy); line-height: 1.15; }
.login-brand h1 span { color: var(--gold); }
.login-brand .brand-sub { font-size: .66rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gray-3); }
.login-card h2 { font-size: 1.25rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; letter-spacing: -.01em; }
.login-card .login-sub { font-size: .84rem; color: var(--text2); margin-bottom: 22px; }
.login-input-wrap { margin-bottom: 14px; }
.login-input-wrap label { font-size: .78rem; font-weight: 600; color: var(--text2); display: block; margin-bottom: 6px; }
.login-hint { margin-top: 18px; font-size: .76rem; color: var(--gray-3); text-align: center; line-height: 1.5; }
.login-hint code { font-family: var(--mono); background: var(--gray-1); padding: 1px 6px; border-radius: 5px; color: var(--text2); }

/* legacy login role grid (kept harmless if present) */
.login-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.login-role-btn { padding: 10px 8px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--text); background: var(--surface); transition: all .15s; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.login-role-btn:hover { border-color: var(--blue2); background: #eef4ff; }
.login-role-btn.selected { border-color: var(--gold); background: #fff8ec; }

/* ── ROLE BADGE ────────────────────────────────────────────────── */
.role-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: .7rem; font-weight: 700; letter-spacing: .02em; }
.role-badge.admin            { background: #fdf0ce; color: #93600a; }
.role-badge.project-manager  { background: #e0ecff; color: #1d4ed8; }
.role-badge.site-engineer    { background: #dcf5e8; color: #0e7a4a; }
.role-badge.civil-engineer   { background: #ede4ff; color: #6d28d9; }
.role-badge.quality-engineer { background: #fde9cf; color: #a85907; }
.role-badge.accounts         { background: #d6f1f7; color: #0b7285; }
.role-badge.tele-caller      { background: #ffe1e8; color: #be123c; }

/* ── ENG REPORT CARD ───────────────────────────────────────────── */
.eng-report-card { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--blue2); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow2); margin-bottom: 14px; }

/* ── SETTINGS PANEL ────────────────────────────────────────────── */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 28px; }
.cfg-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow2); display: flex; flex-direction: column; }
.cfg-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.cfg-card-title { font-size: .92rem; font-weight: 700; color: var(--navy); }
.cfg-card-sub { font-size: .73rem; color: var(--gray-3); margin-top: 2px; }
.cfg-count { font-size: .7rem; font-weight: 700; color: var(--text2); background: var(--gray-1); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; flex: none; }
.cfg-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; min-height: 26px; }
.cfg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; font-size: .78rem; color: var(--text); }
.cfg-chip-x { width: 16px; height: 16px; border: none; background: var(--gray-2); color: var(--text2); border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: background .15s, color .15s; }
.cfg-chip-x svg { width: 9px; height: 9px; }
.cfg-chip-x:hover { background: var(--red); color: #fff; }
.cfg-add { display: flex; gap: 8px; margin-top: auto; }
.cfg-add .form-input { flex: 1; padding: 7px 11px; font-size: .82rem; }
/* settings tabs */
.cfg-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.cfg-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 9px 14px; cursor: pointer; font-family: var(--font); font-size: .9rem; font-weight: 600; color: var(--text2); margin-bottom: -1px; }
.cfg-tab:hover { color: var(--text); }
.cfg-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
/* per-option usage count + disabled remove */
.cfg-chip-n { font-size: .64rem; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; border-radius: 99px; background: var(--gray-2); color: var(--text2); }
.cfg-chip-n.used { background: #e0ecff; color: #1d4ed8; }
.cfg-chip-x.disabled { background: transparent; color: var(--gray-3); cursor: not-allowed; opacity: .5; }
.cfg-chip-x.disabled:hover { background: transparent; color: var(--gray-3); }
/* integration cards */
.cfg-int-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 4px 0 14px; }
.cfg-int-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .switch-sl { position: absolute; inset: 0; background: var(--gray-2); border-radius: 99px; transition: background .15s; cursor: pointer; }
.switch .switch-sl::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-sl { background: var(--green); }
.switch input:checked + .switch-sl::before { transform: translateX(16px); }

/* ── MOBILE DRAWER BACKDROP ────────────────────────────────────── */
.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(10,18,30,.5); z-index: 150; }
.drawer-backdrop.open { display: block; }

/* ── UTILITIES ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.page { display: none; }
.page.active { display: block; }
.muted { color: var(--text2); }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-3); }
.empty-state .ic { font-size: 2rem; color: var(--gray-2); display: block; margin: 0 auto 10px; }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE  (one comprehensive block — responsive-checker compliant)
   Breakpoints: 1024 (tablet), 768 (mobile), 480 (small)
   Inline-style attribute selectors catch hard-coded grids in JS/markup.
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .main { padding: 22px 20px 56px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 880px) {
  /* sidebar becomes off-canvas drawer */
  .nav-toggle { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 160;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { position: sticky; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-date, .topbar-divider { display: none; }
  .topbar-logo .brand-sub { display: none; }
  .topbar-user .u-meta { display: none; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .main { padding: 18px 14px 50px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .projects-grid { grid-template-columns: 1fr; }
  .form-row, .form-row.triple { grid-template-columns: 1fr; }
  .modal { width: 100%; max-width: 96vw; }
  .filter-bar { gap: 8px; }
  .search-box { width: 100%; }
  /* catch inline grid declarations in markup/JS templates */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:repeat(2"],
  [style*="grid-template-columns: repeat(2"],
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: 1fr !important;
  }
  /* fixed two-column "240px 1fr" style layouts collapse */
  [style*="grid-template-columns:240px"],
  [style*="grid-template-columns: 240px"],
  [style*="grid-template-columns:260px"],
  [style*="grid-template-columns: 260px"],
  [style*="grid-template-columns:280px"],
  [style*="grid-template-columns: 280px"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .proj-stats { flex-wrap: wrap; }
  .page-title { font-size: 1.3rem; }
  .fab-call-wrap { bottom: 18px; right: 18px; }
}

/* images never overflow */
img { max-width: 100%; height: auto; }
