/* Yaran NGO – application styles. No external dependencies, works offline. */
:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #e6f4f2;
  --accent: #b45309;
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #64707d;
  --border: #e2e6ea;
  --border-strong: #cfd6dc;
  --sidebar: #0d2f2c;
  --sidebar-text: #b9cbc8;
  --ok: #157f3d;   --ok-bg: #e3f6ea;
  --warn: #9a5b00; --warn-bg: #fdf1d8;
  --danger: #b42318; --danger-bg: #fde7e5;
  --info: #1d5fd1; --info-bg: #e5eefc;
  --grey: #55606b; --grey-bg: #eef0f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: #14a394; display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 650; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--sidebar-text); }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7f9a96; padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px;
  color: var(--sidebar-text); font-size: 13.5px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(20, 163, 148, .22); color: #fff; }
.nav svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .85; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.topbar form { margin: 0; }
.menu-toggle { display: none; background: none; border: 0; padding: 4px; cursor: pointer; color: var(--text); }
.content { padding: 22px 24px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 2px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards & grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flush { padding: 0; }
.card.flush > .card-head { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; }
.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)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 1.35rem; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.highlight { border-color: #9fd6cf; background: linear-gradient(180deg, #f2fbf9, #fff); }
.stat a { color: inherit; }

/* ---------- definition lists ---------- */
.dl { display: grid; grid-template-columns: minmax(100px, 38%) 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; white-space: nowrap; }
.table tbody tr:hover { background: #fafcfc; }
.table tfoot td, .table tr.total td { font-weight: 650; background: #f7f9fa; }
.table tr.sub td { background: #fbfcfd; font-weight: 600; }
.table tr.cancelled td { color: var(--muted); text-decoration: line-through; }
.table tr.cancelled td.keep { text-decoration: none; }
.table .num { text-align: right; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 18px; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 18px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; font-size: 13.5px;
  font-weight: 550; border: 1px solid var(--border-strong); background: #fff; color: var(--text); cursor: pointer;
  line-height: 1.3; white-space: nowrap; font-family: inherit;
}
.btn:hover { background: #f5f7f8; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: #f1b8b2; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-link { background: none; border: 0; color: var(--primary); padding: 0; cursor: pointer; font: inherit; }
.btn svg { width: 15px; height: 15px; }
form.inline { display: inline; margin: 0; }

/* ---------- forms ---------- */
.form-section { margin-bottom: 22px; }
.form-section > h3 { font-size: .95rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 14px; color: var(--primary-dark); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: #3b4652; }
.field .help { font-size: 12px; color: var(--muted); }
.field .errors { color: var(--danger); font-size: 12.5px; margin: 0; padding: 0; list-style: none; }
.field.has-error .input { border-color: var(--danger); }
.field.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 20px; }
.field.check label { font-weight: 500; }
.input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 7px; font-size: 14px;
  background: #fff; color: var(--text); font-family: inherit;
}
.input:focus { outline: 2px solid #9fd6cf; border-color: var(--primary); }
textarea.input { resize: vertical; }
select.input { padding-right: 28px; }
.checkbox { width: 17px; height: 17px; accent-color: var(--primary); }
.choice-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.choice-list label, .field .choice-list label { font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.choice-list input { accent-color: var(--primary); margin-top: 3px; }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 6px; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.filters .input { width: auto; min-width: 150px; padding: 6px 9px; font-size: 13px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters label { font-size: 11.5px; color: var(--muted); display: block; }

/* ---------- messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: 13.5px; }
.alert-success { background: var(--ok-bg); border-color: #b5e3c5; color: #0f5d2c; }
.alert-error { background: var(--danger-bg); border-color: #f5c2bd; color: #8a1a12; }
.alert-info { background: var(--info-bg); border-color: #c4d7f7; color: #163f8c; }
.alert-warning { background: var(--warn-bg); border-color: #f1d9a6; color: #6e4200; }
.errorlist.nonfield { list-style: none; padding: 10px 14px; margin: 0 0 14px; border-radius: 8px; background: var(--danger-bg); color: #8a1a12; border: 1px solid #f5c2bd; }

/* ---------- misc components ---------- */
.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding: 8px 4px 0; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bars { flex: 1; display: flex; align-items: flex-end; gap: 4px; width: 100%; justify-content: center; }
.bar { width: 40%; max-width: 26px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.in { background: #14a394; }
.bar.out { background: #e8a33d; }
.bar-label { font-size: 11.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .in::before { background: #14a394; }
.legend .out::before { background: #e8a33d; }
.progress { height: 8px; background: var(--grey-bg); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.score { display: flex; align-items: center; gap: 14px; }
.score-num { font-size: 2rem; font-weight: 700; line-height: 1; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain li > strong:last-child, .list-plain li > .num:last-child { white-space: nowrap; }
.reasons { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline li.status::before { background: var(--accent); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.doc { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fafbfc; font-size: 12.5px; }
.doc .thumb { height: 110px; display: grid; place-items: center; background: #eef2f3; color: var(--muted); font-weight: 600; }
.doc .thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc .info { padding: 8px; }
.callout { padding: 12px 14px; border-radius: 8px; background: var(--primary-soft); border: 1px solid #bfe3dd; font-size: 13.5px; margin-bottom: 16px; }
.callout.warn { background: var(--warn-bg); border-color: #f1d9a6; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 18px; font-size: 13px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #0d2f2c, #134e48); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }

/* ---------- printable documents ---------- */
.doc-toolbar { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.paper { background: #fff; max-width: 820px; margin: 0 auto 24px; padding: 34px 40px; border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; }
.paper.half { max-width: 820px; }
.paper-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid var(--primary); padding-bottom: 14px; margin-bottom: 18px; }
.paper-head .org { display: flex; gap: 12px; align-items: center; }
.paper-head .org img { width: 56px; height: 56px; object-fit: contain; }
.paper-head .org-name { font-size: 1.35rem; font-weight: 700; color: var(--primary-dark); }
.paper-head .org-meta { font-size: 12px; color: var(--muted); line-height: 1.45; }
.paper-title { text-align: right; }
.paper-title .t { font-size: 1.05rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.paper-title .n { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; margin-top: 4px; }
.paper .rows { display: grid; grid-template-columns: 180px 1fr; gap: 9px 14px; font-size: 14px; }
.paper .rows .k { color: var(--muted); }
.paper .rows .v { border-bottom: 1px dotted var(--border-strong); padding-bottom: 2px; }
.amount-box { display: flex; align-items: center; gap: 16px; margin: 20px 0; padding: 14px 16px; border: 1.5px solid var(--primary); border-radius: 8px; background: #f6fbfa; }
.amount-box .fig { font-size: 1.5rem; font-weight: 700; white-space: nowrap; }
.amount-box .words { font-size: 13.5px; font-style: italic; }
.signatures { display: flex; justify-content: space-between; gap: 30px; margin-top: 44px; font-size: 12.5px; }
.signatures div { flex: 1; border-top: 1px solid #444; padding-top: 6px; text-align: center; color: var(--muted); }
.thumb-box { width: 110px; height: 80px; border: 1px dashed #888; display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.paper-foot { margin-top: 22px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); text-align: center; }
.stamp { position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 4.2rem; font-weight: 800; color: rgba(180, 35, 24, .18); border: 6px solid rgba(180, 35, 24, .18); padding: 4px 24px; border-radius: 12px; pointer-events: none; letter-spacing: .08em; }
.paper table.table th { background: #f3f6f7; }
.paper .section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary-dark); margin: 18px 0 8px; }
.blank-line { border-bottom: 1px solid #999; min-height: 22px; }
.page-break { break-after: page; page-break-after: always; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; box-shadow: 4px 0 20px rgba(0,0,0,.25); }
  body.nav-open .sidebar { left: 0; }
  body.nav-open .scrim { display: block; }
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px 16px 40px; }
  .topbar { padding: 10px 16px; }
  .topbar .user .hide-sm { display: none; }
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .dl { grid-template-columns: 130px 1fr; }
  .paper { padding: 20px 16px; }
  .paper .rows { grid-template-columns: 120px 1fr; }
  .paper-head { flex-direction: column; }
  .paper-title { text-align: left; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12.5px; }
  .sidebar, .topbar, .no-print, .messages, .doc-toolbar { display: none !important; }
  .content { padding: 0; max-width: none; }
  .paper { border: 0; box-shadow: none; margin: 0 auto; padding: 0; max-width: none; }
  .paper + .paper { margin-top: 10mm; }
  .card { box-shadow: none; break-inside: avoid; }
  a { color: inherit; }
  .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .amount-box, .stamp, .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
