/* Cabinet and login. Tokens and controls are in base.css. */
html, body { min-height: 100%; }
.num, .c-sum, .stat b { font-variant-numeric: tabular-nums; }

/* ---------- shell: rail on the left, tabs at the bottom on a phone ---------- */
.rail {
  position: fixed; inset: 0 auto 0 0; width: 248px; z-index: 20; display: flex; flex-direction: column; gap: 22px;
  padding: 18px 14px; background: var(--sunk); border-right: 1px solid var(--line);
}
.view { margin-left: 248px; padding: 34px 40px 72px; max-width: 1400px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; padding: 2px 4px; }
.brand img { width: 46px; height: 46px; display: block; flex: none; }
.brand b { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav a { position: relative; display: flex; align-items: center; gap: 12px; color: var(--text-2); text-decoration: none; min-height: 46px; padding: 8px 12px; border-radius: var(--r-ctl); font-weight: 550;
  transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.nav a.active { color: var(--gold-hi); background: var(--gold-soft); }
/* The active item carries a lit LED line, like the logo's ceiling. */
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); box-shadow: 0 0 12px rgba(246, 180, 43, .75); }
@media (hover: hover) { .nav a:hover:not(.active) { color: var(--text); background: var(--raised); } }
body:not(.is-admin) .admin-only { display: none !important; }
.me { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.me-name { font-size: 13px; color: var(--text-2); padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { display: block; font-size: 12px; color: var(--muted); }
.me-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.me-btns button { flex: 1 1 100%; min-width: 0; justify-content: flex-start; }

/* ---------- page ---------- */
.loading, .empty { padding: 56px 18px; text-align: center; color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -.022em; }
.sub { margin: 6px 0 0; color: var(--muted); }
.head-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { margin-bottom: 14px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--muted); font-weight: 550; }
.crumbs a:hover { color: var(--text); }
.crumbs a svg { flex: none; margin-left: -3px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.print-only { display: none; }

/* stats: the money tile leads, counts follow */
.stats { display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px 18px; }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; line-height: 1.15; }
.stat.accent { position: relative; overflow: hidden; background: linear-gradient(115deg, #2a2413, var(--surface) 62%); border-color: var(--gold-line); }
.stat.accent span { color: var(--text-2); }
.stat.accent b { color: var(--gold-hi); }

/* filters */
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { min-height: 44px; padding: 8px 13px; }
.filters input { flex: 1 1 260px; min-width: 0; }
.filters select { flex: 0 1 210px; min-width: 0; }

/* orders */
.orders { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.order-row { display: grid; grid-template-columns: 62px minmax(150px, 1.2fr) minmax(160px, 1.5fr) minmax(110px, .8fr) 150px 160px; gap: 14px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; transition: background-color 150ms var(--ease); }
.orders > .order-row:first-child { border-top: 0; }
@media (hover: hover) { a.order-row:hover { background: var(--raised); } }
.order-row.head { color: var(--muted); font-size: 12.5px; font-weight: 550; padding-top: 11px; padding-bottom: 11px; }
.order-row > div { min-width: 0; }
.order-row span { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.c-num { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.c-addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.c-master { color: var(--text-2); }
.c-sum { text-align: right; }
.pill { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); white-space: nowrap; }
.order-row span.pill { display: inline-flex; color: var(--c); font-size: 12px; }

/* order page */
.head-total { text-align: right; }
.head-total span { display: block; font-size: 13px; color: var(--muted); }
.head-total b { display: block; font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.order-grid { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 16px; align-items: start; }
.order-grid > * { min-width: 0; }
.status-select { min-height: 42px; padding: 6px 12px; font-weight: 600; }
.rooms { display: grid; gap: 12px; }
.room { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; background: var(--sunk); border: 1px solid var(--line); border-radius: 14px; padding: 12px; transition: border-color 200ms var(--ease); }
@media (hover: hover) { .room:hover { border-color: var(--line-strong); } }
.room-media { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.room-media > :only-child { grid-column: 1 / -1; }
.room-shot { padding: 0; border: 0; min-height: 0; border-radius: 10px; overflow: hidden; display: block; background: var(--bg); }
.room-shot img { display: block; width: 100%; height: 150px; object-fit: cover; }
.room-preview { display: flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; height: 150px; overflow: hidden; text-decoration: none; }
.room-preview svg { width: 100%; height: 100%; }
/* Stored previews were drawn for a light page: the wall lengths need a light colour here. */
.room-preview svg text { fill: var(--text-2); }
.no-plan { color: var(--muted); font-size: 12.5px; text-align: center; padding: 10px; }
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(5, 8, 16, .94); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in 180ms var(--ease); }
.viewer figure { margin: 0; max-width: min(1400px, 100%); }
.viewer img { display: block; max-width: 100%; max-height: calc(100dvh - 80px); border-radius: 12px; }
.viewer figcaption { color: var(--text-2); margin-top: 10px; text-align: center; }
.viewer .icon { position: absolute; top: 12px; right: 12px; color: #fff; }
.room-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.room-title { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; }
.room-title b { font-size: 16px; font-weight: 650; }
.room-title span { font-size: 12px; }
.room-metrics { display: flex; flex-wrap: wrap; gap: 6px; }
.room-metrics span { background: var(--raised); border-radius: 8px; padding: 3px 9px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.room-total { font-size: 20px; font-weight: 700; color: var(--gold-hi); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.room-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }

.estimate table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.estimate td, .estimate th { padding: 10px 4px; border-top: 1px solid var(--line); text-align: left; }
.estimate th { color: var(--muted); font-size: 12.5px; font-weight: 550; border-top: 0; }
.estimate td:nth-child(n+2), .estimate th:nth-child(n+2) { text-align: right; white-space: nowrap; }
.estimate tr.grp td { background: var(--raised); font-weight: 600; color: var(--text-2); }
.estimate tr.grp td:first-child { border-radius: 8px 0 0 8px; padding-left: 10px; }
.estimate tr.grp td:last-child { border-radius: 0 8px 8px 0; padding-right: 10px; }
.estimate tfoot td { font-weight: 700; font-size: 17px; color: var(--gold-hi); border-top: 2px solid var(--line-strong); }
.estimate tfoot tr.sub td { font-size: 13px; font-weight: 500; color: var(--text-2); border-top: 1px solid var(--line); }
.estimate .ep { display: none; }
.cost-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.cost-box div { background: var(--raised); border-radius: 12px; padding: 11px 13px; }
.cost-box span { display: block; font-size: 12px; color: var(--muted); }
.cost-box b { font-variant-numeric: tabular-nums; }
.cost-box b.pos { color: var(--ok); }
.cost-box b.neg { color: var(--danger); }
.hidden-lines { margin-top: 12px; font-size: 13px; color: var(--muted); }
.hidden-lines ul { margin: 6px 0 0; padding-left: 18px; }

.info { margin: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 9px 10px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.danger-link { background: none; border: 0; color: var(--danger); padding: 0; min-height: 0; margin-top: 16px; font-weight: 500; }
button.danger-link:hover:not(:disabled) { background: none; text-decoration: underline; }
.log { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.log li { padding: 9px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; padding-top: 0; }
.log small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-size: 12.5px; font-weight: 550; border-top: 0; }
.off { opacity: .55; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
label input, label select, label textarea { width: 100%; min-height: 44px; padding: 9px 12px; font-size: 15px; font-weight: 400; }
label textarea { resize: vertical; }
label.check { flex-direction: row; align-items: center; gap: 9px; font-size: 14px; color: var(--text); }
label.check input { width: 18px; min-height: 18px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 70px; font-variant-numeric: tabular-nums; }
.input-unit em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 12px; pointer-events: none; }
.form-error { color: var(--danger); font-size: 13px; }
.form-error:empty { display: none; }
.form-h { margin: 8px 0 0; font-size: 14px; font-weight: 650; color: var(--text); }
.form-h .small { font-weight: 400; margin-left: 6px; color: var(--muted); }
fieldset.checks { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0; display: grid; gap: 6px; }
fieldset.checks legend { font-size: 13px; color: var(--muted); padding: 0 4px; }

/* dialog */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5, 8, 16, .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal:not(.hidden) { animation: fade-in 200ms var(--ease); }
.modal-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-panel); width: min(540px, 100%); max-height: calc(100dvh - 32px); overflow: auto; box-shadow: var(--shadow-lg); }
.modal:not(.hidden) .modal-card { animation: pop-in 220ms var(--ease); }
.modal-card.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-head h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
#modalForm { padding: 8px 20px 20px; display: grid; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--raised); color: var(--text); border: 1px solid var(--line-strong); padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
.toast:not(.hidden) { animation: enter-up 200ms var(--ease); }
.toast.bad { background: #5a1f1c; border-color: var(--danger); }

/* ---------- login: a flight under a lit ceiling, out of the logo ---------- */
.bg-scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 0; animation: scene-in 1400ms var(--ease) backwards; }
@keyframes scene-in { from { opacity: 0; } }
.login-page { position: relative; z-index: 1; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(460px, 1fr); }
.login-visual { position: relative; display: grid; place-items: center; padding: 40px; }
.logo-wrap { position: relative; width: min(58%, 440px); animation: logo-in 700ms var(--ease) backwards, logo-float 8s ease-in-out 700ms infinite alternate; will-change: translate; }
.logo-wrap img { position: relative; display: block; width: 100%; height: auto; }
/* The glow behind the logo breathes like a lamp warming up. */
.logo-wrap::before { content: ""; position: absolute; inset: -34%; border-radius: 50%; background: radial-gradient(closest-side, rgba(246, 180, 43, .34), rgba(246, 180, 43, .08) 58%, transparent); animation: logo-glow 5s ease-in-out infinite alternate; }
/* A band of light crosses the logo, cut to the logo's own shape. */
.logo-sheen { position: absolute; inset: 0; overflow: hidden; -webkit-mask: url(/img/logo.webp) center / contain no-repeat; mask: url(/img/logo.webp) center / contain no-repeat; pointer-events: none; }
.logo-sheen::before { content: ""; position: absolute; top: -20%; bottom: -20%; left: -60%; width: 46%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .62) 50%, transparent); translate: 0 0; rotate: 8deg; animation: logo-sheen 7s var(--ease) 1200ms infinite; }
@keyframes logo-in { from { opacity: 0; scale: .9; } }
@keyframes logo-float { from { translate: 0 -7px; } to { translate: 0 7px; } }
@keyframes logo-glow { from { opacity: .55; scale: .94; } to { opacity: 1; scale: 1.05; } }
@keyframes logo-sheen { 0% { translate: 0 0; } 34%, 100% { translate: 360% 0; } }
.login-side { display: flex; align-items: center; justify-content: center; padding: 32px 28px; background: linear-gradient(90deg, transparent, rgba(10, 15, 28, .78) 34%); }
.login-card { position: relative; width: min(390px, 100%); display: grid; gap: 16px; padding: 28px; background: rgba(19, 27, 47, .8); border: 1px solid var(--line-strong); border-radius: var(--r-panel); box-shadow: var(--shadow-lg); animation: enter-up 520ms var(--ease) 180ms backwards; }
@media (hover: hover) { .login-card { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); } }
/* The card's top edge is a lit LED line, with light running along it. */
.login-card::before { content: ""; position: absolute; left: 22px; right: 22px; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-hi), transparent); box-shadow: 0 0 12px rgba(246, 180, 43, .7); animation: led-breathe 4s ease-in-out infinite alternate; }
@keyframes led-breathe { from { opacity: .5; } to { opacity: 1; } }
.login-card > * { animation: enter-up 380ms var(--ease) backwards; }
.login-card > :nth-child(1) { animation-delay: 280ms; }
.login-card > :nth-child(2) { animation-delay: 340ms; }
.login-card > :nth-child(3) { animation-delay: 400ms; }
.login-card > :nth-child(n+4) { animation-delay: 460ms; }
.login-card h1 { margin: 0 0 4px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.login-card input:focus-visible { box-shadow: 0 0 0 3px var(--gold-soft), 0 0 24px rgba(246, 180, 43, .22); }
.login-card .primary { position: relative; overflow: hidden; min-height: 50px; font-size: 15px; margin-top: 4px; }
.login-card .primary::after { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .6), transparent); animation: btn-sheen 6s var(--ease) 2s infinite; }
@keyframes btn-sheen { 0% { translate: 0 0; } 26%, 100% { translate: 480% 0; } }
.install-link { background: transparent; color: var(--gold-hi); }
.login-alt { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.login-alt a { color: var(--gold-hi); font-weight: 600; text-decoration: none; }
.login-alt a:hover { text-decoration: underline; }
.signup-text { margin: 0; color: var(--muted); line-height: 1.55; }
.signup-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text); line-height: 1.45; }
.signup-steps b { color: var(--gold-hi); }
.tg-button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; border-radius: 12px; font-size: 15px; font-weight: 600; text-decoration: none; color: #fff; background: #229ed9; transition: filter 160ms var(--ease), transform 160ms var(--ease); }
.tg-button:hover { filter: brightness(1.08); }
.tg-button:active { transform: scale(.98); }
.tg-button svg { width: 22px; height: 22px; flex: none; }
.tg-nick { font-weight: 700; color: var(--gold-hi); }

/* ---------- moving background of the cabinet ---------- */
body:not(.login) .bg-scene { z-index: -1; opacity: .42; animation: scene-in-soft 1600ms var(--ease) backwards; }
@keyframes scene-in-soft { from { opacity: 0; } }
/* Two large glows drift slowly; only the transform moves, so it costs next to nothing. */
body:not(.login)::before, body:not(.login)::after { content: ""; position: fixed; z-index: -1; width: 80vmax; height: 80vmax; border-radius: 50%; pointer-events: none; will-change: transform; }
body:not(.login)::before { top: -30vmax; right: -24vmax; background: radial-gradient(closest-side, rgba(246, 180, 43, .1), transparent); animation: drift-a 34s ease-in-out infinite alternate; }
body:not(.login)::after { bottom: -38vmax; left: -22vmax; background: radial-gradient(closest-side, rgba(92, 132, 220, .13), transparent); animation: drift-b 42s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate(-22vmax, 16vmax) scale(1.18); } }
@keyframes drift-b { to { transform: translate(26vmax, -14vmax) scale(.9); } }
/* Panels let the moving light show through a little. */
.card, .stat, .orders, .table-wrap, .cat-card, .cal-item { background-color: rgba(19, 27, 47, .93); }
.room { background-color: rgba(13, 20, 36, .85); }
/* Light runs along the edge of the menu. */
.rail::after { content: ""; position: absolute; right: -1px; top: 0; width: 1px; height: 170px; background: linear-gradient(180deg, transparent, var(--gold-hi), transparent); box-shadow: 0 0 10px rgba(246, 180, 43, .7); animation: rail-run 9s linear infinite; pointer-events: none; }
@keyframes nav-run { from { translate: -120px 0; } to { translate: 100vw 0; } }
@keyframes rail-run { from { translate: 0 -180px; } to { translate: 0 100vh; } }
/* The money tile catches a band of light now and then. */
.stat.accent::after { content: ""; position: absolute; top: -10%; bottom: -10%; left: -40%; width: 26%; background: linear-gradient(100deg, transparent, rgba(255, 224, 150, .2), transparent); rotate: 8deg; animation: tile-sheen 9s var(--ease) 1500ms infinite; pointer-events: none; }
@keyframes tile-sheen { 0% { translate: 0 0; } 30%, 100% { translate: 700% 0; } }
/* Lists arrive one after another. */
.orders.enter .order-item, .rooms > .room, .cat-grid > .cat-card, .cal-day .cal-item, .stats > .stat { animation: enter-up 420ms var(--ease) backwards; }
.stats > .stat:nth-child(2) { animation-delay: 60ms; }
.stats > .stat:nth-child(3) { animation-delay: 120ms; }
.stats > .stat:nth-child(4) { animation-delay: 180ms; }
.orders.enter .order-item:nth-child(3), .rooms > .room:nth-child(2), .cat-grid > .cat-card:nth-child(2) { animation-delay: 60ms; }
.orders.enter .order-item:nth-child(4), .rooms > .room:nth-child(3), .cat-grid > .cat-card:nth-child(3) { animation-delay: 120ms; }
.orders.enter .order-item:nth-child(5), .rooms > .room:nth-child(4), .cat-grid > .cat-card:nth-child(4) { animation-delay: 180ms; }
.orders.enter .order-item:nth-child(6), .cat-grid > .cat-card:nth-child(5) { animation-delay: 240ms; }
.orders.enter .order-item:nth-child(7), .cat-grid > .cat-card:nth-child(6) { animation-delay: 300ms; }
.orders.enter .order-item:nth-child(n+8), .cat-grid > .cat-card:nth-child(n+7) { animation-delay: 360ms; }
/* A row under the mouse lights its LED line; a card under the mouse lights its edge. */
.order-row { position: relative; }
@media (hover: hover) {
  a.order-row::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); box-shadow: 0 0 10px rgba(246, 180, 43, .7); scale: 1 0; transition: scale 200ms var(--ease); }
  a.order-row:hover::before { scale: 1 1; }
  .stat, .card { transition: border-color 220ms var(--ease), box-shadow 220ms var(--ease); }
  .stat:hover { border-color: var(--line-strong); box-shadow: 0 8px 30px rgba(3, 6, 14, .4); }
  .room:hover, .cat-card:hover { border-color: var(--gold-line); box-shadow: 0 0 26px rgba(246, 180, 43, .08); }
}

/* ---------- calendar ---------- */
.cal-day { margin-bottom: 22px; }
.cal-day h2 { font-size: 15px; font-weight: 650; margin: 0 0 8px; color: var(--text-2); }
.cal-day h2::first-letter { text-transform: uppercase; }
.cal-day.today h2 { color: var(--gold-hi); }
.cal-item { display: grid; grid-template-columns: 56px 76px minmax(0, 1fr) minmax(0, 190px) auto; gap: 12px; align-items: center; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; color: inherit; text-decoration: none; transition: background-color 150ms var(--ease); }
@media (hover: hover) { .cal-item:hover { background: var(--raised); } }
.cal-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-kind { font-size: 12.5px; font-weight: 600; color: #b9a4ff; }
.cal-kind.inst { color: var(--warn); }
.cal-main { min-width: 0; }
.cal-main b, .cal-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-main b { font-weight: 600; }
.cal-main span, .cal-who { color: var(--muted); font-size: 12.5px; }
.adj-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 64px 110px 38px; gap: 6px; margin-bottom: 6px; }
.adj-row input { min-height: 40px; padding: 6px 9px; width: 100%; }

/* ---------- catalog ---------- */
.cat-kinds { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cat-kinds::-webkit-scrollbar { display: none; }
.cat-kinds button { flex: none; border-radius: 99px; min-height: 40px; padding: 6px 15px; background: transparent; }
.cat-kinds button span { color: var(--muted); font-size: 12px; margin-left: 2px; }
.cat-kinds button.on { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-hi); }
.cat-kinds button.on span { color: var(--gold); }
.seg-sm { display: inline-flex; background: var(--field); border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 3px; gap: 2px; }
.seg-sm button { border: 0; background: transparent; min-height: 36px; padding: 4px 11px; border-radius: 8px; color: var(--muted); }
.seg-sm button.on { background: var(--raised); color: var(--gold-hi); font-weight: 600; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cat-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; transition: translate 200ms var(--ease), border-color 200ms var(--ease); }
@media (hover: hover) { .cat-card:hover { translate: 0 -2px; border-color: var(--line-strong); } }
.cat-open { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: none; text-align: left; white-space: normal; min-height: 0; font-weight: 400; }
button.cat-open:hover:not(:disabled) { background: none; }
.cat-ph { height: 136px; display: flex; align-items: center; justify-content: center; background: var(--raised); overflow: hidden; }
.cat-ph img { width: 100%; height: 100%; object-fit: contain; background: #e8ecf3; }
.cat-ph.big { height: 180px; width: 180px; border-radius: 14px; }
.ph { color: var(--muted); display: grid; place-items: center; width: 100%; height: 100%; }
.ph .i { width: 42px; height: 42px; }
.ph.sm .i { width: 22px; height: 22px; }
.ph.fix svg { width: 72%; height: 72%; max-width: 92px; max-height: 92px; }
.cat-body { padding: 11px 13px 13px; display: grid; gap: 3px; }
.cat-body b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.cat-body .muted { font-size: 12px; }
.cat-price { font-weight: 700; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.cat-price small { font-weight: 500; color: var(--muted); margin-left: 2px; }
.star { color: var(--gold); }
.star .i { width: 16px; height: 16px; display: inline-block; vertical-align: -2px; }
.cat-card > .star { position: absolute; top: 9px; left: 11px; }
.cat-acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 3px; }
.cat-acts .icon { width: 32px; min-height: 32px; background: rgba(10, 15, 28, .78); color: var(--text); border-radius: 8px; }
.cat-acts .icon .i { width: 16px; height: 16px; }
.cat-table td.thumb { width: 56px; }
.cat-table td.thumb img, .cat-table td.thumb .ph { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: var(--raised); }
.cat-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-table td.acts { text-align: right; }
.item-form { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; }
.item-photo { display: grid; gap: 8px; align-content: start; justify-items: start; }
.item-fields { display: grid; gap: 12px; min-width: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
.parts { display: grid; gap: 6px; }
.part-row { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 10px; align-items: end; }
.part-row b { padding-bottom: 11px; font-weight: 600; }
.kit-tabs { margin-bottom: 4px; }
.kit-list { display: grid; gap: 8px; }
.kit-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 80px auto 38px; gap: 8px; align-items: center; }
.kit-row input, .kit-row select { min-height: 40px; padding: 6px 9px; width: 100%; }
.kit-row .check { font-size: 12px; color: var(--muted); white-space: nowrap; }
.kit-row .check input { width: 16px; min-height: 16px; }
.kit-add { justify-self: start; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.price-sample { background: var(--gold-soft); border: 1px solid var(--gold-line); border-radius: 14px; padding: 14px 16px; color: var(--text-2); }
.price-sample b { font-size: 20px; display: block; margin-top: 2px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.prices-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.fix-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.fix-opt { position: relative; display: grid; justify-items: center; gap: 5px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); cursor: pointer; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.2; }
.fix-opt input { position: absolute; opacity: 0; pointer-events: none; }
.fix-opt:has(input:checked) { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft); color: var(--text); }
.fix-opt:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.room-shot img, .kp-pic img, .item-photo img { outline: 1px solid rgba(255, 255, 255, .08); outline-offset: -1px; }

.view > * { animation: fade-in 160ms var(--ease); }

/* ---------- tablet ---------- */
@media (max-width: 1240px) {
  .room { grid-template-columns: 220px minmax(0, 1fr); }
  .room-media { grid-template-columns: minmax(0, 1fr); }
  .room-shot img, .room-preview { height: 120px; }
}
@media (max-width: 1100px) {
  .orders > .order-item:nth-child(2) .order-row { border-top: 0; }
  .order-grid, .prices-layout { grid-template-columns: minmax(0, 1fr); }
  .order-row.head { display: none; }
  .order-row { grid-template-columns: 56px minmax(0, 1fr) 140px 150px; grid-template-areas: "num client status sum" "num addr addr addr"; row-gap: 4px; }
  .order-row .c-num { grid-area: num; }
  .order-row .c-client { grid-area: client; }
  .order-row .c-status { grid-area: status; }
  .order-row .c-sum { grid-area: sum; }
  .order-row .c-addr { grid-area: addr; white-space: normal; font-size: 13px; }
  .order-row .c-addr span { display: inline; margin-left: 8px; }
  .order-row .c-master { display: none; }
}

/* ---------- phone: header on top, tabs at the bottom within thumb reach ---------- */
@media (max-width: 820px) {
  .rail { display: contents; }
  .brand { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: calc(58px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; background: var(--sunk); border-bottom: 1px solid var(--line); }
  .brand img { width: 38px; height: 38px; }
  .brand b { font-size: 15px; }
  .brand small { display: none; }
  .me { position: fixed; top: env(safe-area-inset-top); right: 10px; height: 58px; z-index: 21; display: flex; align-items: center; gap: 8px; border: 0; padding: 0; }
  .me-name { display: none; }
  .me-btns button { min-height: 38px; padding: 6px 10px; font-size: 13px; }
  .nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; flex-direction: row; gap: 0; background: var(--sunk); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 2px; min-height: 54px; padding: 5px 2px; font-size: 11px; text-align: center; background: none !important; }
  .nav a .i { width: 23px; height: 23px; }
  .nav a.active::before { left: 30%; right: 30%; top: -4px; bottom: auto; width: auto; height: 2px; border-radius: 0 0 2px 2px; box-shadow: 0 2px 8px rgba(246, 180, 43, .7); }
  .view { margin-left: 0; padding: calc(58px + env(safe-area-inset-top) + 18px) 14px calc(84px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 16px; }
  .page-head h1, .head-total b { font-size: 24px; }
  .head-total { text-align: left; width: 100%; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
  .stat { padding: 11px 12px; border-radius: 14px; }
  .stat b { font-size: 22px; }
  .stat span { font-size: 12px; }
  .stat.accent { grid-column: 1 / -1; }
  .filters select { flex: 1 1 calc(50% - 5px); }
  /* Orders become cards: where and when the master goes stays readable. */
  .orders { background: none; border: 0; border-radius: 0; display: grid; gap: 8px; overflow: visible; }
  .order-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "client sum" "addr addr" "status num"; gap: 6px 12px; padding: 13px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
  .orders > .order-item:nth-child(2) .order-row { border-top: 1px solid var(--line); }
  .order-row .c-addr span { display: block; margin-left: 0; }
  .order-row .c-status { justify-self: start; }
  .order-row .c-num { text-align: right; font-size: 12px; align-self: center; }
  .card { padding: 15px; border-radius: 16px; }
  .room { grid-template-columns: minmax(0, 1fr); }
  .room-media { grid-template-columns: 1fr 1fr; }
  .room-shot img, .room-preview { height: 130px; }
  .room-actions > * { flex: 1 1 auto; }
  .order-actions > * { flex: 1 1 auto; }
  .row2 { grid-template-columns: minmax(0, 1fr); }
  .info { grid-template-columns: 96px minmax(0, 1fr); }
  .cost-box { grid-template-columns: minmax(0, 1fr); }
  .estimate .c-price { display: none; }
  .estimate .ep { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
  .estimate td, .estimate th { font-size: 13px; padding: 8px 3px; }
  .estimate td:first-child { overflow-wrap: anywhere; }
  .estimate tfoot td { font-size: 15px; }
  .item-form { grid-template-columns: minmax(0, 1fr); }
  .cat-ph.big { width: 100%; }
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
  .kit-row { grid-template-columns: 1fr 1fr; }
  .kit-row .kit-item { grid-column: 1 / -1; }
  .cat-grid { grid-template-columns: 1fr 1fr; }
  .cal-item { grid-template-columns: 50px minmax(0, 1fr) auto; }
  .cal-kind, .cal-who { display: none; }
  .adj-row { grid-template-columns: 1fr 1fr 1fr; }
  .adj-row .a-name { grid-column: 1 / -1; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card, .modal-card.wide { width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; border-width: 1px 0 0; }
  #modalForm { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .login-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .login-visual { padding: calc(26px + env(safe-area-inset-top)) 20px 20px; }
  .logo-wrap { width: 164px; }
  .login-side { align-items: flex-start; padding: 8px 16px 28px; background: none; }
  .login-card { padding: 22px 20px; background: rgba(19, 27, 47, .9); }
  /* No canvas behind the cabinet on a phone: the glows and a light on the tab bar stay. */
  body:not(.login) .bg-scene { display: none; }
  .nav { overflow: hidden; }
  .nav::after { content: ""; position: absolute; top: 0; left: 0; width: 110px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-hi), transparent); box-shadow: 0 0 8px rgba(246, 180, 43, .7); animation: nav-run 8s linear infinite; pointer-events: none; }
  .login-card h1 { font-size: 24px; }
}

@media print {
  body { background: #fff; color: #111; color-scheme: light; }
  .bg-scene, body::before, body::after { display: none !important; }
  .rail, .crumbs, .head-btns, .order-actions, .room-actions, .no-print, .toast, .modal, .card-head button { display: none !important; }
  .print-only { display: block; }
  .view { padding: 0; margin: 0; max-width: none; }
  .order-grid { grid-template-columns: 1fr; }
  .card, .room { background: #fff; border-color: #ccc; break-inside: avoid; }
  .card, .card h2, .estimate td, .estimate tfoot td, .room-total, .head-total b { color: #111 !important; }
  .estimate tr.grp td { background: #eee; }
  .room { grid-template-columns: 150px 1fr; }
  .room-preview { height: 120px; background: #fff; }
  .room-preview svg text { fill: #111; }
}
@media (max-width: 820px) {
  .order-actions .head-btns { width: 100%; }
  .order-actions .status-select { flex: 1 1 100%; }
  .order-actions .btn { flex: 1 1 0; }
}
@media (max-width: 820px) {
  .me-btns { flex-wrap: nowrap; }
  .me-btns button { flex: none; justify-content: center; }
  .me-btns .desk-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-sheen, .stat.accent::after, .rail::after, .nav::after, .login-card .primary::after { display: none; }
  .logo-wrap, .logo-wrap::before, body::before, body::after { animation: none !important; }
}

/* deleting orders and staff */
.order-item { position: relative; }
.orders.can-del .order-row { padding-right: 62px; }
.order-del { position: absolute; right: 12px; top: 50%; translate: 0 -50%; color: var(--muted); }
.order-del:active:not(:disabled) { scale: 1; }
@media (hover: hover) { .order-del:hover:not(:disabled) { color: var(--danger); background: rgba(255, 128, 113, .12); } }
.user-acts { text-align: right; white-space: nowrap; }
.user-acts .icon { margin-left: 4px; vertical-align: middle; }
.confirm-text { margin: 0; color: var(--text-2); line-height: 1.55; }
.confirm-text b { color: var(--text); }
@media (max-width: 820px) {
  .orders.can-del .order-row { padding-right: 14px; }
  .orders.can-del .c-num { margin-right: 44px; }
  .order-del { top: auto; bottom: 6px; right: 6px; translate: none; }
}
@media print { .order-del { display: none; } }
/* Staff on a phone: cards, so the buttons are reachable without sideways scrolling. */
@media (max-width: 820px) {
  .table.staff thead { display: none; }
  .table.staff, .table.staff tbody { display: block; }
  .table.staff tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 13px 14px; border-top: 1px solid var(--line); }
  .table.staff tr:first-child { border-top: 0; }
  .table.staff td { display: block; padding: 0; border: 0; min-width: 0; color: var(--text-2); font-size: 13px; }
  .table.staff td:nth-child(1) { grid-column: 1 / -1; color: var(--text); font-size: 15px; }
  .table.staff td:nth-child(2) { grid-column: 1; }
  .table.staff td:nth-child(3) { grid-column: 1; grid-row: 3; }
  .table.staff td:nth-child(4) { grid-column: 1; grid-row: 4; }
  .table.staff td:nth-child(5) { grid-column: 1; grid-row: 5; }
  .table.staff td:nth-child(5)::before { content: "Активных заказов: "; color: var(--muted); }
  .table.staff td.user-acts { grid-column: 2; grid-row: 2 / span 4; align-self: end; display: flex; align-items: center; gap: 4px; }
}

/* language switcher */
.lang-sel { min-height: 38px; padding: 6px 10px; font-size: 13px; }
.me .lang-sel { width: 100%; }
.login-card .lang-sel { justify-self: end; width: auto; min-height: 36px; margin-bottom: -6px; }
@media (max-width: 820px) { .me .lang-sel { width: auto; max-width: 130px; } }
