/* ==========================================================================
   NM Department of Cultural Affairs — NAGPRA Consultation Tracking Platform
   Prototype theme. Visual direction: premium, calm, data-focused.
   Muted base, vibrant accents.
   ========================================================================== */

:root {
  /* Palette */
  --primary: #0D7A7F;        /* Deep Turquoise */
  --primary-dark: #0a5f63;
  --primary-soft: #e3f0f0;
  --accent: #B66A45;         /* Adobe Clay */
  --accent-soft: #f3e4db;
  --sand: #E8DDCF;           /* Warm Sand */
  --sage: #78916D;           /* Sage Green */
  --sky: #DCEEF5;            /* Sky Blue */
  --sky-deep: #6ea8c4;
  --bg: #FAF8F5;             /* Warm White */
  --card: #FFFFFF;
  --text: #2B2B2B;           /* Charcoal */
  --muted: #7a756e;
  --border: #E6E6E6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(43, 43, 43, 0.04), 0 1px 3px rgba(43, 43, 43, 0.06);
  --shadow-md: 0 4px 14px rgba(43, 43, 43, 0.06), 0 1px 3px rgba(43, 43, 43, 0.05);
  --gap: 22px;
  --maxw: 1340px;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 76px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand .titles { line-height: 1.15; }
.brand .titles .t1 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.brand .titles .t2 { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }

/* ---------- Module nav ---------- */
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; transition: background .12s ease, color .12s ease;
}
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a.on { color: var(--primary-dark); background: var(--primary-soft); }

/* ---------- Page heading ---------- */
.page-head { padding: 34px 0 10px; }
.page-head h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; max-width: 720px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb b { color: var(--text); }

/* ---------- Entity profile head ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); font-weight: 600; margin-bottom: 14px; }
.back-link:hover { color: var(--primary-dark); }
.entity-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.entity-title h1 { margin: 0; }
.entity-title .tag { font-size: 12px; padding: 4px 11px; }
.desc { margin: 12px 0 0; color: var(--muted); font-size: 15px; max-width: 820px; line-height: 1.6; }

/* ---------- Status badges ---------- */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.status.notstarted { background: var(--sand); color: #6b5d4d; }
.status.notstarted::before { background: #a99878; }
.status.inprogress { background: var(--primary-soft); color: var(--primary-dark); }
.status.inprogress::before { background: var(--primary); }
.status.completed { background: #e7efe2; color: #4d6340; }
.status.completed::before { background: var(--sage); }

/* ---------- Section ---------- */
.section { padding: 22px 0; }
.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 14px;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.panel h3 { margin: 0 0 2px; font-size: 15.5px; font-weight: 700; }
.panel .hint { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }

/* ---------- Detail key/value grid ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px 32px; }
.kv .k { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.kv .v { font-size: 15px; font-weight: 600; }
.kv .v a { color: var(--primary); }
.kv .v a:hover { color: var(--primary-dark); text-decoration: underline; }
.kv .v.mono { font-variant-numeric: tabular-nums; }

/* ---------- Count cards ---------- */
.kpi-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(4, 1fr);
}
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.kpi .value { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin-top: 9px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.span2 { grid-column: span 2; }
.kpi .value.big { font-size: 36px; }

/* ---------- Data grid ---------- */
.table-tools {
  display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 220px; max-width: 360px;
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px;
}
.search input { border: 0; outline: 0; background: transparent; font-size: 14px; width: 100%; color: var(--text); }
.search svg { flex: none; color: var(--muted); }
.count-pill { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.table-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid thead th {
  text-align: left; padding: 14px 18px; font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  background: #faf9f7; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.grid thead th .arrow { opacity: 0; margin-left: 5px; font-size: 10px; }
table.grid thead th.sorted .arrow { opacity: 1; color: var(--primary); }
table.grid tbody td { padding: 13px 18px; border-bottom: 1px solid #f1efec; }
table.grid tbody td:first-child { font-weight: 600; }
table.grid tbody tr { cursor: pointer; transition: background .12s ease; }
table.grid tbody tr:hover { background: var(--primary-soft); }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid th.right, table.grid td.right { text-align: right; }
.entity-cell { display: flex; align-items: center; gap: 11px; }
.tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em; padding: 2px 8px;
  border-radius: 6px; background: var(--sand); color: #6b5d4d;
}
.tag.info { background: var(--sky); color: #3d6275; }
.num { font-variant-numeric: tabular-nums; }
.muted-num { color: var(--muted); }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }

.cell-sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.row-inactive { opacity: .55; }
.tag.primary-tag { background: var(--primary-soft); color: var(--primary-dark); }
.tag.secondary-tag { background: var(--sky); color: #3d6275; }
td.actions { white-space: nowrap; }

a.link { color: var(--primary); font-weight: 600; }
a.link:hover { color: var(--primary-dark); text-decoration: underline; }

/* ---------- Initiate consultation bar ---------- */
.initiate-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap; margin-top: 16px; padding: 16px 20px;
  background: var(--primary-soft); border: 1px solid #cfe2e2; border-radius: var(--radius);
}
.initiate-bar .hint { margin: 0; font-size: 12.5px; color: var(--primary-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--primary); border-color: var(--primary); }

/* ---------- Tribe picker ---------- */
.picker-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.picker-tools .search { background: var(--bg); }
.picker-list {
  max-height: 46vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
}
.pick-row {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--primary-soft); }
.pick-row input { accent-color: var(--primary); width: 16px; height: 16px; margin-top: 2px; flex: none; }
.pick-main { font-size: 14px; font-weight: 600; }
.pick-main .cell-sub { font-weight: 400; }

/* ---------- Mailing list ---------- */
.mail-tribe { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.mail-tribe:last-child { border-bottom: 0; }
.mail-tribe-name {
  font-size: 13px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--primary-dark); margin-bottom: 10px;
}
.mail-people { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.mail-person {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 13.5px; line-height: 1.5;
}
.mp-name { font-weight: 700; }
.mp-title { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.mp-addr { font-size: 13px; }
.mp-email { font-size: 13px; color: var(--primary); margin-top: 4px; word-break: break-all; }
.mail-none { font-size: 13px; color: var(--muted); font-style: italic; }
@media (max-width: 640px) { .mail-people { grid-template-columns: 1fr; } }

/* Printing a mailing list should give the list, not the whole application. */
@media print {
  .topbar, main, .modal-actions, .picker-tools, .modal-card h3 + .hint { display: none !important; }
  .modal { position: static; display: none; background: none; padding: 0; overflow: visible; }
  .modal.open { display: block; }
  .modal-card, .modal-card.wide { max-width: none; box-shadow: none; padding: 0; }
  .picker-list { max-height: none; overflow: visible; border: 0; background: none; }
  .mail-person { break-inside: avoid; }
}

/* ---------- Comments ---------- */
.comments { list-style: none; margin: 0 0 14px; padding: 0; }
.comment { padding: 12px 0; border-bottom: 1px solid #f1efec; }
.comment:last-child { border-bottom: 0; }
.comment-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.comment-user { font-size: 13.5px; font-weight: 700; }
.comment-ts { font-size: 12px; color: var(--muted); }
.comment-head .btn-mini { margin-left: auto; }
.comment-body { font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.comment-add { display: flex; gap: 12px; align-items: flex-start; }
.comment-add textarea {
  flex: 1; font-family: inherit; font-size: 14px; color: var(--text); line-height: 1.5;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none; resize: vertical;
}
.comment-add textarea:focus { border-color: var(--primary); background: var(--card); }

/* ---------- Audit history ---------- */
.audit { list-style: none; margin: 0; padding: 0; }
.audit-item {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid #f1efec; font-size: 13.5px;
}
.audit-item:last-child { border-bottom: 0; }
.audit-ts { font-size: 12px; color: var(--muted); min-width: 118px; }
.audit-action { flex: 1; min-width: 220px; }
.audit-user { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Alerts / reminders ---------- */
.alert {
  margin-top: 18px; padding: 13px 18px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid #e3c6b4; color: #7d4527;
  font-size: 13.5px; line-height: 1.55;
}
.alert.soft {
  background: var(--sand); border-color: #dbcbb6; color: #6b5d4d; margin: 0 0 16px;
}
.overdue { color: var(--accent); font-weight: 600; }

/* ---------- Segmented toggle ---------- */
.toggle { display: inline-flex; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.toggle button {
  border: 0; background: transparent; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted); padding: 7px 15px; border-radius: 999px; cursor: pointer;
}
.toggle button.on { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------- Consultation preferences ---------- */
.prefs-panel { border-left: 4px solid var(--accent); }
.prefs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 28px; }
.pref .k {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px;
}
.pref .v { font-size: 14px; font-weight: 600; line-height: 1.5; }
.pref .v.unset { color: var(--accent); font-weight: 500; font-style: italic; }

.status-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 16px 20px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.status-bar .hint { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------- Action items ---------- */
.action-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid #f1efec; font-size: 14px; cursor: pointer;
}
.action-item:last-child { border-bottom: 0; }
.action-item input { accent-color: var(--primary); width: 16px; height: 16px; margin-top: 2px; flex: none; }
.action-item .act-main { flex: 1; font-weight: 600; }
.action-item.done .act-main { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.pill-open {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); padding: 2px 9px; border-radius: 999px;
}
.tag.warn { background: var(--accent-soft); color: #8a4f2e; }
.btn-mini.go { color: var(--primary-dark); border-color: var(--primary); background: var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--primary); background: var(--primary); color: #fff;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn.danger, .btn.ghost.danger:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost.danger { color: var(--accent); background: var(--card); border-color: var(--border); }

.btn-mini {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  padding: 4px 10px; border-radius: 7px; cursor: pointer; margin-left: 5px;
}
.btn-mini:hover { color: var(--primary-dark); border-color: var(--primary); background: var(--primary-soft); }
.btn-mini.danger:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Form controls ---------- */
.select {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 14px; cursor: pointer;
}
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--primary); width: 15px; height: 15px; }

.field { margin-bottom: 14px; flex: 1; }
.field label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); background: var(--card);
}
.field textarea { resize: vertical; line-height: 1.5; }
.field-row { display: flex; gap: 14px; }

/* ---------- Modal ---------- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(43, 43, 43, .38); padding: 40px 20px; overflow-y: auto;
}
.modal.open { display: block; }
.modal-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-md);
  max-width: 460px; margin: 0 auto; padding: 24px 26px;
}
.modal-card.wide { max-width: 620px; }
.modal-card h3 { margin: 0 0 18px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

main { padding-bottom: 50px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi.span2 { grid-column: span 2; }
}
@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi.span2 { grid-column: span 1; }
  .detail-grid { grid-template-columns: 1fr; }
  .brand .titles .t2 { display: none; }
}
