/* Nomad Mining Staff Portal */
:root {
  /* from the Nomad Mining logo */
  --brand: #294B3A;
  --brand-dark: #1E3A2C;
  --brand-ink: #1B3328;
  --brand-tint: #E8EFEB;
  --copper: #AD6E4A;
  --copper-light: #E3B08C;
  --sand: #F6F0EA;
  /* chart series (validated for colour-blind separation) */
  --rev: #0F7550;
  --exp: #D4925F;
  --ink: #1D2421;
  --ink-2: #4B5652;
  --muted: #7A8581;
  --line: #E3E6E4;
  --surface: #FFFFFF;
  --bg: #F6F7F5;
  --good: #1F7A4D; --good-bg: #E5F4EC;
  --warn: #8A5A00; --warn-bg: #FFF3D6;
  --bad: #A3271F;  --bad-bg: #FBE7E5;
  --info: #285E8A; --info-bg: #E6F0F8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,20,.06), 0 4px 16px rgba(16,24,20,.06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- brand / logo */
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-decoration: none; color: inherit; }
.brand img { display: block; height: auto; }
.brand .tag { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; font-weight: 600; opacity: .8; }
.login-hero .brand img { width: 190px; }
.login-card .brand img { width: 220px; }
.login-card .brand .tag { color: var(--copper); opacity: 1; }
.side .brand img { width: 150px; }
.side .brand .tag { color: var(--copper-light); }
.login-card .brand.mobile-only { display: none; }
@media (max-width: 860px) { .login-card .brand.mobile-only { display: flex; } }

/* ---------- login */
.login-page { min-height: 100%; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-ink) 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; inset: auto -10% -30% -10%; height: 60%; background:
  radial-gradient(ellipse at 30% 100%, rgba(173,110,74,.38), transparent 60%),
  radial-gradient(ellipse at 80% 100%, rgba(255,255,255,.08), transparent 55%); pointer-events: none; }
.login-hero h1 { font-size: 40px; line-height: 1.1; margin: 0 0 14px; font-weight: 700; letter-spacing: -.01em; max-width: 12em; }
.login-hero p { max-width: 30em; opacity: .85; font-size: 15px; margin: 0; }
.login-hero ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; position: relative; z-index: 1; }
.login-hero li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.login-hero li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--copper-light); flex: none; }
.login-hero .foot { font-size: 12px; opacity: .65; position: relative; z-index: 1; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin: 0 0 28px; }
.login-card .brand { margin-bottom: 36px; }
.login-card .copper-rule { width: 44px; height: 3px; border-radius: 2px; background: var(--copper); margin: 0 0 14px; }
@media (max-width: 860px) { .login-page { grid-template-columns: 1fr; } .login-hero { display: none; } }

/* ---------- forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--bad); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid #CDD3D0; border-radius: 8px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(41,75,58,.18); }
.input[readonly], .input:disabled { background: #F3F5F4; color: var(--ink-2); }
.input-sm { padding: 7px 10px; font-size: 13px; }
.prefix { position: relative; }
.prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.prefix > .input { padding-left: 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 10px 12px; border: 1px solid #CDD3D0; border-radius: 8px; }
.check-list label { font-weight: 400; display: flex; gap: 8px; align-items: center; color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s; }
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.block { width: 100%; padding: 12px; }
.btn.ghost { background: #fff; color: var(--ink); border-color: #CDD3D0; }
.btn.ghost:hover { background: #F3F5F4; }
.btn.danger { background: #fff; color: var(--bad); border-color: #E8BDB9; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ok { background: var(--good); }
.btn svg { width: 16px; height: 16px; }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert.error { background: var(--bad-bg); color: var(--bad); }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.success { background: var(--good-bg); color: var(--good); }

/* ---------- app shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100%; background: linear-gradient(to right, var(--brand-ink) 248px, var(--bg) 248px); }
.side { background: var(--brand-ink); color: #DCEBE5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { padding: 20px 20px 18px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.nav { padding: 10px 10px 20px; flex: 1; }
.nav h6 { margin: 16px 10px 6px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: rgba(220,235,229,.5); font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: inherit; text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; font-weight: 600; }
.nav a svg { width: 17px; height: 17px; opacity: .85; flex: none; }
.nav .badge { margin-left: auto; background: var(--copper-light); color: #3A1E0C; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 7px; }
.side .me { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; }
.side .me b { display: block; color: #fff; font-size: 13.5px; }
.side .me .row { display: flex; gap: 8px; margin-top: 10px; }
.side .me button, .side .me a { background: rgba(255,255,255,.08); border: 0; color: #fff; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; text-decoration: none; }
.side .me button:hover, .side .me a:hover { background: rgba(255,255,255,.16); }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 18px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; background: none; border: 0; padding: 4px; cursor: pointer; }
.content { padding: 24px 28px 48px; }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .side { position: fixed; z-index: 20; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .menu-btn { display: block; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 14px 16px; }
}

/* ---------- cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 14.5px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1200px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .g-3, .g-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
@media (max-width: 560px) { .g-4 { grid-template-columns: 1fr; } }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .value { font-size: 26px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .note { font-size: 12.5px; color: var(--ink-2); }
.kpi a.note { text-decoration: none; color: var(--rev); font-weight: 600; }
.mb { margin-bottom: 16px; }

/* ---------- tables */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar .input { width: auto; min-width: 140px; }
.toolbar .search { min-width: 220px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #FAFBFA; white-space: nowrap; position: sticky; top: 0; }
table.data th.num { text-align: right; }
table.data td.nw { white-space: nowrap; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data td { padding: 10px 12px; border-bottom: 1px solid #EEF0EF; vertical-align: top; }
table.data tbody tr.click { cursor: pointer; }
table.data tbody tr.click:hover { background: #F7FAF9; }
table.data tfoot td { font-weight: 700; background: #FAFBFA; border-top: 2px solid var(--line); }
table.data td.trunc.narrow { max-width: 200px; }
table.data td.trunc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.in { color: var(--good); } .out { color: var(--bad); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #EEF0EF; color: var(--ink-2); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad  { background: var(--bad-bg);  color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }

/* ---------- progress / budget */
.meter { height: 8px; background: #EDF0EE; border-radius: 4px; overflow: hidden; min-width: 90px; }
.meter > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.meter.warn > i { background: #D49A1F; }
.meter.bad > i { background: var(--bad); }

/* ---------- charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--font); fill: var(--muted); }
.chart .grid-line { stroke: #ECEFED; stroke-width: 1; }
.chart .axis { stroke: #CDD3D0; }
.chart .bar-rev { fill: var(--rev); }
.chart .bar-exp { fill: var(--exp); }
.chart .bar-one { fill: var(--brand); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover { fill: rgba(0,0,0,.04); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend i.rev { background: var(--rev); } .legend i.exp { background: var(--exp); }
.tip { position: fixed; pointer-events: none; background: #1D2421; color: #fff; padding: 8px 10px; border-radius: 6px; font-size: 12px; z-index: 50; box-shadow: var(--shadow); white-space: nowrap; }
.tip b { display: block; margin-bottom: 2px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.hbar .track { height: 10px; background: #EDF0EE; border-radius: 3px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid #EEF0EF; font-size: 13.5px; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }

/* ---------- money accounts */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.acct { display: flex; flex-direction: column; gap: 3px; padding: 14px 18px; border-right: 1px solid var(--line); text-decoration: none; color: inherit; min-width: 0; }
.acct:hover { background: #F7FAF8; }
.acct .prov { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--copper); }
.acct b { font-size: 19px; text-align: left; }
.acct .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct.total { background: #FAFBFA; border-right: 0; }
.acct.total .prov { color: var(--ink-2); }

/* ---------- attachments */
.attach label { display: flex; align-items: center; gap: 4px; }
.attach label svg { width: 15px; height: 15px; }
.files { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; }
.files li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid #EEF0EF; font-size: 13px; }
.files li:last-child { border-bottom: 0; }
.files li > svg { width: 16px; height: 16px; color: var(--copper); flex: none; }
.files .grow { flex: 1; min-width: 0; }
.files .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.files .fact { display: flex; gap: 6px; flex: none; }
.dropzone { margin-top: 8px; border: 1.5px dashed #C9D2CD; border-radius: 8px; padding: 14px; display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; justify-content: center; text-align: center; color: var(--ink-2); font-size: 13px; }
.dropzone > svg { width: 18px; height: 18px; color: var(--copper); }
.dropzone > .small { flex-basis: 100%; }
.dropzone.over { border-color: var(--brand); background: var(--brand-tint); }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline-flex; } }
.clip-count { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-2); font-weight: 600; }
.clip-count svg, th .clip, table.data th svg { width: 14px; height: 14px; vertical-align: -2px; }
td.files-cell { width: 54px; }

/* ---------- modal */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,20,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 30; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .mh { display: flex; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 16.5px; flex: 1; }
.modal .mh button { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .mb2 { padding: 20px 22px 6px; }
.modal .mf { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: #FAFBFA; border-radius: 0 0 12px 12px; }
.modal .mf .spacer { flex: 1; }
.meta-line { font-size: 12px; color: var(--muted); margin: -4px 0 14px; }
.secret { font: 600 18px ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; background: var(--sand); padding: 12px 14px; border-radius: 8px; letter-spacing: .04em; user-select: all; word-break: break-all; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 60; font-size: 13.5px; }
.toast.error { background: var(--bad); }

/* ---------- print */
@media print {
  .side, .topbar .actions, .toolbar, .menu-btn, .no-print { display: none !important; }
  .shell { display: block; background: none; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
  table.data th { position: static; }
}
