:root {
  --navy: #031f4b;
  --blue: #176bad;
  --ink: #0e2035;
  --paper: #f3f5f5;
  --line: #d2dbe0;
  --muted: #657483;
  --white: #fff;
  --danger: #a64242;
  --success: #2f6d4c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
.panel-header {
  min-height: 84px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 34px;
  align-items: center;
  padding: 0 max(24px, calc((100vw - 1380px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.panel-brand { display: inline-flex; align-items: center; gap: 12px; width: fit-content; color: var(--navy); font-size: 14px; font-weight: 700; letter-spacing: .19em; }
.panel-brand small { display: block; margin-top: 5px; color: #567189; font-size: 8px; font-weight: 600; letter-spacing: .2em; }
.panel-mark { width: 32px; height: 32px; position: relative; }
.panel-mark::before, .panel-mark::after { content: ''; position: absolute; width: 17px; height: 17px; }
.panel-mark::before { right: 0; top: 0; border-top: 3px solid var(--navy); border-right: 3px solid var(--navy); }
.panel-mark::after { left: 0; bottom: 0; border-left: 3px solid var(--blue); border-bottom: 3px solid var(--blue); }
.panel-mark i { position: absolute; width: 8px; height: 8px; inset: 12px; background: var(--navy); }
.panel-nav { display: flex; gap: 26px; color: #425970; font-size: 12px; }
.panel-nav a:hover { color: var(--blue); }
.panel-back, .logout-form button {
  border: 0;
  border-bottom: 1px solid var(--navy);
  background: transparent;
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  cursor: pointer;
}
.logout-form { margin: 0; }
.panel-main { width: min(100% - 48px, 1180px); min-height: calc(100vh - 148px); margin: 0 auto; padding: 62px 0 90px; }
.panel-footer {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  border-top: 1px solid var(--line);
  color: #71808c;
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.panel-eyebrow { margin: 0 0 15px; color: var(--blue); font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.panel-title { margin: 0; color: var(--navy); font-family: Georgia, 'Times New Roman', serif; font-size: clamp(40px, 5vw, 64px); font-weight: 400; line-height: 1.04; letter-spacing: -.035em; }
.panel-lead { max-width: 650px; margin: 20px 0 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.panel-section { margin-top: 52px; }
.panel-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 40px; }
.stat-card, .panel-card {
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 18px 50px rgba(3,31,75,.045);
}
.stat-card { padding: 26px; }
.stat-card span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.stat-card strong { display: block; margin-top: 16px; color: var(--navy); font-family: Georgia, serif; font-size: 44px; font-weight: 400; }
.panel-card { padding: clamp(26px, 4vw, 44px); }
.panel-card h2 { margin: 0 0 24px; color: var(--navy); font-family: Georgia, serif; font-size: 28px; font-weight: 400; }
.auth-shell { max-width: 560px; margin: 25px auto; }
.auth-shell .panel-card { border-top: 3px solid var(--blue); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.field { display: grid; gap: 9px; }
.field-full { grid-column: 1 / -1; }
.field > span { color: #40566c; font-size: 11px; font-weight: 600; }
.field > small { color: #788590; font-size: 10px; }
.field input, .field textarea, .field select {
  width: 100%;
  min-height: 50px;
  padding: 14px 15px;
  border: 1px solid #d1dbe1;
  border-radius: 2px;
  outline: 0;
  background: #f7f8f8;
  color: var(--ink);
}
.field textarea { min-height: 130px; max-height: 45vh; overflow-y: auto; resize: vertical; -webkit-overflow-scrolling: touch; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue); background: white; box-shadow: 0 0 0 3px rgba(23,107,173,.1); }
.form-actions { display: flex; gap: 16px; align-items: center; margin-top: 28px; }
.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  border: 1px solid var(--navy);
  border-radius: 0;
  background: var(--navy);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  cursor: pointer;
}
.button:hover { background: var(--blue); border-color: var(--blue); }
.button-secondary { background: transparent; color: var(--navy); }
.button-danger { border-color: #d7bbbb; background: transparent; color: var(--danger); }
.button-small { min-height: 36px; padding: 0 13px; font-size: 9px; }
.notice { margin: 0 0 24px; padding: 15px 18px; border-left: 3px solid var(--blue); background: white; color: #40566c; font-size: 13px; line-height: 1.5; }
.notice-error { border-color: var(--danger); background: #fff7f7; color: #723333; }
.notice-success { border-color: var(--success); background: #f5fbf7; color: #315d45; }
.notice-info { border-color: var(--blue); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: white; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: 17px 18px; border-bottom: 1px solid #e1e6e9; text-align: left; vertical-align: middle; }
.data-table th { color: #667887; font-size: 9px; letter-spacing: .11em; text-transform: uppercase; }
.data-table td { color: #354b60; font-size: 13px; }
.data-table tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 8px; align-items: center; }
.table-actions form { margin: 0; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; background: #edf1f3; color: #5a6b79; font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.badge-live { background: #e3eee7; color: var(--success); }
.badge-owner { background: #e5edf5; color: #285f8d; }
.section-head { display: flex; justify-content: space-between; gap: 24px; align-items: end; margin-bottom: 26px; }
.section-head h2 { margin: 0; color: var(--navy); font-family: Georgia, serif; font-size: 31px; font-weight: 400; }
.credentials { margin-top: 24px; padding: 20px; border: 1px solid #b9cce0; background: #f1f7fb; }
.credentials code, .secret-code { display: block; margin-top: 10px; padding: 12px; overflow-wrap: anywhere; background: #071f3e; color: white; font: 14px Consolas, monospace; }
.qr-layout { display: grid; grid-template-columns: 210px 1fr; gap: 34px; align-items: start; margin-top: 28px; }
#qrcode { width: 200px; min-height: 200px; padding: 12px; background: white; border: 1px solid var(--line); }
#qrcode img, #qrcode canvas { display: block; width: 176px !important; height: 176px !important; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 24px 0; padding: 0; list-style: none; }
.recovery-codes code { display: block; padding: 11px; background: #eef2f4; color: var(--navy); text-align: center; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px; border: 1px solid #d1dbe1; border-bottom: 0; background: #eef2f4; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.editor-toolbar button { min-width: 34px; min-height: 32px; border: 1px solid #c6d0d6; background: white; color: var(--navy); cursor: pointer; }
.editor-size-control { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: #40566c; font-size: 10px; font-weight: 700; }
.editor-size-control input { width: 66px; min-height: 32px; padding: 5px 7px; border: 1px solid #c6d0d6; background: white; color: var(--navy); }
.editor-size-control button { padding-inline: 10px; }
.rich-editor {
  width: 100%;
  height: clamp(380px, 58vh, 560px);
  padding: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  resize: vertical;
  border: 1px solid #d1dbe1;
  outline: none;
  background: white;
  color: #25384c;
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.rich-editor:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,107,173,.1); }
.rich-editor p, .rich-editor div { margin: 0 0 1em; }
.rich-editor > :first-child { margin-top: 0; }
.rich-editor > :last-child { margin-bottom: 0; }
.rich-editor::-webkit-scrollbar { width: 10px; }
.rich-editor::-webkit-scrollbar-track { background: #eef2f4; }
.rich-editor::-webkit-scrollbar-thumb { border: 2px solid #eef2f4; background: #8da0ae; }
.rich-editor h2, .rich-editor h3 { color: var(--navy); font-family: Georgia, serif; font-weight: 400; }
.editor-help { margin: 9px 0 0; color: #788590; font-size: 10px; }
.cover-preview { max-width: 260px; max-height: 150px; margin-top: 12px; object-fit: cover; }
.danger-zone { margin-top: 50px; border-top: 1px solid #dbcaca; padding-top: 28px; }

@media (max-width: 900px) {
  .panel-header { grid-template-columns: 1fr auto; padding: 18px 24px; }
  .panel-nav { grid-column: 1 / -1; order: 3; overflow-x: auto; padding-top: 14px; border-top: 1px solid var(--line); }
  .panel-main { width: min(100% - 32px, 1180px); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .panel-header { gap: 16px; }
  .panel-brand { font-size: 11px; }
  .form-grid, .qr-layout { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .panel-footer { align-items: flex-start; flex-direction: column; padding-block: 20px; }
  .editor-toolbar { position: sticky; top: 0; z-index: 10; display: block; padding: 10px; box-shadow: 0 5px 18px rgba(7, 31, 62, .12); }
  .editor-actions { width: 100%; flex-wrap: nowrap; gap: 8px; padding: 0 0 10px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .editor-actions button { flex: 0 0 auto; }
  .editor-toolbar button { min-height: 44px; padding-inline: 12px; }
  .editor-size-control { display: grid; grid-template-columns: auto 78px minmax(145px, 1fr); width: 100%; margin-left: 0; font-size: 11px; }
  .editor-size-control input { width: 78px; min-height: 44px; font-size: 16px; }
  .editor-size-control button { width: 100%; }
  .rich-editor { height: clamp(320px, 52svh, 460px); min-height: 320px; max-height: none; padding: 18px; resize: none; font-size: 16px; }
  .recovery-codes { grid-template-columns: 1fr; }
}
