:root {
  --ha-paper: #f4efe6;
  --ha-stage: #f7f3ec;
  --ha-surface: #fffdf9;
  --ha-header: #fbf8f2;
  --ha-ink: #2b231b;
  --ha-muted: #5e5246;
  --ha-soft: #7a6d5f;
  --ha-line: #e2d6c3;
  --ha-line-strong: #cdbfa9;
  --ha-brass: #8a6630;
  --ha-brass-dark: #7a5a24;
  --ha-error: #9b3b2a;
  --ha-error-dark: #7d3122;
  --ha-good: #3f6849;
  --ha-focus: rgba(140, 106, 50, .28);
  color-scheme: light;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  background: var(--ha-paper);
}

body {
  min-height: 100vh;
  color: var(--ha-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select { font: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: var(--ha-brass-dark); text-underline-offset: 3px; }

button:focus-visible,
a:focus-visible,
input:focus,
select:focus {
  outline: 0;
  border-color: var(--ha-brass);
  box-shadow: 0 0 0 3px var(--ha-focus);
}

.ha-access {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 56px;
  background: var(--ha-paper);
  color: var(--ha-ink);
}

.ha-stage {
  width: min(100%, var(--stage-max, 1120px));
  min-height: 720px;
  background: var(--ha-stage);
  border: 1px solid var(--ha-line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ha-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid #e6dccb;
  background: var(--ha-header);
}

.ha-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ha-mark {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #b08742;
  border-radius: 6px;
  color: var(--ha-brass);
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 14px;
  letter-spacing: .04em;
  line-height: 1;
}

.ha-brand-title {
  color: var(--ha-ink);
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 17px;
  letter-spacing: .01em;
  line-height: 1.2;
  white-space: nowrap;
}

.ha-brand-subtitle,
.ha-header-link {
  color: var(--ha-soft);
  font-size: 12px;
  line-height: 1.25;
}

.ha-header-link { white-space: nowrap; }

.ha-main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--main-pad, 56px 32px 64px);
}

.ha-panel {
  width: min(100%, var(--panel-width, 440px));
  margin-top: var(--panel-top, 24px);
  padding: var(--panel-pad, 36px 36px 32px);
  background: var(--ha-surface);
  border: 1px solid var(--ha-line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(60, 40, 20, .04), 0 10px 28px rgba(60, 40, 20, .06);
}

.ha-panel.wide {
  --panel-width: 760px;
  --panel-pad: 24px;
  --panel-top: 0;
}

.ha-kicker {
  margin-bottom: 12px;
  color: var(--ha-brass);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .14em;
  line-height: 1.35;
  text-transform: uppercase;
}

.ha-title {
  margin: 10px 0 0;
  color: var(--ha-ink);
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -.005em;
  line-height: 1.15;
}

.ha-copy {
  margin: 12px 0 0;
  color: var(--ha-muted);
  font-size: 15.5px;
  text-wrap: pretty;
}

.ha-field {
  display: grid;
  gap: 6px;
  margin: 0;
}

.ha-form {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ha-label {
  color: var(--ha-ink);
  font-size: 14px;
  font-weight: 600;
}

.ha-input,
.ha-select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--ha-surface);
  border: 1px solid var(--ha-line-strong);
  border-radius: 6px;
  color: var(--ha-ink);
  font-size: 16px;
}

.ha-input[aria-invalid="true"] { border-color: var(--ha-error); }

.ha-help {
  color: var(--ha-soft);
  font-size: 13.5px;
  line-height: 1.4;
}

.ha-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.ha-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid var(--ha-line-strong);
  border-radius: 6px;
  background: var(--ha-surface);
  color: var(--ha-ink);
  font-size: 15.5px;
  font-weight: 600;
  text-decoration: none;
}

.ha-button.primary {
  border-color: transparent;
  background: var(--ha-ink);
  color: #f8f2e7;
}

.ha-button.primary:hover { background: #40352a; }

.ha-button.brass {
  border-color: transparent;
  background: var(--ha-brass);
  color: #fff8ec;
}

.ha-button.brass:hover { background: #76562a; }
.ha-button.subtle { background: transparent; color: var(--ha-brass-dark); }
.ha-button.danger { color: var(--ha-error-dark); }

.ha-status {
  min-height: 21px;
  margin-top: 14px;
  color: var(--ha-soft);
  font-size: 14px;
}

.ha-status:empty { display: none; }
.ha-status.good { color: var(--ha-good); }
.ha-status.warn { color: var(--ha-brass-dark); }
.ha-status.bad { color: var(--ha-error); }

.ha-divider {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid #eee5d6;
  color: var(--ha-muted);
  font-size: 14px;
}

.ha-code-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.ha-code-cell {
  height: 58px;
  padding: 0;
  text-align: center;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.ha-alert {
  margin: 0 0 18px;
  padding: 12px 13px;
  border: 1px solid #e3c4ba;
  border-radius: 6px;
  background: #f8ece7;
  color: var(--ha-error-dark);
  font-size: 14px;
}

.ha-checkbox-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin: 18px 0;
  color: var(--ha-muted);
  font-size: 14px;
}

.ha-checkbox-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--ha-brass);
}

.ha-table {
  display: grid;
  gap: 0;
  margin-top: 18px;
  border: 1px solid #eee5d6;
  border-radius: 8px;
  overflow: hidden;
}

.ha-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 112px 104px auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  background: var(--ha-surface);
  border-bottom: 1px solid #eee5d6;
}

.ha-row:last-child { border-bottom: 0; }
.ha-name { min-width: 0; }

.ha-name strong {
  display: block;
  overflow: hidden;
  color: var(--ha-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ha-name span,
.ha-role {
  color: var(--ha-soft);
  font-size: 13px;
}

.ha-chip {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border: 1px solid var(--ha-line);
  border-radius: 4px;
  background: #fbf8f2;
  color: var(--ha-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.ha-chip.active,
.ha-chip.owner { color: var(--ha-good); }

.ha-chip.revoked,
.ha-chip.expired { color: var(--ha-error-dark); }

.ha-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--ha-line);
  border-radius: 8px;
  background: var(--ha-header);
}

.ha-toolbar button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--ha-line-strong);
  border-radius: 6px;
  background: var(--ha-surface);
  color: var(--ha-ink);
  font-size: 13px;
}

.ha-toolbar button.active {
  background: var(--ha-ink);
  color: #f8f2e7;
}

.ha-spec {
  width: min(100%, 760px);
  margin: 14px auto 0;
  color: var(--ha-soft);
  font-size: 12.5px;
}

.is-hidden { display: none !important; }

@media (max-width: 640px) {
  .ha-header { padding: 14px 16px; }
  .ha-header-link { display: none; }
  .ha-main { padding: 28px 16px 40px; }
  .ha-panel {
    --panel-top: 0;
    --panel-pad: 24px 20px;
  }
  .ha-button,
  .ha-actions { width: 100%; }
  .ha-code-grid { gap: 6px; }
  .ha-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .ha-name strong { white-space: normal; }
}
