:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #fff;
  --ink: #20382b;
  --muted: #66796e;
  --line: #dce5df;
  --green: #174d3b;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Segoe UI', Tahoma, sans-serif; line-height: 1.65; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #b18a30; outline-offset: 3px; }

.header { min-height: 78px; padding: 16px 30px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--green); color: #fff; font-weight: 800; font-size: 21px; }
.brand strong, .brand small { display: block; }
.brand small, .header-note { font-size: 11px; color: var(--muted); }
.layout { max-width: 1450px; margin: auto; padding: 30px; display: grid; grid-template-columns: 245px minmax(0, 1fr); gap: 28px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); padding: 24px; box-shadow: 0 7px 25px rgb(30 60 40 / 3%); }
.sidebar { position: sticky; top: 24px; }
.sidebar > button { width: 100%; text-align: left; margin-bottom: 8px; padding: 10px 12px; background: #f4f7f4; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--ink); }
.sidebar > button:hover { background: #e9f1eb; }
.eyebrow { margin: 0 0 9px; font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: #617a68; }
label { display: block; font-size: 12px; color: #536a5b; margin-bottom: 16px; }
input, select, textarea { display: block; width: 100%; margin-top: 7px; border: 1px solid #cedcd2; border-radius: 8px; background: #fbfcfb; color: var(--ink); padding: 10px 12px; }
input, select { min-height: 44px; }
.target { font-size: 11px; overflow-wrap: anywhere; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.8; }
.workspace { min-width: 0; display: grid; gap: 22px; }
.page-heading h1 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.2; letter-spacing: -.04em; }
.page-heading h1 span { color: #b19554; }
.page-heading > p:last-child { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.notice { margin: 0; padding: 13px 16px; border: 1px solid #cde0d2; border-radius: 9px; color: #345a40; background: #ebf4ed; font-size: 12px; overflow-wrap: anywhere; }
.notice.error { background: #fff1e9; border-color: #ecd2bb; color: #80532a; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.quiet, .primary { min-height: 42px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--green); font-size: 12px; font-weight: 650; }
.primary { background: var(--green); color: #fff; border-color: var(--green); }
.quiet:hover { background: #f0f5f0; }
.danger { color: #994c3c; }
.new-entry-row { display: flex; align-items: end; gap: 12px; margin-bottom: 18px; }
.new-entry-row label { flex: 1; max-width: 280px; margin: 0; }
textarea { min-height: 380px; resize: vertical; font-family: Consolas, monospace; font-size: 13px; line-height: 1.65; tab-size: 2; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 520px; overflow: auto; margin: 18px 0 0; padding: 18px; border: 1px solid #e0e7e1; border-radius: 9px; background: #f5f8f5; font: 12px/1.8 Consolas, monospace; }
.records { display: grid; gap: 10px; }
.record { display: flex; align-items: center; justify-content: space-between; gap: 15px; border: 1px solid var(--line); padding: 14px; border-radius: 10px; }
.record strong, .record small { display: block; }
.record strong { font-size: 13px; overflow-wrap: anywhere; }
.record small { font-size: 10px; color: var(--muted); margin-top: 4px; }
.record-actions { display: flex; gap: 7px; flex-shrink: 0; }

.production .header { border-bottom: 3px solid #b79a56; }
.production .target { color: #88691f; font-weight: 700; }

dialog { width: min(620px, calc(100% - 28px)); max-height: 90dvh; overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: 17px; color: var(--ink); }
dialog::backdrop { background: rgb(15 30 22 / 72%); backdrop-filter: blur(4px); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
#authSummary { max-height: 230px; font-size: 11px; }
.checkbox { display: flex; align-items: flex-start; gap: 10px; }
.checkbox input { width: 18px; min-height: 18px; margin-top: 2px; }
.countdown { padding: 10px 14px; border: 1px solid #e2d6af; border-radius: 8px; background: #faf6e9; color: #776027; font-size: 13px; font-variant-numeric: tabular-nums; }
#totp { font-size: 23px; letter-spacing: .25em; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 850px) {
  .layout { grid-template-columns: 1fr; padding: 20px; }
  .sidebar { position: static; }
  .sidebar > button { width: auto; margin-right: 5px; }
}
@media (max-width: 520px) {
  .header { padding: 15px 18px; }
  .header-note { display: none; }
  .layout { padding: 15px; }
  .panel { padding: 18px; }
  .record { align-items: flex-start; flex-direction: column; }
  .section-heading { align-items: flex-start; }
  input, select { font-size: 16px; }
  dialog { padding: 20px; }
}

.entry-editor {
  width: min(950px, calc(100% - 28px));
}

.entry-editor form > h2 {
  margin-bottom: 24px;
}

.edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 20px;
}

.edit-grid label {
  min-width: 0;
}

.entry-editor textarea {
  min-height: 100px;
  font-family: inherit;
}

.entry-editor input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
}

.entry-editor input[readonly] {
  background: #edf1ed;
  color: #65776a;
}

.entry-editor label > small {
  display: block;
  margin-top: 6px;
}

.form-rows {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.form-rows h3 {
  margin: 0 0 17px;
  font-size: 17px;
}

.form-row-card {
  margin-bottom: 15px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf7;
}

.editor-actions {
  position: sticky;
  bottom: -26px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 0;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  background: white;
}

.editor-error {
  color: #9b4335;
  font-size: 13px;
}

.advanced-editor {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.advanced-editor summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}

.advanced-editor textarea {
  margin-top: 15px;
}

@media (max-width: 650px) {
  .edit-grid { grid-template-columns: 1fr; }
  .editor-actions { bottom: -20px; }
  .record-actions { flex-wrap: wrap; }
}
