:root {
    --color-primary:       #01514E;
    --color-primary-dark:  #013D3A;
    --color-secondary:     #F27041;
    --color-accent:        #17B092;
    --color-accent-light:  #A5F1EA;
    --color-bg:            #F5F8FA;
    --color-surface:       #FFFFFF;
    --color-bg-alt:        #EEF4F7;
    --color-text:          #00302E;
    --color-text-muted:    #53616E;
    --color-border:        #E2E8EC;
    --color-danger:        #C0392B;
    --color-warn:          #D9A400;
    --radius:              10px;
    --shadow:              0 1px 2px rgba(0, 48, 46, .06), 0 4px 16px rgba(0, 48, 46, .06);
    --desk-size:           38px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
}
a { color: var(--color-primary); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: 1.25rem 0; }
p { margin: 0 0 .75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: .85rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: 1rem; }
.spacer { flex: 1; }
.inline { display: inline; }

/* ── Layout ─────────────────────────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.topbar { background: var(--color-surface); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 0 1rem; display: flex; align-items: center; gap: 1.5rem; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; color: var(--color-primary); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--color-primary); position: relative; flex: none; }
.brand-mark::before { content: ''; position: absolute; left: 5px; right: 5px; top: 9px; height: 4px; border-radius: 2px; background: var(--color-accent-light); }
.brand-mark::after { content: ''; position: absolute; left: 7px; top: 13px; width: 3px; height: 8px; border-radius: 1px; background: var(--color-accent-light); box-shadow: 9px 0 0 var(--color-accent-light); }
.brand-company { font-weight: 400; color: var(--color-text-muted); font-size: .9rem; padding-left: .55rem; border-left: 1px solid var(--color-border); }
.brand-lg { font-size: 1.4rem; margin-bottom: 1.5rem; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { padding: .45rem .8rem; border-radius: 8px; text-decoration: none; color: var(--color-text-muted); font-weight: 500; font-size: .95rem; }
.mainnav a:hover { background: var(--color-bg-alt); color: var(--color-text); }
.mainnav a.active { background: var(--color-bg-alt); color: var(--color-primary); }
.usermenu { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--color-text); font-weight: 500; font-size: .9rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--color-accent-light); color: var(--color-primary-dark); display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; flex: none; letter-spacing: .02em; }
.avatar-sm { width: 24px; height: 24px; font-size: .65rem; vertical-align: middle; margin-right: .25rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.crumbs { margin: 0; font-size: .85rem; color: var(--color-text-muted); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }

/* ── Cards / tables / forms ─────────────────────────────────────────── */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card-title { font-size: 1rem; margin-bottom: .75rem; display: flex; align-items: center; gap: .5rem; }
.sub-title { font-size: .9rem; margin: .75rem 0 .35rem; display: flex; gap: .5rem; align-items: baseline; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); padding: .5rem .6rem; border-bottom: 1px solid var(--color-border); }
.table td { padding: .6rem .6rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-muted td { color: var(--color-text-muted); }
.row-muted td { opacity: .6; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.dl dt { color: var(--color-text-muted); }
.dl dd { margin: 0; }
.field { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.form-input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--color-border); border-radius: 8px; font: inherit; color: inherit; background: var(--color-surface); }
.form-input:focus { outline: 2px solid var(--color-accent); outline-offset: 1px; border-color: var(--color-accent); }
.form-input-sm { padding: .3rem .5rem; font-size: .85rem; width: auto; }
select.form-input { appearance: auto; }
.hint { font-size: .8rem; color: var(--color-text-muted); margin: .3rem 0 0; }
.check { display: flex; gap: .5rem; align-items: center; cursor: pointer; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { padding: .55rem .7rem; border: 1px solid var(--color-border); border-right: 0; border-radius: 8px 0 0 8px; background: var(--color-bg-alt); color: var(--color-text-muted); }
.input-prefix .form-input { border-radius: 0 8px 8px 0; }
.inline-form { display: flex; gap: .5rem; margin-top: .75rem; max-width: 480px; }
.inline-form .form-input { flex: 1; }
.row-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { display: inline; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1rem; border-radius: 8px; font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; text-decoration: none; line-height: 1.3; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-bg-alt); }
.btn-ghost { background: transparent; color: var(--color-text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--color-bg-alt); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--color-danger); border-color: transparent; }
.btn-danger-ghost:hover { background: #FBEDEB; }
.btn-sm { padding: .3rem .65rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--color-bg-alt); color: var(--color-text-muted); }
.badge-ok { background: #E3F7F1; color: #0B6E58; }
.badge-off { background: #F3E6E4; color: var(--color-danger); }
.badge-slot-am { background: #FFF2C2; color: #7A5B00; }
.badge-slot-pm { background: #E4E9FF; color: #2E3E9E; }
.badge-slot-full { background: #E3F7F1; color: #0B6E58; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .95rem; border: 1px solid; }
.flash-success { background: #E3F7F1; border-color: #B9E9DB; color: #0B6E58; }
.flash-error { background: #FBEDEB; border-color: #F2C9C4; color: var(--color-danger); }
.subnav { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--color-border); }
.subnav a { padding: .5rem .8rem; text-decoration: none; color: var(--color-text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a.active { color: var(--color-primary); border-color: var(--color-primary); }
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state p { color: var(--color-text-muted); max-width: 460px; margin: .5rem auto 1.25rem; }
.empty-inline { text-align: center; color: var(--color-text-muted); margin: 1rem 0 0; }

/* ── Auth ───────────────────────────────────────────────────────────── */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.35rem; }
.subtitle { color: var(--color-text-muted); margin-bottom: 1.25rem; }

/* ── Booking toolbar ────────────────────────────────────────────────── */
.book-toolbar { margin-bottom: 1rem; }
.toolbar-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.select-office { width: auto; min-width: 180px; font-weight: 600; }
.floor-tabs { display: flex; gap: .25rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px; padding: .2rem; }
.floor-tabs .tab { padding: .35rem .8rem; border-radius: 6px; text-decoration: none; color: var(--color-text-muted); font-weight: 500; font-size: .9rem; }
.floor-tabs .tab.active { background: var(--color-primary); color: #fff; }
.segmented { display: flex; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 8px; padding: .2rem; margin-left: auto; }
.segmented a { padding: .35rem .8rem; border-radius: 6px; text-decoration: none; color: var(--color-text-muted); font-weight: 500; font-size: .9rem; }
.segmented a.active { background: var(--color-bg-alt); color: var(--color-primary); }
.date-strip { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: thin; }
.day { flex: none; width: 62px; padding: .45rem .25rem .4rem; border-radius: 10px; background: var(--color-surface); border: 1px solid var(--color-border); text-decoration: none; color: var(--color-text); display: flex; flex-direction: column; align-items: center; line-height: 1.15; position: relative; }
.day .dow { font-size: .7rem; text-transform: uppercase; color: var(--color-text-muted); letter-spacing: .04em; }
.day .num { font-size: 1.2rem; font-weight: 700; }
.day .mon { font-size: .7rem; color: var(--color-text-muted); }
.day.weekend { background: var(--color-bg-alt); }
.day.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.day.active .dow, .day.active .mon { color: rgba(255, 255, 255, .8); }
.day.disabled { opacity: .45; pointer-events: none; }
.day .occ { position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px; background: var(--color-border); overflow: hidden; }
.day .occ::after { content: ''; position: absolute; inset: 0; width: var(--pct); background: var(--color-accent); }
.day.active .occ { background: rgba(255, 255, 255, .3); }
.day.active .occ::after { background: #fff; }
.day-pick { cursor: pointer; }
.day-pick .num { font-size: 1rem; }

/* ── Floor plan ─────────────────────────────────────────────────────── */
.book-layout, .editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.side-col .card { margin-bottom: 1rem; }
.plan-card { padding: 1rem; }
.plan-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: .75rem; }
.plan-title { font-size: 1.15rem; margin: 0; }
.plan-sub { margin: 0; color: var(--color-text-muted); font-size: .9rem; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; gap: .75rem; flex-wrap: wrap; font-size: .78rem; color: var(--color-text-muted); }
.legend li { display: flex; align-items: center; gap: .3rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid transparent; }
.dot.free { background: #fff; border-color: var(--color-accent); }
.dot.partial { background: linear-gradient(90deg, var(--color-warn) 50%, #fff 50%); border-color: var(--color-warn); }
.dot.booked { background: #9AA7B1; border-color: #9AA7B1; }
.dot.mine { background: var(--color-primary); border-color: var(--color-primary); }
.dot.fixed { background: #CBD5DD; border-color: #8D9AA5; }
.dot.blocked { background: repeating-linear-gradient(45deg, #F2C9C4 0 3px, #fff 3px 6px); border-color: var(--color-danger); }
.plan-wrap { overflow: auto; border-radius: 8px; border: 1px solid var(--color-border); background: var(--color-bg-alt); }
.plan { position: relative; width: 100%; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.plan-img { display: block; width: 100%; height: auto; }
.plan-grid { background-color: #fff; background-image: linear-gradient(var(--color-border) 1px, transparent 1px), linear-gradient(90deg, var(--color-border) 1px, transparent 1px); background-size: 40px 40px; }
.markers { position: absolute; inset: 0; }
.desk { position: absolute; width: var(--desk-size); height: var(--desk-size); border-radius: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; cursor: pointer; border: 2px solid var(--color-accent); background: #fff; color: var(--color-primary-dark); box-shadow: 0 1px 4px rgba(0, 48, 46, .25); transition: transform .1s; padding: 0; font-family: inherit; }
.desk:hover, .desk:focus-visible { transform: translate(-50%, -50%) scale(1.12); z-index: 3; outline: none; }
.desk .desk-label { position: absolute; top: calc(100% + 2px); left: 50%; transform: translateX(-50%); font-size: .65rem; font-weight: 600; color: var(--color-text); background: rgba(255, 255, 255, .85); padding: 0 .3rem; border-radius: 4px; white-space: nowrap; pointer-events: none; }
.desk.partial { background: linear-gradient(90deg, #FFE9A8 50%, #fff 50%); border-color: var(--color-warn); }
.desk.partial.partial-pm { background: linear-gradient(90deg, #fff 50%, #FFE9A8 50%); }
.desk.booked { background: #9AA7B1; border-color: #9AA7B1; color: #fff; }
.desk.mine { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.desk.fixed { background: #CBD5DD; border-color: #8D9AA5; color: #2F3E4A; cursor: default; }
.desk.blocked { background: repeating-linear-gradient(45deg, #F2C9C4 0 3px, #fff 3px 6px); border-color: var(--color-danger); color: var(--color-danger); cursor: not-allowed; }
.desk.selected { box-shadow: 0 0 0 3px var(--color-accent-light), 0 1px 4px rgba(0, 48, 46, .25); z-index: 4; }
.plan.editor .desk { cursor: grab; }
.plan.editor .desk.dragging { cursor: grabbing; z-index: 5; transition: none; }
.plan.editor.adding { cursor: crosshair; }
.plan.editor.adding .desk { pointer-events: none; }
.editor-toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; }
#add-desk-btn.active { background: var(--color-secondary); border-color: var(--color-secondary); }

.people, .desk-list { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; font-size: .92rem; }
.people .person-name { font-weight: 500; flex: 1; }
.desk-list li { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--color-border); font-size: .9rem; }
.desk-list li:last-child { border-bottom: 0; }
.desk-list .dot { flex: none; }
.desk-list .name { font-weight: 500; white-space: nowrap; }
.desk-list button { margin-left: auto; }
.desk-list .who { color: var(--color-text-muted); font-size: .82rem; flex: 1; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk.desk-long { font-size: .55rem; letter-spacing: -.02em; }

/* ── Admin office cards ─────────────────────────────────────────────── */
.office-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.office-head h2 { margin-bottom: .15rem; }
.floor-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.floor-list li { display: flex; align-items: center; gap: .75rem; padding: .5rem 0; border-top: 1px solid var(--color-border); }
.floor-link { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: inherit; flex: 1; min-width: 0; }
.floor-thumb { width: 64px; height: 44px; border-radius: 6px; background: var(--color-bg-alt); border: 1px solid var(--color-border); overflow: hidden; flex: none; display: flex; align-items: center; justify-content: center; }
.floor-thumb img { width: 100%; height: 100%; object-fit: cover; }
.floor-thumb.no-plan { background-image: linear-gradient(var(--color-border) 1px, transparent 1px), linear-gradient(90deg, var(--color-border) 1px, transparent 1px); background-size: 8px 8px; }
.floor-meta { display: flex; flex-direction: column; min-width: 0; }
.date-nav { display: flex; gap: .4rem; align-items: center; }
.date-nav .form-input { width: auto; }

/* ── Modal / toast ──────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 48, 46, .45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--color-surface); border-radius: 14px; padding: 1.5rem; width: 100%; max-width: 440px; position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 90vh; overflow: auto; }
.modal-close { position: absolute; top: .6rem; right: .6rem; border: 0; background: transparent; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--color-text-muted); width: 32px; height: 32px; border-radius: 50%; }
.modal-close:hover { background: var(--color-bg-alt); }
.modal h2 { padding-right: 2rem; }
.slot-options { display: grid; gap: .4rem; margin: .75rem 0 1rem; }
.slot-options label { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border: 1px solid var(--color-border); border-radius: 8px; cursor: pointer; }
.slot-options label:has(input:checked) { border-color: var(--color-primary); background: var(--color-bg-alt); }
.slot-options label.disabled { opacity: .5; cursor: not-allowed; }
.slot-options .who { margin-left: auto; font-size: .8rem; color: var(--color-text-muted); }
.booking-rows { list-style: none; margin: .5rem 0 1rem; padding: 0; }
.booking-rows li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--color-border); }
.booking-rows li:last-child { border-bottom: 0; }
.booking-rows .name { flex: 1; font-weight: 500; }
.toast-root { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 60; pointer-events: none; }
.toast { background: var(--color-text); color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: .9rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .25); animation: toast-in .2s ease-out; max-width: 90vw; }
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .book-layout, .editor-layout { grid-template-columns: 1fr; }
    .mainnav { order: 3; width: 100%; flex: none; overflow-x: auto; padding-bottom: .4rem; }
    .topbar-inner { padding-bottom: 0; }
    .user-name { display: none; }
    :root { --desk-size: 30px; }
    .desk .desk-label { display: none; }
    .desk:hover .desk-label { display: block; }
    .segmented { margin-left: 0; }
}
@media (max-width: 560px) {
    .container { padding: 1rem .75rem 2rem; }
    .card { padding: 1rem; }
    .legend { font-size: .72rem; }
    .brand-company { display: none; }
}

/* ── Drawn floor plan (SVG layer) ───────────────────────────────────── */
.layout-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.layout-svg text { font-family: inherit; user-select: none; pointer-events: none; }
.plan.editor.layout-mode .layout-svg { pointer-events: auto; }
.plan.editor.layout-mode .markers { pointer-events: none; opacity: .55; }
.plan.editor.layout-mode.mode-select .shape { cursor: move; }
.plan.editor.mode-rect, .plan.editor.mode-wall { cursor: crosshair; }
.plan.editor.mode-label { cursor: text; }
.layout-svg .shape.selected rect, .layout-svg .shape.selected line:last-child { stroke: var(--color-primary); stroke-width: 5; stroke-dasharray: 14 8; }
.layout-svg .shape.selected text { fill: var(--color-primary); }
.layout-svg .handle { cursor: nwse-resize; pointer-events: auto; }
.layout-svg .handle[data-handle="ne"], .layout-svg .handle[data-handle="sw"] { cursor: nesw-resize; }
.layout-svg .handle[data-handle="p1"], .layout-svg .handle[data-handle="p2"] { cursor: move; }
.layout-svg .drawing rect { fill: rgba(1, 81, 78, .12); stroke: var(--color-primary); stroke-width: 3; stroke-dasharray: 10 6; }
.layout-svg .drawing line { stroke: var(--color-primary); stroke-width: 8; stroke-linecap: round; opacity: .6; }
.tools { margin-left: 0; }
.tools .tool { border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 500; color: var(--color-text-muted); padding: .35rem .7rem; border-radius: 6px; cursor: pointer; }
.tools .tool.active { background: var(--color-primary); color: #fff; }
.swatches { display: flex; gap: .4rem; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 6px; border: 2px solid; cursor: pointer; padding: 0; }
.swatch.active { outline: 2px solid var(--color-primary); outline-offset: 2px; }
