.admin-body {
  min-height: 100vh;
  background: #edf2f6;
}

.admin-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 76px;
  padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
}

.admin-header-actions { display: flex; align-items: center; gap: 0.85rem; }
.admin-user { color: var(--navy-900); font-weight: 750; }
.text-link, .text-button {
  border: 0;
  background: transparent;
  color: var(--navy-700);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
.text-link:hover, .text-button:hover { text-decoration: underline; }

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #7a5310;
  font-size: 0.84rem;
  font-weight: 800;
}
.connection-status::before { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-500); content: ""; }
.connection-status.connected { color: #1e663d; }
.connection-status.connected::before { background: #2a8b55; }

.login-shell { display: grid; min-height: calc(100vh - 76px); place-items: center; padding: 2rem 1rem; }
.login-card {
  display: grid;
  width: min(460px, 100%);
  gap: 0.7rem;
  padding: 2rem;
  border: 1px solid #c5d0db;
  border-radius: 0.8rem;
  background: white;
  box-shadow: 0 18px 55px rgba(8, 29, 51, 0.13);
}
.login-card h1 { margin: 0.15rem 0 0; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 550; }
.login-card form { display: grid; gap: 0.7rem; }
.login-card form > p { margin: 0 0 0.3rem; color: var(--muted); }
.login-card label, .instruction-form label { color: var(--navy-900); font-size: 0.88rem; font-weight: 800; }
.login-card input, .workspace-rail select, .instruction-form textarea {
  width: 100%;
  border: 1px solid #b9c5d1;
  border-radius: 0.45rem;
  background: white;
  color: var(--ink);
  outline: none;
}
.login-card input { min-height: 46px; padding: 0.65rem 0.75rem; }
.login-card input:focus, .workspace-rail select:focus, .instruction-form textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(28, 84, 136, 0.12); }
.form-error { margin: 0.2rem 0; padding: 0.65rem; border-left: 3px solid #a83636; background: #fff1f1; color: #8c2727; font-size: 0.86rem; }
.local-code { padding: 0.65rem; border-left: 3px solid var(--gold-500); background: #fff8e7; color: #655329 !important; font-size: 0.86rem; }
.login-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; }

.primary-button, .secondary-button, .small-button {
  min-height: 42px;
  border-radius: 0.4rem;
  font-weight: 850;
  cursor: pointer;
}
.primary-button { padding: 0.65rem 1rem; border: 1px solid var(--gold-500); background: var(--gold-500); color: var(--navy-950); }
.primary-button:hover { background: #d5a943; }
.secondary-button { padding: 0.65rem 0.85rem; border: 1px solid #aebdca; background: white; color: var(--navy-900); }
.secondary-button:hover { border-color: var(--navy-700); }
.secondary-button.danger { color: #8c2727; }
.small-button { min-height: 32px; padding: 0.3rem 0.55rem; border: 1px solid #b9c5d1; background: white; color: var(--navy-800); font-size: 0.78rem; }
button:disabled { opacity: 0.48; cursor: not-allowed; }

.workspace { padding: 1.6rem; }
.workspace-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  max-width: 1720px;
  margin: 0 auto 1.4rem;
}
.workspace-intro h1 { margin: 0.2rem 0 0; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 3vw, 2.55rem); font-weight: 550; line-height: 1.15; }
.workspace-intro > p { max-width: 610px; margin: 0; color: var(--muted); }
.role-notice { max-width: 1720px; margin: -0.4rem auto 1rem; padding: 0.75rem 1rem; border-left: 4px solid var(--gold-500); background: #fff8e7; color: #655329; }

.account-management {
  max-width: 1720px;
  margin: 0 auto 1rem;
  overflow: hidden;
  border: 1px solid #c8d2dc;
  border-radius: 0.65rem;
  background: white;
}
.account-management > summary { padding: 0.8rem 1rem; color: var(--navy-900); font-weight: 850; cursor: pointer; }
.account-management-body { padding: 0 1rem 1rem; border-top: 1px solid var(--line); }
.account-form { display: grid; grid-template-columns: 1fr 1.3fr 210px auto; gap: 0.75rem; align-items: end; padding: 1rem 0; }
.account-form div { display: grid; gap: 0.3rem; }
.account-form label { color: var(--navy-900); font-size: 0.8rem; font-weight: 800; }
.account-form input, .account-form select, .account-role-select { min-height: 42px; padding: 0.55rem 0.65rem; border: 1px solid #b9c5d1; border-radius: 0.4rem; background: white; color: var(--ink); }
.account-list { display: grid; gap: 0.45rem; }
.account-card { display: grid; grid-template-columns: minmax(220px, 1fr) 210px auto auto; gap: 0.75rem; align-items: center; padding: 0.75rem; border: 1px solid #d5dde5; border-radius: 0.45rem; }
.account-identity { display: grid; line-height: 1.3; }
.account-identity span { color: var(--muted); font-size: 0.82rem; }
.account-identity small { margin-top: 0.25rem; color: var(--muted); font-size: 0.7rem; }
.account-role.protected { color: var(--navy-700); font-size: 0.78rem; font-weight: 850; }
.account-state { padding: 0.16rem 0.48rem; border-radius: 999px; background: #e0f2e7; color: #1e663d; font-size: 0.7rem; font-weight: 850; text-transform: uppercase; }
.account-state.inactive { background: #f0f0f0; color: #6b6b6b; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(420px, 1fr) minmax(360px, 0.9fr);
  max-width: 1720px;
  min-height: calc(100vh - 190px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #c8d2dc;
  border-radius: 0.75rem;
  background: white;
  box-shadow: 0 14px 40px rgba(8, 29, 51, 0.09);
}

.workspace-rail { overflow: auto; border-right: 1px solid var(--line); background: #f8fafc; }
.workspace-rail section { padding: 1.15rem; border-bottom: 1px solid var(--line); }
.rail-heading { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.65rem; }
.rail-heading h2 { margin: 0; color: var(--navy-900); font-size: 0.9rem; }
.rail-heading > span { display: inline-grid; min-width: 24px; min-height: 24px; place-items: center; border-radius: 50%; background: #e4ebf2; color: var(--navy-800); font-size: 0.75rem; font-weight: 800; }
.workspace-rail select { min-height: 43px; padding: 0.55rem; }
.rail-help, .empty-rail { margin: 0.55rem 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
.draft-list, .version-list { display: grid; gap: 0.5rem; }
.draft-card {
  display: grid;
  gap: 0.28rem;
  width: 100%;
  padding: 0.7rem;
  border: 1px solid #d5dde5;
  border-radius: 0.45rem;
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.draft-card:hover { border-color: #9eafbf; }
.draft-card.active { border-color: var(--navy-700); box-shadow: inset 3px 0 var(--gold-500); }
.draft-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.4rem; }
.draft-card strong { font-size: 0.86rem; line-height: 1.3; }
.draft-card small, .version-card small { color: var(--muted); font-size: 0.72rem; }
.mini-status { padding: 0.08rem 0.35rem; border-radius: 999px; background: #e9eef3; color: var(--muted); font-size: 0.64rem; font-weight: 850; text-transform: uppercase; }
.mini-status.proposed { background: var(--draft-bg); color: var(--draft-ink); }
.mini-status.approved { background: #e1edf8; color: var(--navy-800); }
.mini-status.published { background: #e0f2e7; color: #1e663d; }
.mini-status.discarded { background: #f0f0f0; color: #6b6b6b; }
.version-card { display: grid; gap: 0.18rem; padding: 0.65rem 0; border-bottom: 1px solid #e0e6ec; }
.version-card strong { font-size: 0.82rem; }

.hermes-workbench { display: grid; grid-template-rows: auto auto minmax(240px, 1fr) auto; min-width: 0; }
.workbench-heading, .review-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--line); }
.workbench-heading h2, .review-heading h2 { margin: 0.15rem 0 0; color: var(--navy-950); font-family: Georgia, "Times New Roman", serif; font-size: 1.35rem; line-height: 1.2; }
.proposal-state { padding: 0.18rem 0.55rem; border-radius: 999px; background: #e9eef3; color: var(--navy-700); font-size: 0.72rem; font-weight: 850; text-transform: uppercase; }
.editor-notice { padding: 0.72rem 1.35rem; background: #fff8e7; color: #655329; font-size: 0.8rem; line-height: 1.45; }
.instruction-history { min-height: 260px; max-height: 52vh; overflow: auto; padding: 1.35rem; background: #f8fafc; }
.assistant-bubble, .user-bubble { width: fit-content; max-width: 85%; margin-bottom: 0.8rem; padding: 0.8rem 0.95rem; border-radius: 0.75rem; line-height: 1.5; }
.assistant-bubble { border: 1px solid var(--line); border-bottom-left-radius: 0.18rem; background: white; }
.user-bubble { margin-left: auto; border-bottom-right-radius: 0.18rem; background: var(--navy-900); color: white; }
.instruction-entry small { display: block; margin: -0.45rem 0 0.9rem; color: var(--muted); font-size: 0.72rem; text-align: right; }
.instruction-form { display: grid; gap: 0.55rem; padding: 1rem 1.2rem; border-top: 1px solid var(--line); }
.instruction-form textarea { resize: vertical; padding: 0.75rem; line-height: 1.45; }
.instruction-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.instruction-actions span { color: var(--muted); font-size: 0.8rem; }

.review-panel { min-width: 0; overflow: auto; border-left: 1px solid var(--line); background: #fff; }
.review-empty { padding: 2.2rem 1.5rem; color: var(--muted); }
.review-empty h2 { margin: 0.2rem 0 0.4rem; color: var(--navy-900); font-family: Georgia, "Times New Roman", serif; }
.review-empty p:last-child { margin-top: 0; }
.review-summary { margin: 0; padding: 1rem 1.35rem; border-bottom: 1px solid var(--line); color: #455268; }
.review-section { padding: 0.9rem 1.35rem; border-bottom: 1px solid var(--line); }
.review-section h3 { margin: 0 0 0.45rem; color: var(--navy-900); font-size: 0.88rem; }
.review-section ul { margin: 0; padding-left: 1.2rem; }
.review-section li { margin: 0.3rem 0; font-size: 0.84rem; line-height: 1.45; }
.risk-section { background: #fff8e7; color: #6b5424; }
.diff-section, .proposal-preview { border-bottom: 1px solid var(--line); }
.diff-section summary, .proposal-preview summary { padding: 0.85rem 1.35rem; color: var(--navy-900); font-size: 0.88rem; font-weight: 850; cursor: pointer; }
.policy-diff { max-height: 330px; overflow: auto; padding: 0 1rem 1rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.74rem; line-height: 1.45; }
.diff-line { display: grid; grid-template-columns: 18px 1fr; padding: 0.25rem 0.4rem; border-bottom: 1px solid rgba(0, 0, 0, 0.04); white-space: pre-wrap; }
.diff-line.added { background: #e8f6ed; color: #195c37; }
.diff-line.removed { background: #fff0f0; color: #8b2f2f; }
.no-changes { color: var(--muted); font-family: inherit; }
.proposal-preview article { max-height: 470px; overflow: auto; padding: 0 1.35rem 1.2rem; }
.proposal-preview article h2 { margin: 0.4rem 0; font-family: Georgia, "Times New Roman", serif; }
.proposal-preview article h3 { margin: 1.25rem 0 0.4rem; color: var(--navy-900); font-family: Georgia, "Times New Roman", serif; }
.proposal-preview article p, .proposal-preview article li { font-size: 0.86rem; line-height: 1.55; }
.proposal-preview article ul { margin: 0.25rem 0; padding-left: 1.2rem; }
.preview-meta { color: var(--navy-700); font-size: 0.75rem !important; font-weight: 850; text-transform: uppercase; }
.preview-summary { color: var(--muted); }
.review-actions { display: grid; grid-template-columns: auto 1fr; gap: 0.55rem; padding: 1rem 1.2rem 0.5rem; }
.review-actions .primary-button { grid-column: 1 / -1; }
.review-footnote { margin: 0; padding: 0.3rem 1.2rem 1.2rem; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }

.toast {
  position: fixed;
  z-index: 100;
  right: 1.2rem;
  bottom: 1.2rem;
  max-width: 440px;
  padding: 0.85rem 1rem;
  border: 1px solid #acbac7;
  border-radius: 0.55rem;
  background: var(--navy-950);
  box-shadow: var(--shadow);
  color: white;
  font-weight: 700;
}

@media (max-width: 1250px) {
  .account-form { grid-template-columns: 1fr 1fr; }
  .account-card { grid-template-columns: 1fr 200px auto; }
  .account-state { grid-column: 3; }
  .workspace-grid { grid-template-columns: 250px minmax(420px, 1fr); }
  .review-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
  .review-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .review-actions .primary-button { grid-column: auto; }
}

@media (max-width: 780px) {
  .admin-header { align-items: flex-start; padding: 0.65rem 0.9rem; }
  .admin-header-actions { flex-wrap: wrap; justify-content: flex-end; }
  .connection-status { width: 100%; justify-content: flex-end; }
  .admin-user { display: none; }
  .workspace { padding: 0.8rem; }
  .workspace-intro { display: block; }
  .workspace-intro > p { margin-top: 0.6rem; }
  .account-form, .account-card { grid-template-columns: 1fr; }
  .account-state { grid-column: auto; justify-self: start; }
  .workspace-grid { display: block; }
  .workspace-rail { border-right: 0; }
  .workspace-rail section:nth-child(2), .workspace-rail section:nth-child(3) { max-height: 280px; overflow: auto; }
  .hermes-workbench { border-top: 1px solid var(--line); }
  .instruction-history { max-height: 420px; }
  .review-actions { grid-template-columns: 1fr; }
  .review-actions .primary-button { grid-column: auto; }
}

@media print {
  .admin-header, .workspace-rail, .hermes-workbench, .review-actions, .review-footnote, .toast { display: none !important; }
  .workspace-grid { display: block; border: 0; box-shadow: none; }
  .review-panel { border: 0; }
}
