:root {
  --ink: #1f1f1f;
  --muted: #5d5a55;
  --rule: #d9d3c7;
  --paper: #ffffff;
  --page: #f4f1eb;
  --charcoal: #2b2b2b;
  --slate: #3d3d3d;
  --gold: #a88547;
  --gold-soft: #e9dfcb;
  --green: #1a5632;
  --red: #8c2f2b;

  --stage-dail: #2f6b3f;
  --stage-seanad: #2f5a85;
  --stage-delayed: #7a6a5c;
  --stage-awaiting: #a8742f;
  --stage-promulgated: #5d3f6b;
  --stage-refused: #8c2f2b;
  --stage-submitted: #6b6b6b;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--page);
}

h1, h2, h3, h4 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: normal;
  color: var(--ink);
  margin: 0 0 0.5rem;
  line-height: 1.25;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }

a { color: var(--green); }
a:hover { color: var(--charcoal); }

.hidden { display: none !important; }

.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Masthead */
.masthead {
  background: var(--charcoal);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.wordmark {
  color: #fff;
  text-decoration: none;
  display: block;
}

.wordmark:hover { color: #fff; }

.wordmark-ga {
  display: block;
  font-family: Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}

.wordmark-en {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #cfc6b4;
}

.masthead-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.85rem;
}

.masthead-links a {
  color: #cfc6b4;
  text-decoration: none;
}

.masthead-links a:hover { color: #fff; text-decoration: underline; }

/* Primary nav */
.primary-nav {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
}

.primary-nav a {
  display: block;
  padding: 0.85rem 1rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
}

.primary-nav li:first-child a { padding-left: 0; }

.primary-nav a:hover { border-bottom-color: var(--rule); }

.primary-nav a[aria-current="page"] {
  border-bottom-color: var(--gold);
  font-weight: 600;
}

/* Page heading */
.page-head {
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 1.5rem 0 1.25rem;
}

.crumbs {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.crumbs a { color: var(--muted); }

.page-head p.lede {
  color: var(--muted);
  max-width: 720px;
  margin: 0;
}

main { padding: 2rem 0 3rem; }

/* Panels */
.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel > h2:first-child,
.panel > h3:first-child { margin-top: 0; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.panel-head h2, .panel-head h3 { margin: 0; }

.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}

.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.small { font-size: 0.85rem; }
.muted { color: var(--muted); }

/* Link lists */
.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.link-list li {
  border-top: 1px solid var(--rule);
  padding: 0.7rem 0;
}

.link-list li:first-child { border-top: 0; padding-top: 0; }

.link-list a { font-weight: 600; text-decoration: none; }
.link-list a:hover { text-decoration: underline; }
.link-list span { display: block; font-size: 0.88rem; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-block;
  font: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--charcoal);
  background: var(--charcoal);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  border-radius: 2px;
}

.btn:hover { background: #000; color: #fff; }

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: #b8b1a3;
}

.btn-secondary:hover { background: var(--page); color: var(--ink); }

.btn-danger {
  background: var(--paper);
  color: var(--red);
  border-color: var(--red);
}

.btn-danger:hover { background: var(--red); color: #fff; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Forms */
.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.field .hint {
  display: block;
  font-weight: normal;
  font-size: 0.82rem;
  color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #b8b1a3;
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 120px; resize: vertical; }

input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
}

legend {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.radio-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.radio-row label { font-weight: normal; display: flex; gap: 0.35rem; align-items: center; }

.form-msg {
  font-size: 0.9rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

.form-msg.error { color: var(--red); }
.form-msg.ok { color: var(--green); }

/* Notice */
.notice {
  border-left: 4px solid var(--gold);
  background: #fbf8f2;
  padding: 0.85rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.93rem;
}

.notice p:last-child { margin-bottom: 0; }

/* Tables */
.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--paper);
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

table.data th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid var(--charcoal);
  white-space: nowrap;
}

table.data tbody tr:hover { background: #faf8f4; }

table.data td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }

.row-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--green);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.row-link:hover { color: var(--charcoal); }

.empty {
  padding: 1.5rem 0.75rem;
  color: var(--muted);
  font-style: italic;
}

/* Stage label */
.stage {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.stage::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  background: var(--stage-submitted);
  display: inline-block;
}

.stage-dail::before { background: var(--stage-dail); }
.stage-seanad::before { background: var(--stage-seanad); }
.stage-delayed::before { background: var(--stage-delayed); }
.stage-finalisation::before { background: var(--gold); }
.stage-awaiting::before { background: var(--stage-awaiting); }
.stage-promulgated::before { background: var(--stage-promulgated); }
.stage-refused::before,
.stage-rejected::before { background: var(--stage-refused); }
.stage-returned::before { background: var(--gold); }

/* Filter bar */
.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filters .field { margin: 0; }
.filters input[type="search"] { min-width: 240px; }

.stage-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1rem;
}

.stage-tabs button {
  font: inherit;
  font-size: 0.9rem;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  color: var(--muted);
}

.stage-tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

.stage-tabs .count { color: var(--muted); font-weight: normal; }

/* Dialog */
dialog {
  border: 1px solid var(--rule);
  padding: 0;
  max-width: 680px;
  width: calc(100% - 2rem);
  border-radius: 2px;
}

dialog::backdrop { background: rgba(20, 20, 20, 0.55); }

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.dialog-head h2 { margin: 0; font-size: 1.3rem; }

.dialog-close {
  background: none;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem;
}

.dialog-body { padding: 1.25rem 1.5rem 1.5rem; }

dl.facts {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.45rem 1rem;
  margin: 0 0 1.25rem;
  font-size: 0.93rem;
}

dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.notes {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.92rem;
}

.notes li {
  border-left: 3px solid var(--rule);
  padding: 0.25rem 0 0.25rem 0.75rem;
  margin-bottom: 0.6rem;
}

.notes time { display: block; font-size: 0.8rem; color: var(--muted); }

.prewrap { white-space: pre-wrap; }

/* Attendance register */
.attendance-main .wrap { max-width: 1500px; }
.attendance-panel { border-top: 4px solid var(--gold); padding: 1.25rem; }
.sheet-kicker {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.sheet-scroll {
  overflow: auto;
  max-height: 72vh;
  border: 1px solid var(--rule);
  background: var(--paper);
}

.attendance-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
  background: var(--paper);
}

.attendance-table th,
.attendance-table td {
  padding: 0.55rem 0.65rem;
  border-right: 1px solid #e7e2d9;
  border-bottom: 1px solid #e7e2d9;
  vertical-align: middle;
}

.attendance-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f0ece4;
  color: #45423c;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.attendance-table .att-identity {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--paper);
}

.attendance-table thead .att-identity {
  z-index: 3;
  background: #f0ece4;
}

.attendance-table .att-identity-2 { left: 110px; }
.attendance-table .att-identity-3 { left: 180px; }
.attendance-table .att-identity-4 { left: 440px; }

.attendance-table th:first-child,
.attendance-table td:first-child { border-left: 0; }

.attendance-table tbody tr:hover { background: #faf8f4; }
.attendance-table tbody tr.group-government td:not(.att-mark) { background: #f0f6ef; }
.attendance-table tbody tr.group-opposition td:not(.att-mark) { background: #eef3f8; }
.attendance-table tbody tr.group-chair td:not(.att-mark) { background: #f8f1df; }
.attendance-table tbody tr.group-other td:not(.att-mark) { background: #f1efeb; }

.attendance-table .att-group { min-width: 110px; white-space: nowrap; }
.attendance-table .att-party { min-width: 70px; text-align: center; }
.attendance-table .att-position { min-width: 260px; white-space: pre-line; }
.attendance-table .att-user { min-width: 150px; font-weight: 600; }
.attendance-table .att-percent { min-width: 105px; text-align: center; font-variant-numeric: tabular-nums; }
.attendance-table .att-flag { min-width: 76px; text-align: center; }
.attendance-table .att-mark { min-width: 88px; text-align: center; font-size: 0.72rem; font-weight: 700; }

.attendance-table .member-group {
  border-left: 4px solid var(--member-accent, var(--rule));
  padding-left: 0.5rem;
}

.party-acronym {
  display: inline-block;
  min-width: 2.25rem;
  padding: 0.18rem 0.3rem;
  border: 1px solid currentColor;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.04em;
}

.party-ff { color: #01795d; background: #e5f3ea; }
.party-fg { color: #103877; background: #e7f0f8; }
.party-sf { color: #0f8069; background: #e5f2eb; }
.party-sd { color: #732e8a; background: #f2e8f5; }
.party-ind,
.party-none { color: #686157; background: #f1efeb; }

.group-government { --member-accent: #58836a; }
.group-opposition { --member-accent: #597e9e; }
.group-chair { --member-accent: var(--gold); }
.group-other { --member-accent: #8a8174; }

.attendance-table .mark-present { color: #14532d; background: #e5f0e7; }
.attendance-table .mark-absent { color: #555; background: #eeece8; }
.attendance-table .mark-excused { color: #8a5a19; background: #f7eedc; }
.attendance-table .mark-not_possible { color: #777; background: #f7f6f3; font-size: 0.7rem; }
.attendance-table .mark-unmarked { color: #aaa; font-weight: normal; }

.mark-select { min-width: 118px; padding: 0.35rem; font-size: 0.85rem; }
.attendance-admin-scroll { max-height: 70vh; }
.attendance-admin-table .att-mark { padding: 0.25rem; }
.attendance-admin-table .mark-select { min-width: 140px; width: 140px; border-color: #c7c0b4; }
.attendance-admin-table .mark-select:focus { outline-offset: -2px; }
.attendance-admin-table .mark-saving { display: block; min-height: 1rem; font-size: 0.68rem; color: var(--muted); text-align: center; }
.member-form .field { margin-bottom: 0.8rem; }
.member-form .checkbox-row { display: flex; flex-wrap: wrap; gap: 1rem; }
.member-form .checkbox-row label { display: flex; gap: 0.4rem; align-items: center; font-size: 0.9rem; }
.sitting-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; align-items: end; }
.sitting-controls .field { margin: 0; }
.row-actions { min-width: 160px; }

/* Portal dashboard */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}

.module-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 4px solid var(--gold);
  padding: 1.25rem;
  color: var(--ink);
  text-decoration: none;
}

.module-card:hover { border-color: #b8b1a3; border-top-color: var(--gold); color: var(--ink); }
.module-card h3 { margin-bottom: 0.4rem; }
.module-card p { color: var(--muted); font-size: 0.92rem; flex: 1; }
.module-open { color: var(--green); font-weight: 600; font-size: 0.9rem; }

/* Footer */
.site-foot {
  background: var(--charcoal);
  color: #cfc6b4;
  font-size: 0.85rem;
  padding: 1.75rem 0;
  border-top: 3px solid var(--gold);
}

.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 0.9rem;
}

.site-foot a { color: #fff; text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }
.site-foot p { margin: 0.35rem 0; max-width: 820px; }

@media (max-width: 820px) {
  .two-col { grid-template-columns: 1fr; }
  .masthead-links { display: none; }
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { font-weight: 600; color: var(--ink); }
  .sheet-scroll { max-height: 66vh; }
  .attendance-table .att-position { min-width: 190px; }
}
