@import url("https://fonts.googleapis.com/css2?family=Libre+Baskerville:wght@400;700&family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --ink: #18222d;
  --muted: #667381;
  --navy: #102235;
  --navy-2: #1d344a;
  --brick: #a74d3b;
  --brick-dark: #863929;
  --sage: #667a64;
  --paper: #ffffff;
  --warm: #f7f4ee;
  --soft: #eef2f1;
  --line: #d9dfdc;
  --shadow: 0 22px 60px rgba(16, 34, 53, 0.14);
  --radius: 8px;
  --serif: "Libre Baskerville", Georgia, serif;
  --sans: "Manrope", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--warm); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }

.portal-shell { min-height: 100vh; background: linear-gradient(180deg, #f7f4ee 0%, #edf2f0 100%); }
.portal-header { display: flex; align-items: center; width: min(1180px, calc(100% - 36px)); min-height: 86px; margin: 0 auto; gap: 28px; }
.logo-button { padding: 0; border: 0; background: transparent; text-decoration: none; }
.brand-logo { display: block; width: 154px; height: auto; }
.portal-title { margin-left: auto; padding-left: 24px; color: var(--navy); border-left: 1px solid var(--line); font-family: var(--serif); font-size: 18px; }
.back-link, .inline-back { padding: 8px 0; color: var(--muted); border: 0; background: transparent; font-size: 13px; font-weight: 600; text-decoration: none; }
.back-link:hover, .inline-back:hover { color: var(--brick); }
.portal-stage { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: 52px 0 90px; }
.portal-main { min-width: 0; }

.portal-card { padding: 42px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,0.97); box-shadow: var(--shadow); }
.access-card { width: min(540px, 100%); margin: 28px auto 0; }
.portal-card h1, .confirmation-panel h1 { margin: 10px 0 20px; color: var(--navy); font-family: var(--serif); font-size: clamp(32px, 5vw, 44px); font-weight: 400; line-height: 1.16; }
.step-label, .eyebrow { margin: 0; color: var(--brick); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.intro { margin: -4px 0 30px; color: var(--muted); line-height: 1.65; }

form > label, fieldset legend, .availability-heading > label:first-child { display: block; margin: 20px 0 8px; color: var(--navy); font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; padding: 13px 14px; color: var(--ink); border: 1px solid #c8d0cf; border-radius: var(--radius); outline: none; background: #fff; line-height: 1.5; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(29,52,74,.12); }
button:disabled { cursor: wait; opacity: .58; }

.primary-button, .secondary-button { display: inline-flex; justify-content: center; align-items: center; min-height: 48px; padding: 12px 21px; border: 1px solid var(--brick); border-radius: var(--radius); color: #fff; background: var(--brick); font-weight: 700; text-decoration: none; transition: background 150ms ease, transform 150ms ease, border-color 150ms ease; }
.primary-button:hover { background: var(--brick-dark); border-color: var(--brick-dark); }
.primary-button:active, .secondary-button:active { transform: translateY(1px); }
.primary-button.full { width: 100%; margin-top: 20px; }
.secondary-button.dark { color: var(--navy); border-color: #b9c6c4; background: #fff; }
.secondary-button.dark:hover { border-color: var(--navy); }
.full-link { width: 100%; }
.quiet-button { display: inline-flex; align-items: center; padding: 7px 9px; color: var(--muted); border: 0; border-radius: 5px; background: transparent; font-size: 12px; font-weight: 700; text-decoration: none; }
.quiet-button:hover { color: var(--brick); background: #f4f5f3; }
.quiet-link { display: block; margin-top: 22px; color: var(--muted); font-size: 12px; text-align: center; text-decoration: none; }
.quiet-link:hover { color: var(--brick); }

.alert { width: min(1120px, 100%); margin: 0 auto 18px; padding: 13px 16px; border-radius: 7px; font-size: 13px; line-height: 1.55; }
.alert.success { color: #38543c; border: 1px solid #bdd2bd; background: #edf6ec; }
.alert.warning { color: #6e521b; border: 1px solid #dfc991; background: #fff8e4; }
.alert.error { color: var(--brick-dark); border: 1px solid #e3bdb6; background: #fff4f1; }
.support-note, .submission-note { margin-top: 24px; padding: 14px 16px; color: #52626e; border-left: 3px solid var(--sage); background: var(--soft); font-size: 13px; line-height: 1.55; }
.submission-note strong { display: block; margin-bottom: 3px; color: var(--navy); }
.pin-change-panel { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.pin-change-panel summary { width: max-content; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; }
.pin-change-panel summary:hover { color: var(--brick); }
.pin-change-panel p { margin: 14px 0 4px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.pin-change-panel form > label { margin-top: 12px; }
.pin-change-panel .secondary-button { width: 100%; margin-top: 12px; }

.request-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.tenant-summary { position: sticky; top: 24px; padding: 28px; border-radius: 10px; color: #fff; background: var(--navy); }
.tenant-summary .step-label { color: #efc2b6; }
.tenant-summary h2 { margin: 12px 0 3px; font-family: var(--serif); font-size: 23px; font-weight: 400; line-height: 1.35; }
.tenant-summary > p { margin: 0; color: #b9c5cc; font-size: 13px; }
.tenant-summary dl { margin: 30px 0 18px; }
.tenant-summary dl div { padding: 13px 0; border-top: 1px solid rgba(255,255,255,.13); }
.tenant-summary dt { color: #aebbc4; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.tenant-summary dd { margin: 5px 0 0; font-size: 13px; line-height: 1.45; word-break: break-word; }
.tenant-summary .inline-back { color: #efc2b6; }
.tenant-ticket-list { margin: 8px 0 22px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.13); }
.tenant-ticket-list h3 { margin: 0 0 8px; color: #aebbc4; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.tenant-ticket-list a { display: block; width: 100%; padding: 10px 0; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); text-align: left; text-decoration: none; }
.tenant-ticket-list a.active, .tenant-ticket-list a:hover { color: #efc2b6; }
.tenant-ticket-list a strong, .tenant-ticket-list a span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-ticket-list a strong { font-size: 12px; }
.tenant-ticket-list a span { margin-top: 3px; color: #aebbc4; font-size: 10px; }
.request-card { padding: 42px 48px; }
fieldset { margin: 0 0 26px; padding: 0; border: 0; }
fieldset legend { margin-top: 4px; }
.category-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.category { display: flex; align-items: center; min-height: 52px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); color: #40515e; cursor: pointer; font-size: 13px; font-weight: 600; }
.category input { width: auto; margin: 0 9px 0 0; accent-color: var(--brick); }
.category.selected { color: var(--navy); border-color: var(--navy); background: #f1f5f4; }
.other-guidance { margin: 12px 0 0; padding: 12px 14px; color: #52626e; border-left: 3px solid var(--sage); background: var(--soft); font-size: 12px; line-height: 1.55; }
.availability-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-top: 20px; }
.availability-heading > label:first-child { margin: 0 0 8px; }
.flexible-toggle { display: inline-flex; align-items: center; min-height: 46px; gap: 10px; margin-bottom: 8px; padding: 10px 16px; color: #52626e; border: 1px solid #c8d0cf; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 700; }
.flexible-toggle input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: var(--sage); }
.flexible-toggle.active { color: #fff; border-color: var(--sage); background: var(--sage); }
.availability-box { min-height: 170px; }

.confirmation-panel { padding: 10px 10px 28px; text-align: center; }
.confirmation-panel.compact h1 { margin-bottom: 10px; font-size: clamp(30px, 4vw, 40px); }
.confirmation-panel > p:last-child { width: min(590px, 100%); margin: 0 auto; color: var(--muted); line-height: 1.65; }
.ticket-card { padding: 34px 38px; }
.ticket-topline { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; font-weight: 700; }
.status-pill { padding: 6px 10px; color: #425343; border-radius: 999px; background: #dfe9dd; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.ticket-details { margin: 26px 0; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf9; }
.ticket-details h3 { margin: 0 0 7px; color: var(--navy); font-size: 12px; }
.ticket-details h3:not(:first-child) { margin-top: 18px; }
.ticket-details p { margin: 0; color: #40515e; font-size: 13px; line-height: 1.65; }
.conversation { display: grid; gap: 13px; margin: 28px 0; }
.message { padding: 16px 18px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.message.management { border-left: 4px solid var(--brick); background: #fbf7f4; }
.message.tenant { border-left: 4px solid var(--sage); background: #f6f8f6; }
.message > div { display: flex; justify-content: space-between; gap: 15px; }
.message strong { color: var(--navy); font-size: 13px; }
.message time { color: var(--muted); font-size: 10px; }
.message p { margin: 8px 0 0; color: #40515e; font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.reply-form { padding-top: 22px; border-top: 1px solid var(--line); }
.reply-form > label { display: block; margin: 0 0 8px; color: var(--navy); font-size: 13px; font-weight: 700; }
.reply-form .primary-button { margin-top: 12px; }
.ticket-actions { display: flex; justify-content: flex-end; align-items: center; gap: 20px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }

.admin-login-shell { display: grid; place-items: center; min-height: 100vh; padding: 80px 20px; color: var(--ink); background: linear-gradient(160deg, #f7f4ee, #e7eeeb); }
.admin-logo-link { position: absolute; top: 30px; left: 36px; }
.admin-login-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.admin-login-card h1, .admin-heading h1 { margin: 8px 0 12px; color: var(--navy); font-family: var(--serif); font-weight: 400; }
.admin-login-card h1 { font-size: 37px; }
.admin-login-card > p:not(.step-label) { margin: 0 0 26px; color: var(--muted); line-height: 1.6; }
.admin-shell { min-height: 100vh; background: #f4f6f4; }
.admin-header { display: flex; justify-content: space-between; align-items: center; min-height: 70px; padding: 10px max(24px, calc((100% - 1220px) / 2)); border-bottom: 1px solid var(--line); background: #fff; }
.admin-header > div { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 12px; font-weight: 600; }
.admin-header form { margin: 0; }
.admin-brand { width: 124px; }
.admin-content { width: min(1220px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 90px; }
.admin-heading, .section-heading, .ticket-drawer-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.admin-heading { margin-bottom: 22px; }
.admin-heading h1 { font-size: 43px; }
.admin-alert { margin: 14px 0; padding: 13px 16px; border-radius: 7px; font-size: 12px; line-height: 1.6; }
.admin-alert.notice { color: #52626e; border: 1px solid #d2ddda; background: #edf3f1; }
.admin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 24px 0 34px; }
.admin-stats > div { padding: 22px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.admin-stats strong, .admin-stats span { display: block; }
.admin-stats strong { color: var(--navy); font-family: var(--serif); font-size: 32px; font-weight: 400; }
.admin-stats span { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.admin-section, .ticket-drawer { margin-top: 24px; padding: 28px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.section-heading { margin-bottom: 18px; }
.section-heading h2, .ticket-drawer h2, .contact-modal h2, .setup-card h1 { margin: 4px 0 0; color: var(--navy); font-family: var(--serif); font-size: 27px; font-weight: 400; }
.section-heading > span { color: var(--muted); font-size: 11px; }
.ticket-table { border-top: 1px solid var(--line); }
.ticket-row { display: grid; grid-template-columns: 38px minmax(260px, 1fr) 150px 86px; align-items: center; min-height: 74px; border-bottom: 1px solid var(--line); }
.ticket-row.selected { margin-inline: -12px; padding-inline: 12px; border-radius: 7px; background: #f2f5f3; }
.priority-form, .status-form { margin: 0; }
.priority-star { width: 32px; height: 32px; padding: 0; color: #a5afad; border: 0; border-radius: 50%; background: transparent; font-size: 23px; }
.priority-star.active { color: #c47b25; }
.priority-star:hover { background: #f3f0e9; }
.ticket-row-main { display: block; min-width: 0; padding: 11px 12px 11px 2px; border: 0; background: transparent; text-align: left; text-decoration: none; }
.ticket-row-main span, .ticket-row-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row-main .ticket-number { margin-bottom: 4px; color: var(--brick); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.ticket-row-main strong { color: var(--navy); font-size: 13px; }
.ticket-row-main span:last-child { margin-top: 4px; color: var(--muted); font-size: 11px; }
.ticket-row select { width: 140px; padding: 8px; font-size: 11px; }
.ticket-row > time { color: var(--muted); font-size: 10px; text-align: right; }
.empty-state { padding: 35px 10px; color: var(--muted); font-size: 12px; text-align: center; }
.ticket-drawer { box-shadow: 0 18px 46px rgba(16,34,53,.08); }
.ticket-drawer-heading > div > p { margin: 0; color: var(--muted); font-size: 11px; }
.ticket-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 24px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--line); }
.ticket-facts > div { padding: 14px; background: #fafbf9; }
.ticket-facts span, .ticket-facts strong { display: block; }
.ticket-facts span { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ticket-facts strong { margin-top: 5px; color: var(--navy); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.admin-ticket-details { margin-top: 0; }
.delete-ticket-hint { margin: 22px 0 0; color: var(--muted); font-size: 11px; text-align: right; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-top: 28px; padding: 18px; border: 1px solid #e3bdb6; border-radius: 8px; background: #fff8f6; }
.danger-zone strong { color: var(--brick-dark); font-size: 12px; }
.danger-zone p { margin: 4px 0 0; color: #72554f; font-size: 11px; line-height: 1.5; }
.danger-zone form { flex: 0 0 auto; margin: 0; }
.danger-button { min-height: 40px; padding: 9px 14px; color: #fff; border: 1px solid var(--brick-dark); border-radius: 6px; background: var(--brick-dark); font-size: 11px; font-weight: 700; }
.danger-button:hover { border-color: #61281f; background: #61281f; }
.contact-list { border-top: 1px solid var(--line); }
.contact-row { display: grid; grid-template-columns: 1fr 1.25fr 1.2fr auto; gap: 20px; align-items: center; min-height: 78px; border-bottom: 1px solid var(--line); }
.contact-row.inactive { opacity: .52; }
.contact-row strong, .contact-row span { display: block; }
.contact-row strong { overflow: hidden; color: var(--navy); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.contact-row span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.contact-actions { display: flex; align-items: center; }
.contact-actions form { margin: 0; }
.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(16,34,53,.56); }
.contact-modal { width: min(740px, 100%); max-height: calc(100vh - 48px); overflow: auto; padding: 30px; border-radius: 12px; background: #fff; box-shadow: 0 28px 80px rgba(0,0,0,.25); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; margin-top: 24px; }
.form-grid label { color: var(--navy); font-size: 12px; font-weight: 700; }
.form-grid input { margin-top: 7px; font-weight: 400; }
.form-grid .wide, .pin-field { grid-column: 1 / -1; }
.pin-field { max-width: 300px; }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }

.setup-body { min-height: 100vh; background: linear-gradient(160deg, #f7f4ee, #e7eeeb); }
.setup-shell { width: min(860px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 80px; }
.setup-logo { display: block; width: 155px; margin: 0 auto 28px; }
.setup-card { padding: 38px; }
.setup-card h1 { margin-bottom: 18px; font-size: 36px; }
.setup-card h2 { margin: 34px 0 0; color: var(--navy); font-family: var(--serif); font-size: 22px; font-weight: 400; }
.setup-card code { padding: 2px 5px; border-radius: 4px; background: var(--soft); }
.optional-settings { margin-top: 28px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf9; }
.optional-settings summary { color: var(--navy); cursor: pointer; font-size: 13px; font-weight: 700; }

@media (max-width: 800px) {
  .request-layout { grid-template-columns: 1fr; }
  .tenant-summary { position: static; }
  .tenant-summary dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
  .ticket-row { grid-template-columns: 36px minmax(180px, 1fr) 130px; }
  .ticket-row > time { display: none; }
  .ticket-facts { grid-template-columns: repeat(2, 1fr); }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .danger-button { width: 100%; }
  .contact-row { grid-template-columns: 1fr 1fr; padding: 14px 0; }
  .contact-actions { justify-content: flex-end; }
}

@media (max-width: 560px) {
  .portal-header { width: calc(100% - 28px); }
  .brand-logo { width: 132px; }
  .portal-title { display: none; }
  .back-link { margin-left: auto; }
  .portal-stage { width: calc(100% - 24px); padding-top: 28px; }
  .portal-card, .request-card, .ticket-card { padding: 28px 22px; }
  .category-grid { grid-template-columns: 1fr; }
  .availability-heading { align-items: flex-start; flex-direction: column; gap: 0; }
  .flexible-toggle { justify-content: center; width: 100%; margin-bottom: 12px; }
  .tenant-summary dl { grid-template-columns: 1fr; }
  .ticket-actions { align-items: stretch; flex-direction: column; }
  .ticket-actions a { width: 100%; }
  .message > div { align-items: flex-start; flex-direction: column; gap: 3px; }
  .admin-logo-link { top: 24px; left: 22px; }
  .admin-content { width: calc(100% - 24px); padding-top: 28px; }
  .admin-heading { align-items: stretch; flex-direction: column; }
  .admin-heading h1 { font-size: 36px; }
  .admin-stats { grid-template-columns: 1fr; }
  .admin-section, .ticket-drawer { padding: 20px 15px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .ticket-row { grid-template-columns: 34px minmax(0, 1fr); padding: 5px 0 12px; }
  .ticket-row .status-form { grid-column: 2; width: 100%; }
  .ticket-row select { width: 100%; }
  .ticket-facts { grid-template-columns: 1fr; }
  .contact-row { grid-template-columns: 1fr; gap: 10px; }
  .contact-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide, .pin-field { grid-column: auto; max-width: none; }
  .contact-modal { padding: 24px 20px; }
  .setup-shell { width: calc(100% - 20px); padding-top: 22px; }
  .setup-card { padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
