:root {
  --brand: #6fa9d8;
  --brand-hover: #5b98ca;
  --deep: #356f9f;
  --soft: #dcecf7;
  --pale: #f1f7fb;
  --canvas: #f7fafc;
  --surface: #ffffff;
  --ink: #183247;
  --secondary: #607789;
  --muted: #8a9aa7;
  --line: #dce6ed;
  --info: #356f9f;
  --info-bg: #eef5fb;
  --ok: #3d6b52;
  --ok-bg: #eef5f0;
  --warn: #8a5a1e;
  --warn-bg: #f7f0e6;
  --danger: #8f3a3a;
  --danger-bg: #f6eeee;
  --radius: 4px;
  --control: 44px;
  --shadow: 0 1px 0 rgba(24, 50, 71, 0.04);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Segoe UI", "Avenir Next", Avenir, "Helvetica Neue", sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --wrap: min(1040px, calc(100% - 48px));
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body.portal,
body.portal-auth {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body.portal { display: flex; flex-direction: column; }

img { max-width: 100%; height: auto; }

h1, h2, h3, .portal-brand, .property-name {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 { font-size: clamp(1.55rem, 2.2vw, 2rem); line-height: 1.2; margin: 0; }
h2 { font-size: 1.2rem; margin: 0 0 var(--space-3); font-weight: 600; }
h3 { font-size: 1.02rem; margin: 0 0 var(--space-2); font-weight: 600; }

a {
  color: var(--deep);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
a:hover { color: var(--brand-hover); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* —— Shell —— */
.portal-shell { flex: 1; display: flex; flex-direction: column; }

.portal-top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.portal-top-inner {
  width: var(--wrap);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 64px;
}

.portal-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
}

.portal-brand span {
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.portal-session {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--muted);
  font-size: 0.88rem;
}
.portal-session form { margin: 0; }
.portal-session .who { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle {
  display: none;
  min-height: var(--control);
  min-width: var(--control);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
}

.portal-nav {
  background: var(--pale);
  border-bottom: 1px solid var(--line);
}

.portal-nav-inner {
  width: var(--wrap);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
  min-height: 48px;
  align-items: stretch;
}

.portal-nav a {
  display: inline-flex;
  align-items: center;
  color: var(--secondary);
  text-decoration: none;
  padding: 0;
  box-shadow: inset 0 -2px 0 transparent;
  transition: color 0.15s ease, box-shadow 0.15s ease;
}

.portal-nav a:hover { color: var(--ink); }

.portal-nav a.is-on {
  color: var(--deep);
  box-shadow: inset 0 -2px 0 var(--brand);
}

.portal-main {
  width: var(--wrap);
  margin: var(--space-6) auto var(--space-7);
  padding: var(--space-6) var(--space-7) var(--space-7);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex: 1;
}

.page-head { margin-bottom: var(--space-5); }

.page-kicker {
  margin: 0 0 var(--space-2);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.page-head .lead {
  margin: var(--space-3) 0 0;
  max-width: 38rem;
  color: var(--secondary);
  font-size: 1.02rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-5) 0 0;
  align-items: center;
}

.section {
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
}

.section:first-of-type { margin-top: var(--space-5); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.section-head h2 { margin: 0; }

.section-head a {
  font-size: 0.92rem;
  text-decoration: none;
}
.section-head a:hover { text-decoration: underline; }

/* —— Home overview —— */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--space-6) var(--space-7);
}

.attention {
  background: var(--pale);
  padding: var(--space-4) var(--space-5);
  border-left: 3px solid var(--brand);
  margin-bottom: var(--space-5);
}

.attention p { margin: 0; color: var(--secondary); }
.attention strong { color: var(--ink); font-weight: 600; }

.property-strip {
  display: grid;
  gap: 0;
}

.property-strip a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

.property-strip a:hover { background: var(--pale); }

.property-name {
  font-size: 1.25rem;
  margin: 0 0 4px;
}

.property-meta {
  color: var(--secondary);
  font-size: 0.95rem;
  margin: 0;
}

.property-status {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--deep);
}

.event-list { list-style: none; margin: 0; padding: 0; }

.event-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}

.event-list li:last-child { border-bottom: 0; }

.event-list a {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}
.event-list a:hover { color: var(--deep); text-decoration: underline; }

.event-list .meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
}

/* —— Property detail —— */
.property-hero {
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-5);
}

.property-hero .address {
  margin: var(--space-2) 0 0;
  color: var(--secondary);
  font-size: 1.05rem;
  max-width: 36rem;
}

.property-hero .status-line {
  margin-top: var(--space-3);
  color: var(--deep);
  font-size: 0.92rem;
}

.facts {
  display: grid;
  gap: var(--space-4) var(--space-6);
  margin: 0;
}

.facts-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.facts div { min-width: 0; }

.facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.facts dd {
  margin: 4px 0 0;
  color: var(--ink);
}

/* —— Lists / tables —— */
.stack-list { list-style: none; margin: 0; padding: 0; }

.stack-list > li,
.doc-row,
.msg-row {
  display: grid;
  gap: 4px var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.stack-list > li:last-child,
.doc-row:last-child,
.msg-row:last-child { border-bottom: 0; }

.doc-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.msg-row {
  grid-template-columns: minmax(0, 1fr) auto;
  text-decoration: none;
  color: inherit;
}

.msg-row-form { margin: 0; }
.msg-row-form .msg-row {
  width: 100%;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  font: inherit;
  cursor: pointer;
}

.msg-row:hover { background: var(--pale); }
.msg-row.is-unread .msg-subject { font-weight: 700; color: var(--ink); }
.msg-row .msg-subject { color: var(--ink); font-weight: 600; }
.msg-row .msg-preview { color: var(--secondary); font-size: 0.92rem; }
.msg-row .msg-when { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.table-desktop { width: 100%; border-collapse: collapse; }
.table-desktop th,
.table-desktop td {
  text-align: left;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table-desktop th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.table-desktop tbody tr:last-child td { border-bottom: 0; }

.mobile-cards { display: none; }

/* —— Status —— */
.status-label {
  display: inline;
  color: var(--secondary);
  font-size: 0.92rem;
}

.status-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 8px;
  vertical-align: middle;
}

.status-label.is-progress::before { background: var(--brand); }
.status-label.is-wait::before { background: var(--warn); }
.status-label.is-done::before { background: var(--ok); }
.status-label.is-stop::before { background: var(--danger); }

.status-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* —— Timeline —— */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--soft);
}

.timeline li {
  position: relative;
  padding: 0 0 var(--space-5) var(--space-5);
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface);
}

.timeline .when {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 4px;
}

.timeline .what {
  margin: 0;
  color: var(--ink);
}

/* —— Empty —— */
.empty-state {
  padding: var(--space-5) 0;
  max-width: 28rem;
}

.empty-state h2 {
  font-size: 1.15rem;
  margin-bottom: var(--space-2);
}

.empty-state p {
  margin: 0 0 var(--space-4);
  color: var(--secondary);
}

/* —— Buttons —— */
.btn,
.btn-secondary,
.btn-text,
.btn-danger,
button.link-button {
  font: inherit;
  cursor: pointer;
}

.btn,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control);
  padding: 0 18px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn {
  background: var(--deep);
  color: #fff;
  border: 1px solid var(--deep);
}
.btn:hover { background: #2c5f8a; color: #fff; border-color: #2c5f8a; }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--brand); color: var(--deep); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #e2c8c8;
}

.btn-text,
button.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--deep);
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: auto;
}
.btn-text:hover,
button.link-button:hover { color: var(--brand-hover); }

/* —— Forms —— */
.portal-form { max-width: 32rem; }
.portal-form.wide { max-width: 40rem; }

.form-section {
  margin: 0 0 var(--space-5);
  padding: 0 0 var(--space-5);
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type { border-bottom: 0; }

.form-section h2 {
  font-size: 1.05rem;
  margin-bottom: var(--space-2);
}

.form-hint {
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: 0.92rem;
}

.field { margin: 0 0 var(--space-4); }

.field label {
  display: block;
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 500;
}

.field .hint {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

label.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: var(--space-4) 0;
  color: var(--secondary);
  font-weight: 400;
}

input, textarea, select {
  width: 100%;
  min-height: var(--control);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.15s ease, outline 0.15s ease;
}

textarea { min-height: 8rem; resize: vertical; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--soft);
  border-color: var(--brand);
}

input[type="checkbox"],
input[type="file"] { width: auto; min-height: auto; }

input[type="file"] {
  padding: var(--space-3) 0;
  border: 0;
}

.text-danger { color: var(--danger); font-size: 0.9rem; }
.validation-summary-errors {
  background: var(--danger-bg);
  color: var(--danger);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-4);
  border-left: 3px solid var(--danger);
}
.validation-summary-errors ul { margin: 0; padding-left: 1.1rem; }

.flash {
  background: var(--ok-bg);
  color: var(--ok);
  padding: var(--space-3) 0;
  margin: 0 0 var(--space-5);
  border-bottom: 1px solid #d5e4da;
}

.flash-info {
  background: var(--info-bg);
  color: var(--info);
  border-bottom-color: var(--soft);
}

.http-warn {
  background: var(--warn-bg);
  color: var(--warn);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-4);
  border-left: 3px solid #c4a06a;
}
.http-warn a { color: var(--warn); }

.message-body {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
  white-space: pre-wrap;
  color: var(--ink);
  line-height: 1.65;
}

/* —— Support FAB —— */
.support-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  min-height: var(--control);
  padding: 0 18px;
  background: var(--surface);
  color: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(24, 50, 71, 0.08);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.support-fab:hover {
  border-color: var(--brand);
  color: var(--ink);
  text-decoration: none;
}

/* —— Auth —— */
body.portal-auth {
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-4);
  background: var(--pale);
}

.portal-card {
  width: min(420px, 100%);
  background: var(--surface);
  padding: 40px 36px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.portal-card:has(.prose) { width: min(36rem, 100%); }

.portal-mark {
  font-family: var(--serif);
  font-size: 2rem;
  margin: 0;
  letter-spacing: -0.03em;
}

.portal-kicker {
  margin: 4px 0 22px;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

.portal-card h1 { font-size: 1.35rem; margin: 0 0 8px; }
.portal-card > p { color: var(--secondary); margin-top: 0; }

.prose { max-width: 40rem; color: var(--secondary); }
.prose h2 { margin-top: 1.4rem; color: var(--ink); }

.privacy-notice { max-width: 44rem; color: var(--secondary); }
.privacy-notice h1, .privacy-notice h2, .privacy-notice h3 { color: var(--ink); }
.privacy-notice h2 { margin-top: 1.6rem; }
.privacy-notice h3 { margin-top: 1.1rem; font-size: 1.05rem; }
.privacy-meta { color: var(--muted); font-size: 0.92rem; }
.privacy-toc {
  margin: 1.6rem 0;
  padding: 1rem 1.1rem;
  background: var(--pale);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.privacy-toc p { margin: 0 0 0.5rem; font-weight: 600; color: var(--ink); }
.privacy-toc ol { margin: 0; padding-left: 1.2rem; }
.privacy-toc li { margin: 0.2rem 0; }

.cookie-bar {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: 36rem;
  background: var(--surface);
  color: var(--secondary);
  padding: 16px 18px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(24, 50, 71, 0.08);
}
.cookie-bar-form { display: grid; gap: 12px; }
.cookie-title { margin: 0; font-size: 1.05rem; color: var(--ink); }
.cookie-bar p { margin: 0; }
.cookie-options summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.cookie-options fieldset { border: 0; padding: 10px 0 0; margin: 0; display: grid; gap: 8px; }
.cookie-options label { display: flex; gap: 8px; align-items: flex-start; font-size: 0.92rem; }
.cookie-options input { width: auto; margin-top: 3px; }
.cookie-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.cookie-bar button {
  background: var(--deep);
  color: #fff;
  border: 0;
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  min-height: 40px;
}
.cookie-btn-secondary {
  background: transparent !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; gap: var(--space-5); }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  :root { --wrap: calc(100% - 32px); }

  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .portal-nav { display: none; }
  .portal-nav.is-open {
    display: block;
    border-bottom: 1px solid var(--line);
  }
  .portal-nav-inner {
    flex-direction: column;
    gap: 0;
    padding: var(--space-2) 0 var(--space-3);
    min-height: 0;
  }
  .portal-nav a {
    padding: 12px 0;
    box-shadow: none;
    border-bottom: 1px solid var(--line);
  }
  .portal-nav a.is-on {
    box-shadow: none;
    color: var(--deep);
    font-weight: 600;
  }

  .portal-main { padding: var(--space-5) var(--space-4) var(--space-6); margin-top: var(--space-4); }
  .facts-wide { grid-template-columns: 1fr; }
  .table-desktop { display: none; }
  .mobile-cards { display: grid; gap: 0; }
  .mobile-cards article {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--line);
  }
  .mobile-cards h3 { margin: 0 0 4px; font-family: var(--sans); font-size: 1rem; }
  .cookie-bar {
    flex-direction: column;
    align-items: stretch;
    bottom: 80px;
  }
  .support-fab { right: 16px; bottom: 16px; }
  .portal-session .who { display: none; }
}
