:root {
  --bg: #f4f6f9; --surface: #fff; --alt: #f8fafc; --border: #cbd5e1; --line: #e2e8f0;
  --ink: #1e293b; --muted: #64748b; --primary: #1d4ed8; --primary-h: #1e40af; --soft: #eff6ff;
  --ok-bg: #ecfdf5; --ok: #065f46; --warn-bg: #fffbeb; --warn: #92400e; --bad-bg: #fef2f2; --bad: #991b1b;
  --fs: 1;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f172a; --surface: #1e293b; --alt: #172033; --border: #334155; --line: #263449; --ink: #e2e8f0; --muted: #94a3b8;
    --soft: #1e3a8a33; --ok-bg: #064e3b55; --ok: #6ee7b7; --warn-bg: #78350f55; --warn: #fcd34d; --bad-bg: #7f1d1d55; --bad: #fca5a5; }
}
* { box-sizing: border-box; }
body { margin: 0; font: calc(14px * var(--fs))/1.45 Inter, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); font-size: .9em; }
h1 { font-size: 1.45em; margin: 0 0 .2em; } h2 { font-size: 1.15em; margin: 0 0 .6em; } h3 { margin: .2em 0 .5em; }

.top { background: #0f172a; color: #f8fafc; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; flex-wrap: wrap; }
.top .brand { font-weight: 700; font-size: 1.1em; } .top .brand b { color: #60a5fa; }
.top .grp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top select, .top button { background: #1e293b; color: #f8fafc; border: 1px solid #334155; border-radius: 6px; padding: 5px 9px; font: inherit; cursor: pointer; width: auto; }
.strip { background: #172554; color: #dbeafe; padding: 6px 16px; display: flex; gap: 18px; flex-wrap: wrap; font-size: .92em; border-bottom: 1px solid #1e3a8a; }
.strip b { color: #fff; } .strip .total { margin-left: auto; font-weight: 600; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 90px); }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 10px 8px; }
.side h4 { margin: 10px 8px 4px; font-size: .75em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; }
.side button:hover { background: var(--alt); } .side button.on { background: var(--soft); color: var(--primary); font-weight: 600; }
main { padding: 18px 22px; max-width: 1200px; width: 100%; }
@media (max-width: 760px) { .shell { grid-template-columns: 1fr; } .side { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); } .side h4 { display: none; } .side button { white-space: nowrap; width: auto; } main { padding: 14px; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi .l { color: var(--muted); font-size: .85em; } .kpi .v { font-size: 1.45em; font-weight: 700; }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--alt); font-weight: 600; } td.r, th.r { text-align: right; }
.tablewrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .82em; font-weight: 600; background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--primary); border-color: var(--primary); }
label { display: block; font-size: .85em; font-weight: 600; margin-bottom: 3px; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font: inherit; background: var(--surface); color: var(--ink); }
textarea { min-height: 90px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 10px; align-items: end; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink); padding: 6px 12px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.p { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.p:hover { background: var(--primary-h); }
.btn.d { color: var(--bad); } .btn.s { padding: 3px 9px; font-size: .88em; }
.notice { padding: 9px 12px; border-radius: 6px; margin-bottom: 12px; background: var(--soft); border: 1px solid #93c5fd55; }
.notice.err { background: var(--bad-bg); color: var(--bad); border-color: #ef444455; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.auth { max-width: 400px; margin: 8vh auto; } .center { text-align: center; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; } .steps span { padding: 4px 10px; border-radius: 999px; background: var(--alt); border: 1px solid var(--border); font-size: .85em; }
.steps span.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg { border-left: 3px solid var(--border); padding: 6px 12px; margin-bottom: 10px; background: var(--alt); border-radius: 0 6px 6px 0; }
.msg.open { border-color: #f59e0b; } .msg pre { white-space: pre-wrap; font: inherit; margin: 4px 0; }
.msg .mh { cursor: pointer; padding: 2px 0; } .msg .mh:hover b { text-decoration: underline; }
.msg.unread { border-left-color: var(--primary); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); } .msg.unread .mh b { font-weight: 800; }
.furow { border-left: 3px solid var(--border); padding: 6px 10px; margin-bottom: 8px; } .furow.due { border-left-color: #dc2626; }
.furow .fubtns { margin-top: 4px; } .badge.due { background: #fee2e2; color: #991b1b; }
.msg .fuform, .msg .reply { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); } .msg .fuform input[type=date] { width: auto; }
.newdot { color: var(--primary); font-size: 12px; margin-right: 4px; }
.cnt { display: inline-block; background: #dc2626; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 6px; line-height: 16px; margin-left: 4px; font-weight: 700; vertical-align: middle; }
.chk { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; font-weight: 500; } .chk input { width: auto; }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

.portal-tag { font-size: .7em; background: #334155; border-radius: 10px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; font-weight: 500; }
.top button.switch { background: #2563eb; border-color: #2563eb; }
.menubar { background: #0ea5e9; display: flex; gap: 2px; padding: 0 12px; flex-wrap: wrap; position: relative; z-index: 5; }
.menubar .mi, .menubar .mb { background: none; border: 0; color: #fff; font: inherit; font-weight: 600; padding: 10px 14px; cursor: pointer; border-radius: 0; }
.menubar .mi.on, .menubar .dd.on > .mb, .menubar .mi:hover, .menubar .mb:hover { background: #0284c7; }
.menubar .dd { position: relative; padding: 0; }
.menubar .ddm { display: none; position: absolute; top: 100%; left: 0; background: #7dd3fc; min-width: 220px; box-shadow: 0 6px 16px rgba(0,0,0,.2); }
.menubar .dd:hover .ddm, .menubar .dd:focus-within .ddm, .menubar .ddm.open { display: block; }
.menubar .ddm button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 14px; font: inherit; color: #0c4a6e; font-weight: 600; cursor: pointer; }
.menubar .ddm button:hover, .menubar .ddm button.on { background: #bae6fd; }
.shell1 { min-height: calc(100vh - 140px); }

/* One login, two views: segmented switch between the owner's own unit and the management screens */
.portal-switch { display: inline-flex; border: 1px solid #475569; border-radius: 8px; overflow: hidden; }
.top .portal-switch button { border: 0; border-radius: 0; background: transparent; color: #cbd5e1; padding: 6px 12px; font-weight: 600; }
.top .portal-switch button.on { background: var(--primary); color: #fff; }
/* Sandbox */
.demo-bar { background: #fef3c7; color: #78350f; border-bottom: 1px solid #f59e0b; padding: 6px 16px; font-size: .9em; text-align: center; }
.demo-bar a { color: #78350f; font-weight: 600; margin-left: 8px; }
.demo-panel { max-width: 980px; margin: 16px auto; border: 2px dashed #f59e0b; }
.demo-panel .badge { margin: 1px; }
/* Roles editor: permissions grouped by area */
.permgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.permgrid fieldset { border: 1px solid var(--line, #e2e8f0); border-radius: 8px; padding: 6px 10px; margin: 0; }
.permgrid legend { font-weight: 700; font-size: .85em; color: var(--muted); padding: 0 4px; }
.permgrid .chk { display: block; margin: 3px 0; }
.ok-ink { color: #047857; }
/* Notifications bell */
.top button.bell { position: relative; }
.bell .dot { position: absolute; top: -6px; right: -6px; background: #dc2626; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 5px; line-height: 16px; }
/* Ticket history, notifications */
.ev { border-left: 3px solid #cbd5e1; padding: 6px 10px; margin: 8px 0; }
.ev.internal { border-left-color: #f59e0b; background: #fffbeb; }
.ev.unread { border-left-color: var(--primary); background: var(--soft); }
.pre { white-space: pre-wrap; }
tr.hl td { background: #fff7ed; }
.badge.warn { background: #fef3c7; color: #92400e; }
/* Announcements */
.ann.imp-important { border-left: 4px solid #f59e0b; }
.ann.imp-urgent { border-left: 4px solid #dc2626; }
.ann.withdrawn { opacity: .6; }
.ann.withdrawn .pre { text-decoration: line-through; }
/* Pay guide, receipts */
.paymethod { border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.receipt { background: #ecfdf5; border-radius: 6px; padding: 6px 10px; }
.summary-preview h3 { margin: 8px 0 4px; }

/* first sign-in: big language choices */
.langpick { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.langpick label { border: 2px solid #cbd5e1; border-radius: 10px; padding: 12px 20px; cursor: pointer; font-size: 1.1em; font-weight: 600; background: #fff; }
.langpick label.on { border-color: var(--primary); background: #eff6ff; }
.langpick input { margin-right: 8px; width: auto; display: inline; }

/* Phones: keep the header short so the page content starts higher */
@media (max-width: 600px) {
  .strip > span:not(.total) { display: none; } .strip { padding-top: 4px; padding-bottom: 4px; }
  .top .muted { display: none; } .top { padding-top: 6px; padding-bottom: 6px; gap: 6px; }
  .top [data-act=font], .top .grp > span { display: none; } /* phones zoom by themselves; the name is shown under Settings */
  .top select[data-change=complex] { max-width: 60vw; }
  .top button, .top select { padding: 4px 8px; }
  .menubar .mi, .menubar .mb { padding: 6px 10px; }
  .card { padding: 12px; } h1 { font-size: 1.35em; margin: 8px 0; }
}

/* Budget bars, printable statements and receipts */
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 3px; } .bar span { display: block; height: 100%; background: var(--primary); } .bar span.over { background: #dc2626; }
td.neg { color: #dc2626; }
.printpage { max-width: 820px; margin: 16px auto; background: var(--surface); padding: 24px 28px; border-radius: 10px; }
.phead { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--ink, #0f172a); padding-bottom: 10px; margin-bottom: 14px; }
.rcpt { width: 100%; border-collapse: collapse; } .rcpt th { text-align: left; width: 34%; color: var(--muted); font-weight: 600; } .rcpt th, .rcpt td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.printpage.wide { max-width: 1240px; }
table.rep { font-size: .88em; } table.rep tr.tot td { border-top: 2px solid var(--line); }
@media print {
  body { background: #fff !important; color: #000 !important; } .noprint, .demo-bar, .top, .menubar { display: none !important; }
  .printpage { margin: 0; padding: 0; max-width: none; box-shadow: none; } a { color: #000; text-decoration: none; }
  table.rep { font-size: 8.5pt; } table.rep thead { display: table-header-group; } table.rep tr { break-inside: avoid; }
  .printpage .tablewrap { overflow: visible !important; }
}

/* Tasks board */
.kanban { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; }
.kcol { flex: 0 0 272px; background: var(--alt); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 120px; }
.kcol.over { outline: 2px dashed var(--primary); }
.khead { display: flex; align-items: center; gap: 6px; padding: 4px 4px 8px; } .khead .kact { margin-left: auto; } .khead .kact .btn { padding: 0 6px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.kcard:hover { border-color: var(--primary); } .kcard.dragging { opacity: .5; }
.kcard.urgent { border-left-color: #dc2626; } .kcard.high { border-left-color: #f59e0b; } .kcard.low { border-left-color: #94a3b8; }
.ktitle { font-weight: 600; } .kmeta { display: flex; gap: 10px; flex-wrap: wrap; font-size: .85em; color: var(--muted); margin-top: 4px; }
.kmeta .late { color: #dc2626; font-weight: 700; } .kmeta .ok { color: #16a34a; } .kempty { text-align: center; font-size: .9em; }
.kpeople { display: flex; gap: 4px; margin-top: 6px; } .chip { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; }
.chip.ext { background: #64748b; }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; }
.modal { position: fixed; z-index: 51; top: 4vh; left: 50%; transform: translateX(-50%); width: min(760px, calc(100vw - 32px)); max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 12px; padding: 16px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal h3 { margin: 16px 0 6px; }
.clitem { padding: 2px 0; } .struck { text-decoration: line-through; color: var(--muted); }
.tfiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 8px; }
.tfile { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: .9em; word-break: break-word; }
.tfile img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; } .tfile .ficon { font-size: 32px; width: 64px; text-align: center; }
