:root {
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17212b;
  background: #f4f7f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --navy: #17324a;
  --navy-2: #234c68;
  --blue: #2d6d96;
  --line: #dbe4ea;
  --muted: #6a7885;
  --soft: #eef3f6;
  --success: #2d7254;
  --warning: #9a5a17;
  --danger: #a83a3a;
  --shadow: 0 10px 30px rgba(23, 50, 74, .07);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f7f9; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea { width: 100%; border: 1px solid #cfdbe2; background: #fff; border-radius: 9px; padding: 10px 12px; color: #17212b; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(45,109,150,.18); border-color: #2d6d96; }
label > span, fieldset legend { display: block; font-size: 12px; font-weight: 700; color: #586977; margin-bottom: 6px; }
fieldset { border: 1px solid #d8e2e8; border-radius: 10px; margin: 0; padding: 12px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 25px; margin-bottom: 0; }
h2 { font-size: 18px; margin-bottom: 5px; }
small { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; word-break: break-all; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { background: var(--navy); color: white; padding: 24px 18px; display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 900; }
.brand strong { display: block; font-size: 17px; }
.brand span { display: block; font-size: 11px; color: #bcd0dc; margin-top: 2px; }
.org-switcher { margin-bottom: 18px; }
.org-switcher span { color: #bcd0dc; }
.org-switcher select { background: #27485f; color: white; border-color: #45667d; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: #dce8ee; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.sidebar nav a:hover, .sidebar nav a.active { background: #315a74; color: white; }
.sidebar-footer { margin-top: auto; padding: 14px 12px; background: rgba(255,255,255,.06); border-radius: 10px; }
.sidebar-footer span, .sidebar-footer small { display: block; }
.sidebar-footer small { color: #bcd0dc; margin-top: 3px; font-size: 11px; }
.main-content { min-width: 0; padding: 0 30px 40px; }
.topbar { height: 92px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e0e7eb; margin-bottom: 28px; }
.eyebrow { color: #5e7280; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 800; }
.security-chip { font-size: 12px; color: var(--success); background: #eaf5ee; border: 1px solid #cfe6d8; padding: 8px 11px; border-radius: 999px; }
.security-chip.provider-chip { color: #6f4514; background: #fff2df; border-color: #efd3a9; }
.account-platform-admin .sidebar { background: #3e2f28; }
.account-platform-admin .sidebar nav a:hover, .account-platform-admin .sidebar nav a.active { background: #665043; }
.account-platform-admin .org-switcher select { background: #5a463b; border-color: #80695c; }
.page-stack { display: flex; flex-direction: column; gap: 20px; }
.page-loading, .loading-screen { padding: 80px; text-align: center; color: var(--muted); }
.fatal, .setup-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.fatal { text-align: center; }
.setup-card { width: min(520px, 100%); background: white; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 32px; border-radius: 16px; }
.setup-card p { color: var(--muted); line-height: 1.6; }

.panel { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-header p { color: var(--muted); font-size: 13px; margin-bottom: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.metric-card { background: white; border: 1px solid var(--line); border-radius: 13px; padding: 18px; box-shadow: var(--shadow); }
.metric-card span { display: block; font-size: 12px; font-weight: 800; color: var(--muted); }
.metric-card strong { display: block; font-size: 24px; margin: 8px 0 5px; color: var(--navy); }
.metric-card.warning { border-left: 4px solid #c78639; }
.compact-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.principle-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }
.principle-grid div { background: #f7fafb; border: 1px solid #e1e8ec; border-radius: 10px; padding: 15px; }
.principle-grid p { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 7px 0 0; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; align-items: end; }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.form-grid.single { grid-template-columns: 1fr; }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.primary, .secondary { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 800; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: #235d81; }
.secondary { color: var(--navy); background: #e9f0f4; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.compact { padding: 7px 10px; font-size: 12px; }
.mode-explainer { display: flex; gap: 14px; align-items: center; border: 1px solid #efd3a9; background: #fff7ea; color: #684116; border-radius: 12px; padding: 14px 16px; }
.mode-explainer.customer { border-color: #cfe1ec; background: #edf6fb; color: #254f69; }
.mode-explainer strong { white-space: nowrap; }
.mode-explainer span { font-size: 13px; line-height: 1.5; }
.closed-toggle { display: inline-flex; width: fit-content; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.closed-toggle input { width: auto; }
.form-error, .form-notice { border-radius: 10px; padding: 13px 15px; font-size: 13px; }
.form-error { color: #842f2f; background: #fdeeee; border: 1px solid #f1cccc; }
.form-notice { color: #276347; background: #eaf5ee; border: 1px solid #cde4d5; }
.upload-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.upload-form small { grid-column: 1/-1; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.check { display: flex; gap: 7px; align-items: center; font-size: 13px; }
.check input { width: auto; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: #5d6f7c; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid #edf1f3; vertical-align: top; }
td strong, td small { display: block; }
td small { margin-top: 4px; }
.status-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 800; color: #415562; background: #edf2f5; white-space: nowrap; }
.status-overdue, .status-emergency, .status-cancelled, .status-declined { color: #8e3030; background: #fdecec; }
.status-paid, .status-active, .status-completed, .status-matched { color: #286449; background: #e8f5ed; }
.status-partial, .status-high, .status-waiting, .status-quoted { color: #875217; background: #fff2df; }
.status-draft, .status-new, .status-submitted, .status-unmatched { color: #365f79; background: #e8f2f8; }
.inline-actions { display: flex; gap: 8px; align-items: center; }
.inline-actions select { min-width: 125px; padding: 6px; }

.property-list { display: grid; gap: 12px; }
.property-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 15px; border: 1px solid #e0e8ec; border-radius: 11px; }
.property-card strong, .property-card span { display: block; }
.property-card > div > span { color: var(--muted); font-size: 12px; margin-top: 5px; }
.property-count { font-size: 20px; font-weight: 900; color: var(--navy); }
.unit-chips { grid-column: 1/-1; display: flex; flex-wrap: wrap; gap: 6px; }
.unit-chips span { background: var(--soft); border-radius: 999px; padding: 5px 8px; font-size: 11px; }
.ticket-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.ticket-card { border: 1px solid #dde5e9; border-left: 4px solid #7792a3; border-radius: 11px; padding: 15px; background: #fff; }
.ticket-card.urgency-emergency { border-left-color: var(--danger); }
.ticket-card.urgency-high { border-left-color: #c47c2c; }
.ticket-top { display: flex; justify-content: space-between; gap: 10px; }
.ticket-top strong, .ticket-top span { display: block; }
.ticket-top span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ticket-card p { font-size: 13px; color: #52636f; min-height: 38px; margin: 13px 0; }
.ticket-meta, .ticket-cost { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 10px; font-size: 11px; color: var(--muted); }
.document-list { display: grid; gap: 9px; }
.document-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; border: 1px solid #e1e8ec; border-radius: 10px; padding: 13px; }
.document-row strong, .document-row span { display: block; }
.document-row span { color: var(--muted); font-size: 12px; margin-top: 4px; }
.empty-state { text-align: center; padding: 32px; color: var(--muted); border: 1px dashed #cbd8df; border-radius: 10px; }
.empty-state strong { color: #405563; }
.empty-state p { margin: 7px 0 0; font-size: 13px; }
.detail-list { margin: 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid #edf1f3; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 800; text-align: right; }
.risk-list { margin: 0; padding-left: 20px; color: #4e606c; line-height: 1.9; }

@media (max-width: 1100px) {
  .metric-grid, .ticket-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .principle-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-4 { grid-column: span 2; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; min-height: 0; padding: 16px; }
  .sidebar nav { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); }
  .sidebar nav a { text-align: center; font-size: 12px; padding: 8px 5px; }
  .sidebar-footer { display: none; }
  .main-content { padding: 0 14px 30px; }
  .topbar { height: 78px; }
  .security-chip { display: none; }
  .metric-grid, .compact-grid, .two-column, .ticket-grid, .principle-grid { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: span 1; }
  .panel { padding: 15px; }
  .upload-form { grid-template-columns: 1fr; }
  .document-row { align-items: flex-start; flex-direction: column; }
  .mode-explainer { align-items: flex-start; flex-direction: column; gap: 5px; }
}

.dev-account-switcher { border-color: #7a9ab0; }
.account-management-agent .sidebar { background: #254b45; }
.account-management-agent .sidebar nav a:hover, .account-management-agent .sidebar nav a.active { background: #35675e; }
.sidebar nav button { width: 100%; border: 0; background: transparent; color: #dce8ee; text-align: left; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.sidebar nav button:hover, .sidebar nav button.active { background: #315a74; color: white; }
.account-platform-admin .sidebar nav button:hover, .account-platform-admin .sidebar nav button.active { background: #665043; }
.account-management-agent .sidebar nav button:hover, .account-management-agent .sidebar nav button.active { background: #35675e; }
.demo-warning { display: flex; gap: 14px; align-items: center; margin: -10px 0 22px; padding: 12px 15px; background: #fff4df; border: 1px solid #e8cf9f; border-radius: 11px; color: #694716; font-size: 13px; }
.demo-warning strong { white-space: nowrap; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.action-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.file-button { display: grid; place-items: center; text-align: center; cursor: pointer; }
.file-button input { display: none; }
.danger-button { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 800; color: #8b2f2f; background: #fde9e9; }
.account-corporate-customer .sidebar { background: #17324a; }
.account-individual-customer .sidebar { background: #273d5a; }
textarea { min-height: 90px; resize: vertical; }
@media (max-width: 760px) {
  .sidebar nav button { text-align: center; font-size: 12px; padding: 8px 5px; }
  .demo-warning { align-items: flex-start; flex-direction: column; gap: 4px; }
  .action-grid { grid-template-columns: 1fr; }
}
