:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #18202d;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #047857;
  --shadow: 0 12px 28px rgba(24, 32, 45, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand, .brand-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}

.navlinks {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.navlinks a {
  padding: 9px 11px;
  border-radius: 8px;
  color: #344054;
  font-size: 14px;
  white-space: nowrap;
}

.navlinks a.active, .navlinks a:hover {
  background: #e6f4f1;
  color: var(--primary-dark);
  text-decoration: none;
}

.logout { margin: 0; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.shell.narrow { width: min(840px, calc(100% - 32px)); }

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 42px); line-height: 1.08; }
h2 { margin-bottom: 12px; font-size: 20px; }

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted { color: var(--muted); font-size: 14px; }

.panel, .login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 22px; }
.stack-gap { display: grid; gap: 16px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15,118,110,0.16), rgba(180,83,9,0.12)),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  padding: 28px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  min-height: 106px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric span { color: var(--muted); font-size: 13px; }
.metric strong { display: block; margin-top: 12px; font-size: 34px; }

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
td { font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover { background: var(--primary-dark); text-decoration: none; }
.button.ghost { background: #fff; color: var(--primary-dark); }
.button.small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.button.full { width: 100%; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #edf2f7;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.pill.published, .pill.granted, .pill.fulfilled, .pill.closed, .pill.reported { background: #dcfce7; color: var(--ok); }
.pill.withdrawn, .pill.rejected, .pill.confirmed { background: #fee2e2; color: var(--danger); }
.pill.draft, .pill.open, .pill.suspected { background: #fef3c7; color: var(--accent); }

.form-stack, .form-grid { display: grid; gap: 16px; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.purpose-editor {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

input, textarea, select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea { resize: vertical; }
hr { width: 100%; border: 0; border-top: 1px solid var(--line); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check input { width: 18px; min-height: 18px; }
.check span { margin: 0; }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(130px, 160px) minmax(180px, 1fr) auto;
  gap: 8px;
  min-width: 460px;
}

.search-row, .key-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.key-form { max-width: 620px; }

.alert, .success {
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.alert { background: #fee2e2; color: var(--danger); }
.success { background: #dcfce7; color: var(--ok); }

.public-shell {
  width: min(960px, calc(100% - 32px));
  margin: 34px auto 64px;
}

.public-header {
  padding: 28px 0 18px;
}

.public-header h1 { max-width: 820px; }
.public-header p { max-width: 760px; color: #475467; font-size: 17px; line-height: 1.6; }
.public-header.compact { padding-top: 12px; }

.notice-meta, .public-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.data-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.data-list div {
  display: grid;
  grid-template-columns: minmax(110px, 0.4fr) 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.data-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.data-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.notice-meta span, .public-contact span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.public-panel { margin-top: 8px; }
.identity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.purpose-list { display: grid; gap: 12px; }

.purpose-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.purpose-row input { width: 18px; min-height: 18px; margin-top: 2px; }
.purpose-row strong, .purpose-row small, .purpose-row em { display: block; }
.purpose-row small { margin: 5px 0; color: #475467; line-height: 1.5; }
.purpose-row em { color: var(--muted); font-size: 12px; font-style: normal; }

.success-block {
  text-align: center;
  padding: 28px 12px;
}

code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #eef2f6;
  color: #344054;
}

@media (max-width: 920px) {
  .topbar { grid-template-columns: 1fr; }
  .logout { justify-self: start; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .shell, .public-shell { width: min(100% - 20px, 1000px); margin-top: 18px; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .metric-grid, .form-grid, .identity-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { padding: 16px; }
  .inline-form { grid-template-columns: 1fr; min-width: 260px; }
  .search-row, .key-form { grid-template-columns: 1fr; }
  h1 { font-size: 30px; }
}
