/* Tameer — Construction Expense Management
   Brand: teal #019A95 · charcoal #1E252B (sampled from the logo) */

:root {
  --teal: #019A95;
  --teal-700: #017A76;
  --teal-50: #E7F6F5;
  --teal-100: #CDEDEA;
  --ink: #1E252B;
  --ink-2: #3D4852;
  --muted: #6A7680;
  --line: #E2E8EA;
  --line-2: #EEF2F3;
  --bg: #F4F7F7;
  --card: #FFFFFF;
  --red: #C8413B;
  --red-50: #FCEDEC;
  --green: #0B8457;
  --green-50: #E7F5EE;
  --amber: #B7791F;
  --amber-50: #FDF4E3;
  --blue: #2F6FB3;
  --blue-50: #EAF2FB;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(30, 37, 43, .05), 0 1px 3px rgba(30, 37, 43, .04);
  --shadow-lg: 0 10px 30px rgba(30, 37, 43, .12);
  --sidebar: 256px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 30px; height: 30px; }

/* ---------- Urdu labels ---------- */
.ur {
  font-family: var(--font-ur); font-weight: 400; color: var(--muted);
  font-size: .78em; line-height: 1; letter-spacing: 0; white-space: nowrap;
}
.no-urdu .ur { display: none; }
.label .ur, th .ur, .kpi-label .ur, .dt-ur, dt .ur { display: block; margin-top: 6px; font-size: .82em; line-height: 1.9; text-align: left; }
.card-title .ur { font-size: .78em; margin-inline-start: 4px; }
.table th.num .ur { text-align: right; }
h1 .ur { font-size: .55em; margin-inline-start: 6px; vertical-align: middle; }
.btn .ur, .chip .ur, .tab .ur { font-size: .74em; opacity: .85; }
.btn-primary .ur { color: rgba(255,255,255,.85); }
.nav-link .ur { display: block; font-size: .72em; line-height: 1.9; margin-top: 2px; text-align: left; }
.sheet .ur { display: inline; margin: 0 0 0 6px; font-size: .8em; line-height: 1; }
.sheet thead .ur { display: block; margin: 5px 0 0; line-height: 1.8; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.brand img { width: 170px; height: auto; }
.nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500; font-size: 14px; position: relative;
}
.nav-link:hover { background: var(--line-2); text-decoration: none; color: var(--ink); }
.nav-link.is-active { background: var(--teal-50); color: var(--teal-700); }
.nav-link.is-active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--teal); }
.nav-link .icon { color: var(--muted); }
.nav-link.is-active .icon { color: var(--teal); }
.nav-link.is-soon { opacity: .5; cursor: default; }
.nav-text { flex: 1; min-width: 0; }
.soon { font-size: 10px; font-weight: 700; color: var(--muted); background: var(--line-2); border-radius: 999px; padding: 1px 6px; letter-spacing: .02em; }
.nav-sep { margin: 14px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.nav-sep .ur { text-transform: none; letter-spacing: 0; }
.sidebar-foot { border-top: 1px solid var(--line); padding: 12px 14px; display: flex; align-items: center; gap: 8px; }
.me { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); }
.me:hover { text-decoration: none; }
.me-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.3; }
.me-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--teal); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
a.avatar:hover { text-decoration: none; }

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 30; display: none; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar-brand { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }
.topbar-brand img { width: 28px; height: 28px; object-fit: contain; }
.topbar-brand:hover { text-decoration: none; }
.scrim { display: none; }
.only-mobile { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; line-height: 1.3; min-height: 40px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; border-color: #C9D3D6; background: #FAFCFC; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--teal-100); outline-offset: 1px; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-700); border-color: var(--teal-700); color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #A9342F; border-color: #A9342F; color: #fff; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 20px; min-height: 48px; font-size: 15px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.icon-btn.danger:hover { background: var(--red-50); color: var(--red); }
.linklike { background: none; border: 0; padding: 0; color: var(--teal-700); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13.5px; }

/* ---------- Page structure ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.head-actions { display: flex; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; font-weight: 500; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.strong { font-weight: 600; color: var(--ink); }
.nowrap { white-space: nowrap; }
.mt { margin-top: 22px; }
.mb { margin-bottom: 16px; }
.pos { color: var(--green); }
.neg { color: var(--red) !important; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-soft { background: #FAFCFC; box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 12px; }
.card-head .card-title { margin-bottom: 0; }
.count { font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--muted); border-radius: 999px; padding: 1px 8px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.two-col.wide-left { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.two-col > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg > .card:last-child { margin-bottom: 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis-3, .kpis-n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis-n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value small { font-size: .6em; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-accent { background: linear-gradient(160deg, #F2FBFA, #fff 60%); border-color: var(--teal-100); }
.kpi-accent .kpi-value { color: var(--teal-700); }

.meter { height: 7px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.meter.over span { background: var(--red); }
.meter.plain span { background: #7FC9C5; }
.meter.sm { height: 5px; min-width: 60px; }

/* ---------- Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; vertical-align: middle; line-height: 1.6; }
.badge .ur { color: inherit; opacity: .8; }
h1 .badge { font-size: 12px; letter-spacing: 0; }
.badge-planning { background: var(--blue-50); color: var(--blue); }
.badge-under_construction { background: var(--amber-50); color: var(--amber); }
.badge-completed { background: var(--teal-50); color: var(--teal-700); }
.badge-sold { background: var(--green-50); color: var(--green); }
.badge-on_hold { background: var(--red-50); color: var(--red); }
.role-super_admin { background: var(--ink); color: #fff; }
.role-admin { background: var(--teal-50); color: var(--teal-700); }
.role-site_manager { background: var(--amber-50); color: var(--amber); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--teal-50); color: var(--teal-700); margin-right: 6px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.filters select { width: auto; min-width: 180px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 38px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font-size: 13px; font-weight: 500; }
.chip:hover { text-decoration: none; border-color: #C9D3D6; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-on .count { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Alerts ---------- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.alert > span { flex: 1; }
.alert-success { background: var(--green-50); border-color: #BFE3D0; color: #0A5C3E; }
.alert-error { background: var(--red-50); border-color: #F2C6C3; color: #8E2B26; }
.alert-info { background: var(--blue-50); border-color: #C8DCF1; color: #1F4E80; }
.alert-x { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; display: flex; }
.alert-x .icon { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: #fff;
  border: 1px solid #D5DDE0; border-radius: 9px; padding: 9px 12px; min-height: 42px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-100); }
input[dir=rtl] { font-family: var(--font-ur); font-size: 14px; line-height: 2; padding-top: 4px; padding-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--red); font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.field-end { justify-content: flex-end; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.form-card .card-title { color: var(--ink); }
.form-card .card-title .icon { color: var(--teal); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 14px 0 6px; margin-top: 0; z-index: 5; }
.card .sticky-actions { background: linear-gradient(to top, #fff 70%, transparent); }
.check, .switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input, .switch input, .perm-grid input, .check-card input { width: 18px; height: 18px; accent-color: var(--teal); margin: 0; }
.switch input { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: #CBD5D8; position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { transform: translateX(16px); }
.switch.small { font-size: 13px; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
.fieldset legend { font-weight: 700; padding: 0 6px; }
.info { display: inline-flex; width: 16px; height: 16px; border-radius: 50%; background: var(--line); color: var(--ink-2); font-size: 11px; align-items: center; justify-content: center; cursor: help; position: relative; }
.info:hover::after, .info:focus::after { content: attr(data-tip); position: absolute; right: 0; top: 22px; width: 240px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.45; padding: 8px 10px; border-radius: 8px; text-align: left; white-space: normal; z-index: 10; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: none; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: bottom; }
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:hover td { background: #FAFCFC; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .w-bar { width: 140px; }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.is-disabled td { opacity: .55; }
.user-cell { display: flex; align-items: center; gap: 10px; }

/* Budget sheet */
.sheet-wrap { max-height: none; }
.sheet th, .sheet td { padding: 8px 12px; }
.sheet .group-row th { background: #F6F9F9; color: var(--ink); font-size: 13.5px; font-weight: 700; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-top: 10px; padding-bottom: 10px; }
.sheet tbody td:first-child { padding-left: 24px; }
.sheet tfoot th { font-size: 14px; color: var(--ink); border-top: 2px solid var(--ink); border-bottom: 0; padding-top: 12px; }
.sheet tr.is-over td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.sheet.hide-empty tr.is-empty, .sheet.hide-empty tbody.is-empty { display: none; }
.sticky-col { position: sticky; left: 0; background: inherit; z-index: 1; }
.sheet td.sticky-col { background: #fff; }
.sheet .group-row .sticky-col { background: #F6F9F9; }
.edit-sheet input.amount { text-align: right; min-height: 36px; padding: 6px 10px; max-width: 170px; margin-left: auto; font-variant-numeric: tabular-nums; }
.edit-sheet input.amount.calc-error { border-color: var(--red); }
.per-sqft { display: block; font-size: 11.5px; margin-top: 2px; min-height: 1em; }
.budget-total { font-size: 14px; color: var(--muted); }
.budget-total strong { color: var(--ink); font-size: 16px; }

/* Responsive table → cards on phones */
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
  .table.responsive td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; flex-shrink: 0; }
  .table.responsive td:first-child { display: block; text-align: left; border-bottom: 1px solid var(--line-2); padding-bottom: 10px; margin-bottom: 4px; }
  .table.responsive td:first-child::before { display: none; }
  .table.responsive td.actions { justify-content: flex-end; }
  .table.responsive td.actions::before { display: none; }
  .table.responsive .num { text-align: right; }
  .table.responsive .meter { width: 120px; margin-top: 6px; }
  .table-wrap { margin: 0; padding: 0; }
}

/* ---------- Projects ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.project-card {
  display: flex; flex-direction: column; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--ink); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-card:hover { text-decoration: none; border-color: var(--teal-100); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.pc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pc-head h3 { font-size: 1.02rem; }
.pc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pc-stats strong { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pc-stats .ur { display: block; margin-top: 4px; line-height: 1.8; }
.pc-foot { display: flex; justify-content: space-between; }

.project-head .page-head { margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--teal-700); border-bottom-color: var(--teal); }
.tab.is-soon { opacity: .45; cursor: default; font-weight: 500; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.facts dt { color: var(--muted); font-size: 13.5px; }
.facts dd { margin: 0; font-weight: 500; text-align: right; font-size: 14px; }
.facts.one-col { grid-template-columns: 1fr; }
.notes { margin-top: 14px; padding: 12px 14px; background: #FAFCFC; border-radius: 10px; font-size: 14px; }
.notes p { margin: 4px 0 0; }

.group-bars { display: flex; flex-direction: column; gap: 14px; }
.gb-row { display: grid; grid-template-columns: 170px 1fr 170px; gap: 14px; align-items: center; font-size: 14px; }
.gb-name { font-weight: 600; }
.gb-name .ur { display: inline; margin-left: 6px; }
.gb-nums { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.doc-mini { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.doc-mini li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.doc-mini a { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); font-weight: 500; font-size: 14px; }
.doc-mini a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-mini .icon { color: var(--teal); }
.people { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.people li { display: flex; align-items: center; gap: 10px; }
.danger-zone summary { cursor: pointer; color: var(--red); font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.danger-zone[open] summary { margin-bottom: 12px; }

/* ---------- Documents ---------- */
.upload-card { padding: 16px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  border: 2px dashed #CAD6D8; border-radius: var(--radius); padding: 26px 16px; cursor: pointer; color: var(--ink-2);
  background: #FAFCFC; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--teal); background: var(--teal-50); }
.dropzone .icon { color: var(--teal); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-meta { margin-top: 14px; align-items: end; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.doc-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.doc-thumb { aspect-ratio: 4 / 3; background: #F1F5F5; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-ext { font-weight: 800; font-size: 20px; letter-spacing: .04em; color: #fff; background: var(--ink-2); padding: 12px 16px; border-radius: 10px; }
.ext-pdf { background: #C8413B; }
.ext-dwg, .ext-dxf { background: var(--blue); }
.ext-xls, .ext-xlsx { background: var(--green); }
.ext-doc, .ext-docx { background: #2B579A; }
.doc-body { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.doc-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.doc-actions { display: flex; gap: 2px; padding: 4px 8px 8px; margin-top: auto; }
.doc-actions form { display: inline; }
.rename-form { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 14px; }

/* ---------- Cost heads ---------- */
.head-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.head-groups .card { margin-bottom: 0; }
.head-group.is-inactive { opacity: .65; }
.head-list { list-style: none; margin: 0 0 10px; padding: 0; }
.head-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.head-list li.is-inactive .head-name { color: var(--muted); text-decoration: line-through; }
.head-name .ur { margin-left: 6px; }
.row-actions { display: flex; align-items: center; gap: 0; }
.row-actions form { display: inline; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon { width: 16px; height: 16px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.inline-form input[type=text] { flex: 1; min-width: 140px; min-height: 38px; }
.inline-form select { width: auto; min-height: 38px; }
.inline-form.full { width: 100%; margin: 8px 0; }
.w-sort { width: 80px !important; min-height: 38px; }
.w-ur { max-width: 130px; }
.add-head { margin: 0; }

/* ---------- Users ---------- */
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.role-option { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.role-option:has(input:checked) { border-color: var(--teal); background: var(--teal-50); }
.role-option input { margin-top: 3px; accent-color: var(--teal); width: 18px; height: 18px; }
.role-option span { display: flex; flex-direction: column; gap: 3px; }
.role-option small { font-size: 12.5px; }
.perm-grid td, .perm-grid th { padding: 9px 10px; }
.perm-grid th .ur { display: block; }
.perm-grid td:first-child .ur { margin-left: 6px; }
.project-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 14px; }
.check-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.check-card:has(input:checked) { border-color: var(--teal); background: var(--teal-50); }
.check-card span { display: flex; flex-direction: column; font-size: 14px; }
.check-card small { font-size: 12px; }

/* ---------- Activity ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: flex; gap: 12px; padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--line-2); }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-top: 7px; flex-shrink: 0; }
.act-delete .feed-dot { background: var(--red); }
.act-update .feed-dot { background: var(--amber); }
.act-tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--teal-50); color: var(--teal-700); margin-right: 4px; }
.act-tag.act-delete { background: var(--red-50); color: var(--red); }
.act-tag.act-update { background: var(--amber-50); color: var(--amber); }
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.roadmap { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); }

/* ---------- Empty & error ---------- */
.empty-state { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-state.compact { padding: 20px; }
.empty-state p { max-width: 460px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--teal-50); color: var(--teal); display: flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.empty-icon .icon { width: 26px; height: 26px; }
.error-page { padding-top: 80px; }
.error-code { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0; letter-spacing: .1em; }
.error-page .btn { margin: 4px; }

/* ---------- Guest (login / setup) ---------- */
body.guest { background: radial-gradient(1200px 600px at 50% -10%, #E3F4F2, var(--bg) 60%); }
.guest-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.auth-card.wide { max-width: 760px; }
.auth-logo { width: 220px; margin: 0 auto 18px; }
.auth-title { text-align: center; font-size: 1.25rem; margin-bottom: 20px; }
.auth-title .ur { display: block; font-size: .7em; margin-top: 10px; line-height: 1.8; }
.checklist { list-style: none; padding: 0; margin: 16px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 13.5px; }
.checklist li { display: flex; align-items: center; gap: 8px; }
.checklist .ok { color: var(--green); }
.checklist .bad { color: var(--red); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis:not(.kpis-4) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .two-col, .two-col.wide-left { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .head-groups { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .only-mobile { display: flex !important; }
  .topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); width: 280px; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(30, 37, 43, .4); z-index: 35; }
  body.nav-open { overflow: hidden; }
  .main { margin-left: 0; }
  .content { padding: 20px 16px 40px; }
  .facts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.3rem; }
  .kpis, .kpis-4, .kpis:not(.kpis-4) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px; }
  .kpi-value { font-size: 1.15rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .card { padding: 16px; border-radius: 10px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .page-head > .btn, .page-head > a.btn { width: 100%; }
  .project-grid, .doc-grid { grid-template-columns: 1fr; }
  .gb-row { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .gb-bar { grid-column: 1 / -1; grid-row: 2; }
  .role-pick { grid-template-columns: 1fr; }
  .checklist { grid-template-columns: 1fr; }
  .search { max-width: none; }
  .filters select { flex: 1; min-width: 0; }
  .auth-card { padding: 26px 20px; }
  .sheet td.sticky-col, .sheet th.sticky-col { max-width: 150px; white-space: normal; }
  .edit-sheet input.amount { max-width: 120px; min-width: 96px; }
  .sticky-actions .btn { flex: 1; }
}
/* ============ Phase 2: purchases, payments, accounts, partners ============ */
.mt-xs { margin-top: 6px; }
.clickable { cursor: pointer; }
.narrow-form { max-width: 820px; }
.compact-kpis .kpi { padding: 12px 16px; }
.compact-kpis .kpi-value { font-size: 1.15rem; }
.items-cell { max-width: 280px; color: var(--ink-2); font-size: 13.5px; }
.qty-line { font-size: 12px; color: var(--muted); margin-top: 2px; }
.warn { color: var(--amber); font-weight: 600; }

/* status badges for bills */
.pay-paid { background: var(--green-50); color: var(--green); }
.pay-partial { background: var(--amber-50); color: var(--amber); }
.pay-unpaid { background: var(--red-50); color: var(--red); }

/* transaction type tags */
.txn-tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); }
.txn-supplier_payment { background: var(--blue-50); color: var(--blue); }
.txn-expense { background: var(--amber-50); color: var(--amber); }
.txn-transfer { background: var(--line-2); color: var(--ink-2); }
.txn-sale_receipt, .txn-investment { background: var(--green-50); color: var(--green); }
.txn-payout, .txn-land_payment { background: var(--red-50); color: var(--red); }

/* purchase lines */
.items-head { display: grid; grid-template-columns: minmax(200px, 2.4fr) 0.9fr 0.8fr 1fr 1.1fr 36px; gap: 8px; padding: 0 11px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.items-head .num { text-align: right; }
.items-head .ur { display: block; font-size: .85em; line-height: 1.8; }
.bill-table tfoot .ur, .sheet tfoot .ur, .split-table tfoot .ur { display: inline; margin-left: 6px; }
.items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.item-row {
  display: grid; grid-template-columns: minmax(200px, 2.4fr) 0.9fr 0.8fr 1fr 1.1fr 36px; gap: 8px; align-items: start;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #FBFDFD;
}
.item-row input, .item-row select { min-height: 40px; }
.ir-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ir-other { display: flex; flex-direction: column; gap: 6px; }
.ir-head { font-size: 12px; color: var(--teal-700); min-height: 1em; }
.ir-lbl { display: none; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.item-row label { display: flex; flex-direction: column; min-width: 0; }
.ir-amt input { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ir-amt input.is-calc { background: #F1F7F6; border-color: transparent; }
.ir-qty input, .ir-rate input { text-align: right; font-variant-numeric: tabular-nums; }
.ir-del { margin-top: 2px; }
.bill-totals { margin-left: auto; max-width: 360px; display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.bill-totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14.5px; }
.bill-totals input { max-width: 160px; text-align: right; min-height: 38px; }
.bill-totals strong { font-variant-numeric: tabular-nums; }
.bt-total { font-size: 18px !important; padding-top: 8px; border-top: 2px solid var(--ink); }
.bt-total strong { font-size: 20px; color: var(--teal-700); }
.quick-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-btns .chip { cursor: pointer; font: inherit; font-size: 12.5px; padding: 4px 10px; }
.payable-line { margin-top: 14px; padding: 10px 14px; background: #FAFCFC; border-radius: 10px; display: flex; justify-content: space-between; font-size: 14.5px; }
.payable-line strong { color: var(--red); }

/* file pickers */
.file-pick { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 2px dashed #CAD6D8; border-radius: 10px; cursor: pointer; background: #FAFCFC; transition: border-color .15s, background .15s; }
.file-pick:hover, .file-pick.has-file { border-color: var(--teal); background: var(--teal-50); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.fp-label { font-weight: 600; font-size: 14px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.att { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.att-thumb { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; background: #F1F5F5; overflow: hidden; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb .doc-ext { font-size: 14px; padding: 8px 10px; }
.att-meta { padding: 6px 8px; display: flex; flex-direction: column; font-size: 12.5px; }
.att-meta .ur { display: none; }
.att-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; background: rgba(255,255,255,.9); }
.attach-more { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.attach-more select { width: auto; min-height: 34px; font-size: 13px; }

/* bill view */
.bill-head { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.bill-head > div { display: flex; flex-direction: column; gap: 2px; }
.bill-table tfoot td, .bill-table tfoot th { border-bottom: 0; padding-top: 6px; padding-bottom: 6px; }
.bill-total th { font-size: 16px; border-top: 2px solid var(--ink); padding-top: 10px !important; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; flex-wrap: wrap; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list li > span { flex: 1; min-width: 140px; }
.mini-list li > strong { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* payments */
.type-switch, .new-entry-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.new-entry-bar .chip { gap: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 9px 14px; font-size: 14px; font-weight: 500; }
.seg input:checked + span { background: var(--teal); color: #fff; }
.seg input:checked + span .ur { color: rgba(255,255,255,.85); }
.money-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; color: var(--ink); box-shadow: var(--shadow); }
.money-strip:hover { text-decoration: none; border-color: var(--teal-100); }
.money-strip > div { display: flex; flex-direction: column; gap: 2px; }
.money-strip strong { font-size: 16px; font-variant-numeric: tabular-nums; }

/* accounts */
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.account-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.account-card:hover { text-decoration: none; border-color: var(--teal-100); box-shadow: var(--shadow-lg); }
.ac-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.ac-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--teal-50); color: var(--teal); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.type-bank .ac-icon { background: var(--blue-50); color: var(--blue); }
.type-petty_cash .ac-icon { background: var(--amber-50); color: var(--amber); }
.ac-name { font-size: 15px; }
.ac-bal { font-size: 1.35rem; margin-top: 8px; font-variant-numeric: tabular-nums; }
.account-card.is-disabled { opacity: .55; }
.my-cash { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); background: linear-gradient(120deg, #FFF8EA, #fff); border: 1px solid #F3DDB0; margin-bottom: 18px; color: var(--ink); }
.my-cash:hover { text-decoration: none; }
.my-cash > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.my-cash strong { font-size: 1.3rem; }
.my-cash .ac-icon { background: var(--amber-50); color: var(--amber); }

/* partners */
.share-pill { display: inline-block; min-width: 56px; text-align: center; font-weight: 700; font-size: 13px; padding: 2px 8px; border-radius: 999px; background: var(--teal-50); color: var(--teal-700); }
.split-table tfoot th { border-top: 2px solid var(--ink); color: var(--ink); font-size: 13.5px; }

.w-unit { max-width: 150px; }

@media (max-width: 900px) {
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 1fr; }
  .ir-item { grid-column: 1 / -1; }
  .ir-lbl { display: block; }
  .ir-amt { grid-column: span 2; }
  .ir-del { justify-self: end; align-self: end; }
}
@media (max-width: 640px) {
  .item-row { grid-template-columns: 1fr 1fr; }
  .ir-amt { grid-column: auto; }
  .ir-del { grid-column: 1 / -1; justify-self: end; margin-top: -4px; }
  .bill-totals { max-width: none; }
  .bill-head { grid-template-columns: 1fr; }
  .head-actions { flex-wrap: wrap; width: 100%; }
  .head-actions .btn { flex: 1; }
}

/* ============ Phase 3: contracts & labour ============ */
.contract-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.contract-card { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.contract-card:hover { text-decoration: none; border-color: var(--teal-100); box-shadow: var(--shadow-lg); }
.contract-card.status-cancelled { opacity: .6; }
.cc-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.cc-terms { font-size: 13.5px; color: var(--ink-2); background: #F6F9F9; border-radius: 8px; padding: 8px 10px; }
.cc-bars { display: flex; flex-direction: column; gap: 5px; }
.cc-bar-lbl { display: flex; justify-content: space-between; font-size: 12.5px; }
.cc-foot { display: flex; justify-content: space-between; font-size: 13.5px; padding-top: 8px; border-top: 1px solid var(--line-2); }

.new-contractor { margin-top: 8px; gap: 8px !important; }
.contract-total { margin-top: 16px; padding: 12px 14px; background: var(--teal-50); border-radius: 10px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.contract-total strong { font-size: 20px; color: var(--teal-700); font-variant-numeric: tabular-nums; }
.stages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.stage-row { display: grid; grid-template-columns: minmax(180px, 2fr) 100px 140px minmax(100px, 1fr) 36px; gap: 8px; align-items: center; }
.stage-row.is-done { opacity: .75; }
.stage-row input { min-height: 38px; }
.stage-row input:disabled { background: #F4F7F7; color: var(--muted); }
.sr-pct { position: relative; display: block; }
.sr-pct input { padding-right: 26px; text-align: right; }
.sr-pct span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.stage-row [data-stage-amt] { text-align: right; }
.stages-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.stage-list { list-style: none; margin: 0 0 8px; padding: 0; position: relative; }
.stage-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); position: relative; }
.stage-list li:last-child { border-bottom: 0; }
.stage-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #CBD5D8; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: #fff; }
.stage-list li.is-done .stage-dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.stage-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stage-list li.is-done .stage-body strong { color: var(--ink-2); }
.stage-action { display: flex; gap: 6px; align-items: center; }
.stage-action input[type=date] { width: 150px; min-height: 32px; padding: 4px 8px; font-size: 13px; }

@media (max-width: 640px) {
  .stage-row { grid-template-columns: 1fr 1fr; }
  .stage-row input[name="stage_name[]"] { grid-column: 1 / -1; }
  .stage-list li { flex-wrap: wrap; }
  .stage-action { width: 100%; justify-content: flex-end; }
  .contract-grid { grid-template-columns: 1fr; }
}

/* ============ Phase 4: inventory & site diary ============ */
.stock-bar { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.stock-bar .meter { width: 90px; }
.stock-left { font-size: 15px; }
.stock-left small { font-weight: 500; color: var(--muted); }
.stock-matrix th a { color: var(--ink-2); }
.stock-matrix td, .stock-matrix th { white-space: nowrap; }
.stock-matrix td.sticky-col, .stock-matrix th.sticky-col { background: #fff; }
.mv-opening { background: var(--blue-50); color: var(--blue); }
.mv-usage { background: var(--amber-50); color: var(--amber); }
.mv-adjust { background: var(--line-2); color: var(--ink-2); }
.action-list { display: flex; flex-direction: column; gap: 4px; }
.action-list a { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; color: var(--ink); }
.action-list a:hover { background: #fff; text-decoration: none; }
.action-list a .icon { color: var(--teal); }
.action-list span { display: flex; flex-direction: column; }
.moves { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.move-row { display: grid; grid-template-columns: minmax(200px, 2fr) 150px 1fr 1.2fr 36px; gap: 8px; align-items: center; }
.use-row { grid-template-columns: minmax(200px, 2fr) 150px 1.5fr 36px; }
.move-row input, .move-row select { min-height: 40px; }
.mr-qty { position: relative; display: block; }
.mr-qty input { padding-right: 50px; text-align: right; }
.mr-unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); pointer-events: none; }
.w-date { max-width: 220px; }

.today-cta { display: flex; align-items: center; gap: 14px; padding: 16px 18px; margin-bottom: 14px; border: 2px dashed var(--teal-100); border-radius: var(--radius); background: #FAFDFD; color: var(--ink); }
.today-cta:hover { border-color: var(--teal); background: var(--teal-50); text-decoration: none; }
.today-cta > .icon { width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--teal); color: #fff; }
.today-cta span { display: flex; flex-direction: column; }
.diary-list { display: flex; flex-direction: column; gap: 10px; }
.diary-card { display: flex; gap: 14px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); box-shadow: var(--shadow); align-items: flex-start; }
.diary-card:hover { text-decoration: none; border-color: var(--teal-100); }
.dc-date { display: flex; flex-direction: column; align-items: center; min-width: 52px; padding: 6px 4px; border-radius: 10px; background: var(--teal-50); color: var(--teal-700); line-height: 1.1; }
.dc-day { font-size: 22px; font-weight: 800; }
.dc-mon { font-size: 12px; font-weight: 700; text-transform: uppercase; }
.dc-wd { font-size: 11px; color: var(--muted); }
.dc-body { flex: 1; min-width: 0; }
.dc-body p { margin: 0 0 6px; font-size: 14px; }
.dc-project { display: block; font-size: 13px; color: var(--teal-700); margin-bottom: 2px; }
.dc-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.dc-cover { width: 88px; height: 66px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.diary-text { font-size: 15px; line-height: 1.6; }
.notes.issue { background: var(--amber-50); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.weather-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.weather-pick input { position: absolute; opacity: 0; pointer-events: none; }
.weather-pick span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; cursor: pointer; }
.weather-pick input:checked + span { background: var(--teal); border-color: var(--teal); color: #fff; }
details.form-card > summary { cursor: pointer; list-style: none; }
details.form-card > summary::-webkit-details-marker { display: none; }

.progress-card { position: sticky; top: 16px; }
.progress-ring { --pct: 0; width: 132px; height: 132px; margin: 4px auto 10px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(closest-side, #fff 78%, transparent 79% 100%), conic-gradient(var(--teal) calc(var(--pct) * 1%), var(--line-2) 0); }
.progress-ring strong { font-size: 28px; line-height: 1; }
.progress-editor { display: flex; flex-direction: column; margin-top: 10px; }
.pe-group { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 4px; }
.pe-row { display: grid; grid-template-columns: 1fr 70px 78px; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.pe-name .ur { display: none; }
.pe-input { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.pe-input input { min-height: 32px; padding: 4px 6px; text-align: right; width: 60px; }
.pe-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.pe-foot input { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13px; }
.progress-mini { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.progress-mini .meter { width: 70px; }

@media (max-width: 760px) {
  .move-row, .use-row { grid-template-columns: 1fr 1fr; }
  .move-row select { grid-column: 1 / -1; }
  .move-row [data-move-remove] { justify-self: end; }
  .dc-cover { display: none; }
  .progress-card { position: static; }
}

/* ============ Phase 5: reports ============ */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.report-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--ink); }
.report-card:hover { text-decoration: none; border-color: var(--teal-100); box-shadow: var(--shadow-lg); }
.rc-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--teal-50); color: var(--teal); display: inline-flex; align-items: center; justify-content: center; }
.eac-summary { padding: 24px; }
.eac-lines { margin: 0; }
.eac-lines > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-2); font-size: 15.5px; }
.eac-lines dt { color: var(--ink-2); }
.eac-lines dt .ur { display: inline; margin-left: 8px; }
.eac-lines dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.eac-gap { border-bottom: 0 !important; padding: 4px 0 !important; }
.eac-final { border-top: 2px solid var(--ink); border-bottom: 0 !important; font-size: 18px !important; }
.eac-final dd { font-size: 22px; color: var(--teal-700); }
.eac-overrun { margin-top: 8px; padding: 12px 14px !important; border-radius: 10px; border: 0 !important; }
.eac-overrun.is-over { background: var(--red-50); color: var(--red); }
.eac-overrun.is-under { background: var(--green-50); color: var(--green); }
.eac-overrun dt { color: inherit; font-weight: 600; }
.eac-overrun dd { font-size: 20px; }
.eac-overrun small { font-weight: 500; font-size: 13px; }
.w-eacbar { width: 22%; min-width: 140px; }
.eac-bar { position: relative; height: 10px; background: var(--line-2); border-radius: 999px; display: flex; overflow: visible; }
.eb-actual { background: var(--teal); border-radius: 999px 0 0 999px; height: 100%; }
.eb-more { background: repeating-linear-gradient(45deg, #9ED6D2, #9ED6D2 4px, #C8EAE7 4px, #C8EAE7 8px); height: 100%; border-radius: 0 999px 999px 0; }
.eb-budget { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 2px; }
.eac-table tr.is-over .eb-more { background: repeating-linear-gradient(45deg, #EBA29E, #EBA29E 4px, #F6CFCC 4px, #F6CFCC 8px); }
.legend { display: flex; gap: 14px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 8px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.lg-actual { background: var(--teal); } .lg-more { background: #9ED6D2; } .lg-budget { width: 2px !important; height: 12px !important; background: var(--ink); }
.watch-card { border-color: #F2C6C3; }
.watch-card .card-title .icon { color: var(--red); }
.month-chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; height: 220px; align-items: end; }
.mc-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.mc-bar { width: 100%; max-width: 44px; background: var(--teal); border-radius: 6px 6px 0 0; min-height: 2px; }
.mc-col.is-future .mc-bar { background: var(--line); }
.mc-val { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.mc-lbl { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.month-table td, .month-table th { white-space: nowrap; font-size: 13px; }

/* Printable statement */
.print-page { background: #E9EEEF; }
.print-toolbar { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 8px; padding: 10px 16px; background: rgba(255,255,255,.95); border-bottom: 1px solid var(--line); z-index: 5; }
.sheet-a4 { max-width: 210mm; margin: 20px auto; background: #fff; padding: 16mm 14mm; box-shadow: var(--shadow-lg); font-size: 12.5px; color: #111; }
.print-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--teal); margin-bottom: 14px; }
.print-head img { width: 150px; }
.print-head div { display: flex; flex-direction: column; text-align: right; font-size: 11.5px; color: #444; }
.print-head strong { font-size: 15px; color: #111; }
.print-title { font-size: 22px; margin: 0; }
.print-sub { color: #555; margin: 4px 0 12px; }
.print-section { margin-top: 16px; break-inside: avoid; }
.print-section h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-700); margin: 0 0 6px; }
.print-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.print-table { width: 100%; border-collapse: collapse; }
.print-table th, .print-table td { padding: 5px 6px; border-bottom: 1px solid #E3E8EA; text-align: left; vertical-align: top; }
.print-table thead th { font-size: 11px; color: #555; border-bottom: 1.5px solid #333; }
.print-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.print-table.kv th { color: #555; font-weight: 500; width: 45%; }
.print-table .grp td { font-weight: 700; background: #F4F7F7; }
.print-table tfoot th { border-top: 1.5px solid #333; border-bottom: 0; }
.print-table .strong-row th, .print-table .strong-row td { font-weight: 700; border-top: 1.5px solid #333; }
.print-foot { display: flex; justify-content: space-between; margin-top: 40px; color: #555; font-size: 11.5px; }
@media print {
  @page { size: A4; margin: 12mm; }
  .print-toolbar { display: none !important; }
  .print-page { background: #fff; }
  .sheet-a4 { margin: 0; padding: 0; box-shadow: none; max-width: none; }
  .content { padding: 0; }
  .page-head .head-actions, .back-link, .filters, .chips { display: none !important; }
  a { color: inherit; text-decoration: none; }
}
@media (max-width: 640px) {
  .month-chart { height: 160px; gap: 3px; }
  .mc-val { display: none; }
  .print-cols { grid-template-columns: 1fr; }
  .sheet-a4 { padding: 16px; margin: 0; }
}

@media print {
  .sidebar, .topbar, .tabs, .btn, .icon-btn, .foot, .alert { display: none !important; }
  .main { margin: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
.req { color: var(--red); font-weight: 700; }
.pe-bar .meter, .progress-mini .meter, .money-strip .meter { display: block; }
.money-strip .meter { margin-top: 4px; max-width: 120px; }
.print-table.kv4 th { width: 20%; }
.print-table.kv4 td { width: 30%; }
.print-table.kv td { font-variant-numeric: tabular-nums; }
/* Urdu on/off toggle (sidebar + phone top bar) */
.urdu-toggle { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; color: var(--muted); font: inherit; }
.urdu-toggle span { font-family: var(--font-ur); font-size: 13px; line-height: 1; padding-bottom: 3px; }
.urdu-toggle i { position: relative; width: 26px; height: 15px; border-radius: 999px; background: #CBD5D8; transition: background .15s; }
.urdu-toggle i::after { content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.urdu-toggle.is-on { color: var(--teal-700); border-color: var(--teal-100); background: var(--teal-50); }
.urdu-toggle.is-on i { background: var(--teal); }
.urdu-toggle.is-on i::after { transform: translateX(11px); }
.urdu-toggle:hover { border-color: var(--teal); }

/* Payments & cash tracking switched off (Settings) */
.no-payments .pay-only { display: none !important; }
.item-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-new-item { border-style: dashed; border-color: var(--teal-100); color: var(--teal-700); }
.btn-new-item:hover { border-color: var(--teal); background: var(--teal-50); }
