/* ------------------------------------------------------------------
   Finance Document — shared stylesheet for the public page and the
   staff page.

   The look is deliberately plain: a document library is something people
   scan, not something they admire. Everything here serves that — one
   accent colour, generous white space, no gradients, no shadows beyond a
   hairline, and type sizes that stay readable on a phone held one-handed
   at a counter.
   ------------------------------------------------------------------ */

:root {
  --bg:         #f5f7fa;
  --surface:    #ffffff;
  --surface-2:  #f0f3f7;
  --border:     #dfe4ea;
  --border-2:   #c9d1da;
  --text:       #131a23;
  --muted:      #5c6773;
  --muted-2:    #8a949f;

  --accent:      #0f4c81;
  --accent-dark: #0b3a63;
  --accent-soft: #e7eff7;

  --danger:      #b42318;
  --danger-soft: #fdeceb;
  --ok:          #15803d;
  --ok-soft:     #e8f6ed;

  --radius:   10px;
  --radius-s: 6px;
  --gap:      16px;
  --maxw:     1080px;

  --shadow: 0 1px 2px rgba(19, 26, 35, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }

/* Focus is never removed, only replaced — people navigate these forms
   with the keyboard. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 18px;
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.mark {
  width: 40px; height: 40px;
  flex: none;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
}

.site-title { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.2px; }
.site-sub   { margin: 1px 0 0; font-size: 13px; color: var(--muted); }
.header-spacer { flex: 1 1 auto; }

/* ---------- generic controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger { color: var(--danger); border-color: #e8c3bf; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { padding: 6px 11px; font-size: 13px; }

input[type=text], input[type=search], input[type=email],
input[type=password], input[type=number], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 74px; }

label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.hint  { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

/* ---------- toolbar (search + filter) ---------- */

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 22px 0 14px;
}
.toolbar .search { flex: 1 1 260px; }
.toolbar .filter { flex: 0 1 230px; }

.result-line {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ---------- category groups ---------- */

.cat {
  margin-bottom: 26px;
}
.cat-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.cat-name  { margin: 0; font-size: 15px; font-weight: 650; }
.cat-count {
  font-size: 12px; color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 9px;
}
.cat-desc { margin: 0; font-size: 13px; color: var(--muted); flex: 1 1 100%; }

/* ---------- document rows ---------- */

.doc-list { display: grid; gap: 10px; }

.doc {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.doc-body { flex: 1 1 auto; min-width: 0; }
.doc-title { margin: 0; font-size: 15px; font-weight: 600; }
.doc-desc  { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.doc-meta  {
  margin-top: 7px;
  font-size: 12.5px;
  color: var(--muted-2);
  display: flex; gap: 6px; flex-wrap: wrap;
}
.doc-meta span:not(:last-child)::after { content: "·"; margin-left: 6px; }

.doc-actions { display: flex; gap: 8px; flex: none; align-items: center; flex-wrap: wrap; }

/* File-type chip. The colour is a quick visual sort, not information on
   its own — the extension is always spelled out inside it. */
.ftype {
  flex: none;
  width: 46px; height: 46px;
  border-radius: var(--radius-s);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  text-transform: uppercase;
  overflow: hidden;
}
.ft-pdf   { background: #fdecea; color: #b42318; border-color: #f6cfca; }
.ft-doc   { background: #e8f0fb; color: #12509c; border-color: #cbdcf3; }
.ft-xls   { background: #e7f6ec; color: #15803d; border-color: #c7e8d3; }
.ft-ppt   { background: #fdf0e6; color: #b45309; border-color: #f5ddc4; }
.ft-img   { background: #f1ecfb; color: #6d3bce; border-color: #ddd2f5; }
.ft-zip   { background: #eceff2; color: #475467; border-color: #d9dee4; }

/* ---------- notices ---------- */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
}

.note {
  padding: 10px 13px;
  border-radius: var(--radius-s);
  font-size: 13.5px;
  margin-bottom: 14px;
}
.note-err { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0c8c3; }
.note-ok  { background: var(--ok-soft);     color: var(--ok);     border: 1px solid #c6e6d2; }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 40px;
  padding: 22px 0 34px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.site-footer .wrap { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }

/* ---------- admin ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel h2 { margin: 0 0 4px; font-size: 16px; font-weight: 650; }
.panel .panel-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }

.login-wrap { max-width: 380px; margin: 60px auto; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.tabs { display: flex; gap: 8px; margin: 22px 0 18px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px;
  border: 1px solid var(--border-2);
  border-radius: 20px;
  background: var(--surface);
  font: inherit; font-size: 13.5px; font-weight: 550;
  cursor: pointer;
}
.tab[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th {
  text-align: left; font-size: 12px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
table.list td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }

/* ---------- dialog ---------- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  box-shadow: 0 16px 48px rgba(19, 26, 35, .18);
}
dialog::backdrop { background: rgba(19, 26, 35, .42); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dlg-head h3 { margin: 0; font-size: 16px; }
.dlg-body { padding: 18px 20px; max-height: 62vh; overflow: auto; }
.dlg-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- phone ---------- */

@media (max-width: 640px) {
  .doc { flex-wrap: wrap; }
  .doc-actions { width: 100%; }
  .doc-actions .btn { flex: 1 1 auto; }
  .grid-2 { grid-template-columns: 1fr; }
  table.list thead { display: none; }
  table.list td { display: block; border: 0; padding: 3px 0; }
  table.list tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); }
}
