/* Zak Staging Limited — UI theme (matches logo: deep green, warm gold, ink black) */
:root {
  --green-900: #12301f;
  --green-800: #1d4a36;
  --green-700: #245c43;
  --green-50: #eef5f1;
  --gold: #b08d57;
  --gold-light: #f4ede1;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e6e4df;
  --bg: #f7f6f3;
  --card: #ffffff;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn: #9a6700;
  --warn-bg: #fff6e0;
  --info: #1f5fa8;
  --info-bg: #e9f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--green-900); color: #dfe9e3; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.brand img { width: 108px; height: 108px; border-radius: 50%; background: #fff; padding: 4px; box-shadow: 0 0 0 2px var(--gold); }
.brand span { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: #c9b48e; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #dfe9e3; padding: 9px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active { background: var(--green-700); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.sidebar-foot form { margin: 6px 0 0; }
.sidebar-foot button { background: none; border: 1px solid rgba(255,255,255,.18); color: #dfe9e3; border-radius: 6px; padding: 6px 10px; cursor: pointer; width: 100%; }
.sidebar-foot button:hover { background: rgba(255,255,255,.06); }
.main { padding: 28px 36px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mobile-bar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .mobile-bar { display: flex; align-items: center; gap: 12px; background: var(--green-900); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .mobile-bar img { width: 34px; height: 34px; border-radius: 50%; background: #fff; }
  .mobile-bar button { background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; margin-left: auto; }
  .main { padding: 20px 16px 60px; }
}

/* ---------- Cards / stats ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--green-700); }
.stat.gold::before { background: var(--gold); }
.stat.warn::before { background: #d4a017; }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.55rem; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.section { margin-top: 22px; }

/* ---------- Chart ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar-rev { fill: var(--green-700); }
.chart .bar-exp { fill: var(--gold); }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .gridline { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .rev { background: var(--green-700); }
.legend .exp { background: var(--gold); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: #fbfaf8; }
.table tbody tr:hover { background: #fbfaf7; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 650; background: #fbfaf8; border-bottom: 0; }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; text-transform: capitalize; }
.badge-draft { background: #eef0f3; color: #475467; }
.badge-sent { background: var(--info-bg); color: var(--info); }
.badge-paid { background: var(--green-50); color: var(--green-700); }
.badge-void { background: #f2f2f2; color: #8a8a8a; text-decoration: line-through; }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550;
  font-size: .9rem; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1.3;
}
.btn:hover { background: #f6f5f2; text-decoration: none; }
.btn-primary { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn-gold:hover { background: #9c7a47; }
.btn-danger { color: var(--danger); border-color: #f1c4bf; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-link { background: none; border: 0; color: var(--green-700); padding: 0; cursor: pointer; font: inherit; }
form.inline { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 5px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=tel], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #d5d3cd; border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(36, 92, 67, .15); }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--green-700); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filters .field { min-width: 140px; }
.filters select, .filters input { padding: 7px 10px; }

/* Line items editor */
.items-table td { padding: 6px 6px; border-bottom: 0; vertical-align: top; }
.items-table th { padding: 8px 6px; }
.items-table .col-qty { width: 100px; }
.items-table .col-rate { width: 150px; }
.items-table .col-amt { width: 130px; }
.items-table .col-del { width: 44px; }
.items-table .amt { padding-top: 9px; display: block; text-align: right; font-variant-numeric: tabular-nums; }
.remove-row { background: none; border: 0; color: var(--muted); font-size: 1.25rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.remove-row:hover { color: var(--danger); background: var(--danger-bg); }

.totals { margin-left: auto; width: 100%; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 10px; font-weight: 700; font-size: 1.1rem; }

.split-preview { background: var(--gold-light); border: 1px solid #e8dcc6; border-radius: 8px; padding: 14px 16px; }
.split-preview div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; padding: 2px 0; }
.split-preview .em { font-weight: 650; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: .92rem; border: 1px solid transparent; }
.alert-success { background: var(--green-50); color: var(--green-800); border-color: #cfe3d8; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #f5c6c0; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Invoice preview ---------- */
.invoice-doc { padding: 40px 44px; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--gold); }
.inv-head img { width: 100px; height: 100px; }
.inv-head .title { font-size: 1.9rem; font-weight: 700; color: var(--green-800); letter-spacing: .08em; text-align: right; }
.inv-head .biz { text-align: right; font-size: .85rem; color: var(--muted); white-space: pre-line; }
.inv-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 22px 0; }
.inv-label { font-size: .72rem; font-weight: 700; letter-spacing: .1em; color: var(--gold); text-transform: uppercase; margin-bottom: 4px; }
.inv-meta dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; justify-self: end; min-width: 260px; }
.inv-meta dt { color: var(--muted); font-size: .88rem; }
.inv-meta dd { margin: 0; text-align: right; font-weight: 600; }
.pre { white-space: pre-line; }
.inv-items th { background: var(--green-800); color: #fff; }
.inv-terms { margin-top: 26px; font-size: .88rem; color: #374151; }
@media (max-width: 700px) { .invoice-doc { padding: 20px; } .inv-meta { grid-template-columns: 1fr; } .inv-meta dl { justify-self: stretch; } }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #2b6a4e 0%, transparent 60%), linear-gradient(160deg, var(--green-900), #0b1d13); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 34px 32px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-card .logo { display: block; width: 150px; height: 150px; margin: 0 auto 6px; }
.login-card h1 { text-align: center; font-size: 1.25rem; margin-bottom: 4px; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: .9rem; }
.login-card .btn { width: 100%; padding: 11px; font-size: 1rem; }
.login-foot { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 18px; }

.danger-zone { border-color: #f1c4bf; }

/* ---------- v2 additions ---------- */
.badge-partial { background: #fff3d6; color: #8a5a00; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f2dca6; }
.code-tag { display: inline-block; font-weight: 650; background: var(--gold-light); color: #6f5428; border: 1px solid #e8dcc6; border-radius: 6px; padding: 1px 8px; font-size: .85rem; }
.preview-number { font-weight: 650; font-size: 1.05rem; padding: 8px 0; color: var(--green-800); font-variant-numeric: tabular-nums; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 16px; margin: 0; }
.fieldset legend { font-weight: 650; padding: 0 6px; color: var(--green-800); }
.push-right { margin-left: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.upload-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.upload-btn { position: relative; cursor: pointer; }
.upload-btn:focus-within { box-shadow: 0 0 0 3px rgba(36, 92, 67, .25); }
.upload-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: .85rem; color: var(--green-700); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 12px; }
.thumb { border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fff; }
.thumb img, .thumb .file-icon { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: 6px; background: #f3f1ec; }
.thumb .file-icon { display: grid; place-items: center; font-weight: 700; color: var(--danger); letter-spacing: .1em; }
.thumb-name { font-size: .78rem; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.danger-link, .btn-link.danger-link { color: var(--danger); }
.timeline { list-style: none; margin: 0; padding: 6px 22px 14px; max-height: 360px; overflow: auto; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.timeline li:last-child { border-bottom: 0; }
.invoice-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 1100px) { .invoice-layout { grid-template-columns: 1fr; } }
.payment-form { border-top: 1px solid var(--line); background: #fbfaf8; border-radius: 0 0 var(--radius) var(--radius); }
.row-warn td { background: #fff8f6; }
.role-tag { display: inline-block; margin-left: 4px; font-size: .7rem; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.12); color: #e7d7b8; }
.sidebar-foot a.me { color: #fff; }
.attach-note { background: var(--green-50); border: 1px solid #cfe3d8; color: var(--green-800); border-radius: 8px; padding: 10px 14px; font-size: .9rem; }
.folder { color: inherit; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .15s, transform .15s; }
.folder:hover { text-decoration: none; box-shadow: 0 6px 18px rgba(16,24,40,.08); transform: translateY(-1px); }
.folder-top { display: flex; justify-content: space-between; align-items: center; }
.folder-icon { font-size: 1.6rem; }
.folder-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 4px; }
.folder-stats div { background: #fbfaf8; border-radius: 6px; padding: 6px 8px; font-size: .78rem; color: var(--muted); display: flex; flex-direction: column; }
.folder-stats strong { color: var(--ink); font-size: .95rem; }
code { background: #f1efe9; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
button[disabled] { opacity: .5; cursor: not-allowed; }
.card-pad > h2 { margin-bottom: 12px; }
.thumb img { object-fit: contain; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--green-800); border-bottom-color: var(--gold); }
.pay-toggle { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; }
.highlight-card { background: var(--gold-light); border-color: #e8dcc6; }
.fx-box { margin-top: 18px; background: #eef4fb; border: 1px solid #cfe0f3; color: #1f3f63; border-radius: 8px; padding: 10px 14px; font-size: .88rem; }
