:root {
  --ink: #18201d;
  --muted: #68716d;
  --paper: #f5f4ef;
  --panel: #fffefa;
  --line: #d8d8cf;
  --accent: #155e4a;
  --accent-hover: #0f4b3b;
  --danger: #a13d32;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.quiet-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  color: #929791;
  font-size: .9rem;
  letter-spacing: .04em;
}
.shell { min-height: 100vh; padding: 2rem; }
.login-wrap {
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
}
.card {
  width: min(100%, 27rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 2rem;
  box-shadow: 0 18px 50px rgb(35 45 40 / 8%);
}
.eyebrow {
  margin: 0 0 .65rem;
  color: var(--accent);
  font: 600 .72rem/1 monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: .55rem;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  letter-spacing: -.045em;
}
.muted { color: var(--muted); line-height: 1.55; }
.form-grid { display: grid; gap: 1rem; margin-top: 1.5rem; }
label {
  display: grid;
  gap: .45rem;
  color: #414a46;
  font-size: .85rem;
  font-weight: 600;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: .78rem .85rem;
  outline: none;
}
input[type="checkbox"] { width: auto; }
textarea {
  min-height: 15rem;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: .8rem;
  line-height: 1.45;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(21 94 74 / 12%);
}
.button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  padding: .78rem 1rem;
  font-weight: 700;
}
.button:hover { background: var(--accent-hover); }
.button.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}
.button.danger { background: transparent; color: var(--danger); }
.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: .25rem;
  font-size: 1.6rem;
  line-height: 1;
}
.error { margin: 0; color: var(--danger); font-size: .85rem; }
.dashboard { width: min(100%, 72rem); margin: 0 auto; }
.dashboard-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.dashboard-header h1 { margin-bottom: 0; }
.table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
th {
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.status {
  display: inline-flex;
  border-radius: 999px;
  background: #e5f2eb;
  color: #27654f;
  padding: .3rem .58rem;
  font-size: .76rem;
  font-weight: 700;
}
.status.revoked, .status.expired {
  background: #f5e9e6;
  color: #9a4339;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .35rem;
}
.actions .button { padding: .48rem .65rem; font-size: .78rem; }
.empty { padding: 4rem 1.5rem; text-align: center; color: var(--muted); }
.empty.compact { padding: 1.5rem; }
.management-section { margin-top: 3rem; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-heading h2, .section-heading h3 { margin-bottom: 0; }
.section-heading > .muted { margin-bottom: 0; }
.credential-form {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(12rem, 1fr) auto auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}
fieldset {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}
fieldset legend {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}
fieldset label {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
}
.secret-panel {
  margin: 1rem 0;
  border: 1px solid #d6b866;
  border-radius: 12px;
  background: #fff9df;
  padding: 1rem;
}
.secret-value {
  display: block;
  margin-top: .5rem;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: .8rem;
}
.operations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: .75rem;
}
.metric-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 1rem;
}
.metric-card strong {
  display: block;
  margin-top: .4rem;
  font-size: 1.35rem;
}
.alert {
  margin-bottom: 1rem;
  border: 1px solid #d6b866;
  border-radius: 10px;
  background: #fff9df;
  padding: .8rem 1rem;
}
.alert.danger {
  border-color: #dca49d;
  background: #fff0ed;
  color: var(--danger);
}
.edit-dialog {
  width: min(calc(100% - 2rem), 58rem);
  max-height: calc(100vh - 2rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  padding: 1.5rem;
  box-shadow: 0 24px 80px rgb(24 32 29 / 24%);
}
.edit-dialog::backdrop { background: rgb(24 32 29 / 55%); }
.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}
.dialog-header h2 { margin-bottom: 0; }
.form-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.source-tools {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.file-button {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .6rem .8rem;
  cursor: pointer;
}
.field-help {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.45;
}
.dialog-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.dialog-spacer { flex: 1; }
.notice-link {
  color: var(--accent);
  font-weight: 700;
}
.revision-section {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.revision-list {
  display: grid;
  gap: .5rem;
}
.revision-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .75rem;
}
.revision-row p { margin: 0; }
.access-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #edeee9;
}
.access-panel { width: min(calc(100% - 2rem), 25rem); text-align: center; }
.access-panel .card { width: 100%; }
html.page-active,
body.page-active {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.page-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
[hidden] { display: none !important; }

@media (max-width: 720px) {
  .shell { padding: 1rem; }
  .dashboard-header { align-items: start; flex-direction: column; }
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tr {
    margin-bottom: .75rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    padding: .4rem;
  }
  td { border: 0; padding: .6rem; }
  .actions { justify-content: flex-start; }
  .form-columns { grid-template-columns: 1fr; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .dialog-spacer { display: none; }
  .credential-form { grid-template-columns: 1fr; align-items: stretch; }
  .section-heading { align-items: start; flex-direction: column; }
}
