:root {
  --bg: #d8d8d2;
  --panel: #fff;
  --panel-alt: #f3f3ed;
  --ink: #050505;
  --inverse: #fff;
  --muted: #555;
  --line: #050505;
  --soft-line: #8a8a84;
  --brand: #050505;
  --accent: #050505;
  --danger: #050505;
  --ok: #050505;
  --warn: #050505;
  --font-body: "Courier New", Courier, monospace;
  --font-display: "Courier New", Courier, monospace;
  --radius: 0;
  --border: 2px;
  --shadow: 5px 5px 0 #050505;
  --card-pad: 16px;
  --content-width: 1220px;
}

[data-theme="operator"] {
  --bg: #d8d8d2;
  --panel: #fff;
  --panel-alt: #f3f3ed;
  --ink: #050505;
  --inverse: #fff;
  --muted: #555;
  --line: #050505;
  --soft-line: #85857f;
  --brand: #050505;
  --accent: #050505;
  --font-body: "Courier New", Courier, monospace;
  --font-display: "Courier New", Courier, monospace;
  --radius: 0;
  --border: 2px;
  --shadow: 5px 5px 0 #050505;
  --card-pad: 16px;
}

[data-theme="dos-midnight"] {
  color-scheme: dark;
  --bg: #000;
  --panel: #000;
  --panel-alt: #0b0b0b;
  --ink: #fff;
  --inverse: #000;
  --muted: #cfcfcf;
  --line: #fff;
  --soft-line: #9a9a9a;
  --brand: #000;
  --accent: #fff;
  --font-body: "Courier New", Courier, monospace;
  --font-display: "Courier New", Courier, monospace;
  --radius: 0;
  --border: 1px;
  --shadow: none;
  --card-pad: 14px;
}

[data-theme="ledger"] {
  --bg: #e5e3da;
  --panel: #fffef7;
  --panel-alt: #f1efe5;
  --ink: #090909;
  --inverse: #fffef7;
  --muted: #57544c;
  --line: #090909;
  --soft-line: #79766e;
  --brand: #fffef7;
  --accent: #090909;
  --font-body: Georgia, "Times New Roman", serif;
  --font-display: Georgia, "Times New Roman", serif;
  --radius: 0;
  --border: 1px;
  --shadow: 3px 3px 0 #090909;
  --card-pad: 18px;
}

[data-theme="property-review"] {
  --bg: #d9d8d0;
  --panel: #fff;
  --panel-alt: #efeee7;
  --ink: #050505;
  --inverse: #fff;
  --muted: #4d4d48;
  --line: #050505;
  --soft-line: #777770;
  --brand: #fff;
  --accent: #050505;
  --font-body: "Times New Roman", Times, serif;
  --font-display: Georgia, "Times New Roman", serif;
  --radius: 0;
  --border: 1px;
  --shadow: none;
  --card-pad: 17px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px double var(--ink); outline-offset: 3px; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 11px 18px;
  border-bottom: var(--border) solid var(--line);
  background: var(--brand);
  color: var(--inverse);
}

.app-header .bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  width: min(100%, var(--content-width));
  margin: 0 auto;
}

.brand-lockup a { display: flex; align-items: baseline; gap: 9px; color: inherit; text-decoration: none; }
.brand-lockup strong { font: 900 25px/1 var(--font-display); letter-spacing: -.07em; }
.brand-lockup span { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }

.app-nav { display: flex; align-items: center; justify-content: center; gap: 13px; flex-wrap: wrap; font-size: 12px; }
.app-nav a { color: inherit; text-decoration: none; text-transform: uppercase; letter-spacing: .02em; }
.app-nav a:hover { text-decoration: underline; text-underline-offset: 4px; }

.header-actions, .theme-quick-form { display: flex; align-items: center; gap: 7px; }
.header-actions form, .logout-form { margin: 0; }
.theme-quick-form select { width: 158px; min-height: 34px; padding: 6px 26px 6px 8px; }
.theme-apply { padding: 7px 9px; }

main { width: min(100%, var(--content-width)); margin: 0 auto; padding: 24px 18px 40px; }

h1, h2, h3, h4 { margin-top: 0; color: var(--ink); font-family: var(--font-display); line-height: 1.08; }
h1 { margin-bottom: 18px; font-size: clamp(27px, 4vw, 44px); letter-spacing: -.045em; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
p { margin-top: 0; }

.eyebrow { margin-bottom: 5px; font: 700 10px/1.2 "Courier New", monospace; letter-spacing: .17em; text-transform: uppercase; }
.muted { color: var(--muted); }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.card {
  margin-bottom: 16px;
  padding: var(--card-pad);
  border: var(--border) solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.badge {
  display: inline-block;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: 700 10px/1.2 "Courier New", monospace;
  text-transform: uppercase;
}
.badge.ok { border-style: double; border-width: 3px; }
.badge.warn { border-style: dashed; }
.badge.danger { color: var(--inverse); background: var(--danger); }

.btn, button {
  display: inline-block;
  min-height: 36px;
  padding: 8px 12px;
  border: var(--border) solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--inverse);
  cursor: pointer;
  font: 700 12px/1.1 var(--font-body);
  text-decoration: none;
}
.btn:hover, button:hover { filter: invert(1); }
.btn.secondary, button.secondary { background: var(--panel); color: var(--ink); }
.btn.danger, button.danger { background: var(--danger); }
.btn.ok, button.ok { border-style: double; border-width: 4px; background: var(--ok); }
button:disabled { cursor: not-allowed; opacity: .55; filter: none; }

input, textarea, select {
  width: 100%;
  min-height: 38px;
  padding: 8px 9px;
  border: var(--border) solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 120px; font-family: "Courier New", Courier, monospace; }
label { display: block; margin: 10px 0 5px; font-weight: 700; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 7px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { border-bottom-width: 2px; font-family: var(--font-display); }
.table tr:hover td { background: var(--panel-alt); }

.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 80%; padding: 10px 12px; border: var(--border) solid var(--line); border-radius: var(--radius); white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--inverse); }
.msg.assistant { align-self: flex-start; background: var(--panel); }

pre { overflow: auto; padding: 12px; border: var(--border) solid var(--line); border-radius: var(--radius); background: var(--ink); color: var(--inverse); white-space: pre-wrap; }
.code, code { font-family: "Courier New", Courier, monospace; }
.alert { padding: 12px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel-alt); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.source-box { margin: 10px 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-alt); }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline-form label { margin: 0; }
.inline-form select { width: auto; min-width: 180px; }

.theme-settings { margin-bottom: 24px; }
.theme-option-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin: 15px 0; }
.theme-option-card {
  position: relative;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  min-height: 96px;
  margin: 0;
  padding: 11px;
  border: 2px solid #050505;
  background: #fff;
  color: #050505;
  cursor: pointer;
}
.theme-option-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.theme-option-card:has(input:checked) { outline: 4px double var(--ink); outline-offset: 3px; }
.theme-option-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid currentColor; font: 700 13px "Courier New", monospace; }
.theme-option-card strong, .theme-option-card small { display: block; }
.theme-option-card small { margin-top: 5px; font: 10px/1.35 "Courier New", monospace; }
.theme-option-card[data-theme-preview="dos-midnight"] { background: #000; color: #fff; font-family: "Courier New", monospace; }
.theme-option-card[data-theme-preview="ledger"] { background: #fffef3; border-style: double; border-width: 4px; font-family: Georgia, serif; }
.theme-option-card[data-theme-preview="property-review"] { border-width: 5px 1px 2px; font-family: "Times New Roman", serif; }

.login-shell { display: grid; place-items: start center; padding: 8vh 18px 30px; }
.login-main { width: min(100%, 460px); margin: 0; padding: 0; }
.login-card { padding: 24px; }
.login-mark { margin: 0 0 16px; font: 900 44px/.8 var(--font-display); letter-spacing: -.08em; }

/* PPX Operator: structured monochrome workstation. */
[data-theme="operator"] .app-header { border-bottom-width: 4px; }
[data-theme="operator"] .card { transition: transform .1s ease, box-shadow .1s ease; }
[data-theme="operator"] .card:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
[data-theme="operator"] h1::after { content: "_"; }

/* DOS Midnight: a dedicated white-on-black terminal. */
[data-theme="dos-midnight"] .app-header { border-bottom: 1px solid #fff; }
[data-theme="dos-midnight"] .brand-lockup strong::after { content: ">_"; margin-left: 3px; }
[data-theme="dos-midnight"] .card { outline: 1px solid #fff; outline-offset: -5px; }
[data-theme="dos-midnight"] h1, [data-theme="dos-midnight"] h2, [data-theme="dos-midnight"] h3 { text-transform: uppercase; letter-spacing: .02em; }
[data-theme="dos-midnight"] h1::before { content: "C:\\PPX> "; font-size: .42em; vertical-align: middle; }
[data-theme="dos-midnight"] .table th { color: #000; background: #fff; }
[data-theme="dos-midnight"] .theme-quick-form select { color: #fff; background: #000; }
[data-theme="dos-midnight"] .alert { border-style: double; }

/* PPX Ledger: private estate book and paper report. */
[data-theme="ledger"] body {
  background-color: var(--bg);
  background-image: radial-gradient(#777 0.4px, transparent 0.4px);
  background-size: 5px 5px;
}
[data-theme="ledger"] .app-header { color: #090909; border-top: 5px double #090909; border-bottom: 5px double #090909; }
[data-theme="ledger"] .app-nav a { text-transform: none; }
[data-theme="ledger"] .brand-lockup strong { font-size: 31px; }
[data-theme="ledger"] .card { border-top: 5px double var(--line); }
[data-theme="ledger"] h1 { padding-bottom: 7px; border-bottom: 5px double var(--line); }
[data-theme="ledger"] .table th { border-top: 1px solid var(--line); border-bottom: 3px double var(--line); }

/* PPX Property Review: specialist late-70s/80s financial newspaper. */
[data-theme="property-review"] .app-header { position: relative; padding-top: 7px; color: #050505; border-top: 7px solid #050505; border-bottom: 4px double #050505; }
[data-theme="property-review"] .app-header .bar { grid-template-columns: auto 1fr auto; }
[data-theme="property-review"] .brand-lockup strong { font: 700 38px/.8 Georgia, serif; }
[data-theme="property-review"] .brand-lockup span { font: 700 9px "Courier New", monospace; }
[data-theme="property-review"] .app-nav { padding: 7px 0; border-top: 1px solid #050505; border-bottom: 1px solid #050505; font-family: "Courier New", monospace; }
[data-theme="property-review"] h1 { padding: 5px 0 9px; border-top: 6px solid var(--line); border-bottom: 4px double var(--line); font-size: clamp(32px, 5vw, 56px); }
[data-theme="property-review"] h2 { padding-bottom: 5px; border-bottom: 2px solid var(--line); }
[data-theme="property-review"] .card { border-width: 5px 1px 1px; }
[data-theme="property-review"] .table th { color: #fff; background: #050505; font-family: "Courier New", monospace; }
[data-theme="property-review"] .badge, [data-theme="property-review"] button, [data-theme="property-review"] input, [data-theme="property-review"] select { font-family: "Courier New", monospace; }

@media (max-width: 1020px) {
  .app-header .bar { grid-template-columns: 1fr auto; }
  .app-nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .theme-option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  main { padding: 16px 12px 30px; }
  .app-header { position: relative; padding: 10px 12px; }
  .app-header .bar, [data-theme="property-review"] .app-header .bar { display: flex; align-items: stretch; flex-direction: column; gap: 10px; }
  .brand-lockup a { justify-content: space-between; }
  .app-nav { justify-content: flex-start; gap: 7px 12px; font-size: 11px; }
  .header-actions { justify-content: space-between; }
  .theme-quick-form { flex: 1; }
  .theme-quick-form select { flex: 1; width: auto; }
  .grid, .theme-option-grid { grid-template-columns: 1fr; }
  .span-3, .span-4, .span-6, .span-8, .span-12 { grid-column: span 1; }
  .card { padding: 13px; }
  .section-heading { display: block; }
  .msg { max-width: 96%; }
  .table { display: block; overflow-x: auto; font-size: 12px; }
  .inline-form { display: block; }
  .inline-form select { width: 100%; }
}
