:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface: #fcfcfb;
  --border: #e3e2de;
  --grid: #ecebe7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --accent: #2a78d6;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --good: #0f7b3e;
  --bad: #c0352f;
  --logo: #7c7c7c;
  --ap: #7a5ad6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --border: #2d2d2b;
    --grid: #262624;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #3987e5;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --good: #4cc27c;
    --bad: #ef7a74;
    --logo: #a9a9a6;
    --ap: #9d83ee;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --border: #2d2d2b; --grid: #262624;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e88; --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --good: #4cc27c; --bad: #ef7a74;
  --logo: #a9a9a6;
  --ap: #9d83ee;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px 32px; max-width: 1400px; margin-inline: auto;
}
h1 { font-size: 18px; margin: 0; font-weight: 650; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
input, select, button { font: inherit; color: var(--text); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 16px; }
.user-box { display: flex; align-items: center; gap: 10px; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 11px; border-radius: 7px; color: var(--text-2); text-decoration: none; font-size: 13px; }
.nav a:hover { background: var(--grid); }
.nav a.on { color: var(--text); background: var(--surface); border: 1px solid var(--border); padding: 5px 10px; }
.nav a.off { color: var(--muted); opacity: .6; cursor: default; }
.nav a.off:hover { background: none; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 6px 11px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--accent); color: #fff; }
.small-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12px; color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kpi .lbl { color: var(--text-2); font-size: 12.5px; }
.kpi .val { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--st); }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--grid); color: var(--text-2); }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.err { color: var(--bad); margin: 0; }
.warn { color: var(--bad); }
.muted { color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 20px; }
.tip {
  position: fixed; z-index: 50; max-width: 280px; padding: 8px 10px; border-radius: 8px; pointer-events: none;
  background: var(--text); color: var(--surface); font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: none; }
@media (max-width: 700px) { .top { flex-wrap: wrap; gap: 10px; } }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 11px; }
.logo { height: 38px; width: auto; display: block; color: var(--logo); flex: none; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-txt b { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.brand-txt small { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.brand-sub { font-size: 16px; font-weight: 600; color: var(--text-2); padding-left: 12px; border-left: 1px solid var(--border); line-height: 26px; }
@media (max-width: 520px) { .logo { height: 32px; } .brand-txt b { font-size: 16px; } .brand-sub { display: none; } }

/* service status colors */
.st-completed { --st: var(--s3); }
.st-pending { --st: var(--muted); }
.st-confirmed { --st: var(--s2); }
.st-cancelled { --st: var(--s1); }

/* toolbar */
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 12px; }
.today-btn { font-size: 13px; padding: 5px 12px; }
.cal-arrows { display: inline-flex; gap: 2px; }
.arrow { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 7px; background: none; color: var(--text-2); cursor: pointer; }
.arrow:hover { background: var(--grid); color: var(--text); }
.cal-title { font-size: 17px; font-weight: 650; margin-right: auto; }
.cal-legend { margin-right: 6px; }

/* month view */
#cal.loading { opacity: .6; transition: opacity .2s; }
.cal-month {
  display: grid; grid-template-rows: auto 1fr; height: calc(100vh - 170px); min-height: 560px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.cal-dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.cal-dow div { padding: 8px 10px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.cal-dow .s { display: none; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 0; }
.cal-cell {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; padding: 4px 5px 4px;
  border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); cursor: pointer; transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:nth-last-child(-n+7) { border-bottom: 0; }
.cal-cell.we { background: color-mix(in srgb, var(--text) 2.5%, var(--surface)); }
.cal-cell.out { background: var(--bg); }
.cal-cell.out .cal-num b { color: var(--muted); font-weight: 500; }
.cal-cell:hover, .cal-cell:focus-visible { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); outline: none; }
.cal-num { display: flex; align-items: center; gap: 6px; min-height: 22px; padding: 0 2px 2px; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-num b { font-weight: 600; padding: 0 6px; border-radius: 999px; line-height: 20px; margin-left: -4px; }
.cal-num small { color: var(--bad); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal-num .cnt { display: none; }
.cal-cell.hol .cal-num b, .cal-cell.we:nth-child(7n) .cal-num b { color: var(--bad); }
.cal-cell.today .cal-num b { background: var(--accent); color: #fff; }
.cal-evs { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.ev {
  display: flex; gap: 5px; flex: none; height: 18px; line-height: 18px; padding: 0 6px; font-size: 12px; border-radius: 4px;
  border-left: 3px solid var(--st); background: color-mix(in srgb, var(--st) 13%, var(--surface));
  white-space: nowrap; overflow: hidden;
}
.ev time { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; }
.ev span { overflow: hidden; text-overflow: ellipsis; }
.ev.st-cancelled span, .dev.st-cancelled b, .day-list .st-cancelled b { text-decoration: line-through; color: var(--muted); }
.more { font-size: 12px; color: var(--text-2); padding: 0 6px; line-height: 18px; }
.cal-cell:hover .more { color: var(--accent); }
@media (max-width: 760px) {
  .cal-month { height: auto; min-height: 0; }
  .cal-grid { grid-template-rows: none !important; grid-auto-rows: 64px; }
  .cal-dow div { padding: 6px 4px; text-align: center; }
  .cal-dow .l { display: none; }
  .cal-dow .s { display: inline; }
  .cal-num { flex-direction: column; gap: 4px; align-items: center; }
  .cal-num b { margin: 0; }
  .cal-num small, .cal-evs { display: none; }
  .cal-num .cnt:not(:empty) { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 999px; font-size: 11px; text-align: center; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
  .cal-legend { order: 5; width: 100%; }
}

/* day view */
.day-wrap { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 12px; align-items: start; }
.day-side .card { margin-bottom: 12px; }
.mini-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 13px; }
.mini-head .arrow { width: 26px; height: 26px; }
.mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mini-dow { color: var(--muted); font-size: 11px; padding: 2px 0; }
.mini button { position: relative; border: 0; background: none; padding: 4px 0 6px; border-radius: 6px; cursor: pointer; color: var(--text); }
.mini button:hover { background: var(--grid); }
.mini button.out { color: var(--muted); }
.mini button.hol { color: var(--bad); }
.mini button.today { box-shadow: inset 0 0 0 1px var(--accent); }
.mini button.sel { background: var(--accent); color: #fff; }
.mini button.has::after { content: ''; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); opacity: .7; }
.mini button.sel.has::after { background: #fff; }
.mini-kpis { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini-kpis .kpi { padding: 8px 10px; border-radius: 8px; }
.mini-kpis .lbl { font-size: 11.5px; white-space: nowrap; }
.mini-kpis .val { font-size: 19px; }
.day-list { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 520px); min-height: 120px; overflow-y: auto; }
.day-list li { display: flex; gap: 10px; padding: 7px 6px 7px 9px; border-left: 3px solid var(--st); border-bottom: 1px solid var(--grid); cursor: pointer; font-size: 12.5px; }
.day-list li:hover { background: var(--grid); }
.day-list time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.day-list span { min-width: 0; display: flex; flex-direction: column; }
.day-list b { font-weight: 600; }
.day-list small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-card { padding: 0; overflow: hidden; }
.day-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.day-scroll { height: calc(100vh - 210px); min-height: 480px; overflow-y: auto; padding: 10px 0 10px; }
.day-grid { position: relative; margin-left: 58px; margin-right: 10px; border-left: 1px solid var(--border); }
.hr { position: absolute; left: 0; right: 0; height: 48px; border-top: 1px solid var(--grid); pointer-events: none; }
.hr.night { background: color-mix(in srgb, var(--text) 2.5%, transparent); }
.hr::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--grid); }
.hr span { position: absolute; left: -58px; width: 48px; top: -9px; text-align: right; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dev {
  position: absolute; z-index: 1; overflow: hidden; padding: 3px 8px; font-size: 12px; line-height: 1.35; border-radius: 6px; cursor: pointer;
  border-left: 3px solid var(--st); background: color-mix(in srgb, var(--st) 15%, var(--surface));
  box-shadow: 0 0 0 1px var(--surface);
}
.dev:hover { background: color-mix(in srgb, var(--st) 24%, var(--surface)); z-index: 2; }
.dev div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev time { color: var(--text-2); font-variant-numeric: tabular-nums; }
.dev-r, .dev-d { color: var(--text-2); }
.dev.short .dev-r, .dev.short .dev-d { display: none; }
.dev.flash-ev { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 2px var(--st); } 100% { box-shadow: 0 0 0 1px var(--surface); } }
.now { position: absolute; left: -6px; right: 0; z-index: 3; border-top: 2px solid var(--bad); pointer-events: none; }
.now::before { content: ''; position: absolute; left: 0; top: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
@media (max-width: 900px) {
  .day-wrap { grid-template-columns: 1fr; }
  .day-side { order: 2; }
  .day-list { max-height: none; }
  .day-scroll { height: 70vh; min-height: 0; }
}

/* header: user and logout */
a.home { color: inherit; text-decoration: none; }
.user-name { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); text-decoration: none; font-size: 13px; transition: color .15s, border-color .15s; }
.user-name::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.user-name:hover, .user-name.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.logout { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); text-decoration: none; font-size: 13px; transition: color .15s, border-color .15s, background .15s; }
.logout:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); background: color-mix(in srgb, var(--bad) 7%, var(--surface)); }
@media (max-width: 700px) { .user-box { flex-wrap: wrap; } .logout span { display: none; } }

/* buttons, messages */
.btn { display: inline-block; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 6px; padding: 6px 14px; cursor: pointer; text-decoration: none; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }
a.small-btn { text-decoration: none; display: inline-block; }
.danger { background: none; border: 1px solid color-mix(in srgb, var(--bad) 50%, var(--border)); color: var(--bad); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.danger:hover { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.flash { background: color-mix(in srgb, var(--good) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--good) 40%, var(--border)); border-radius: 8px; padding: 9px 12px; margin: 0 0 12px; }
.flash.err { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); color: var(--bad); }
.flash.warn-box { background: color-mix(in srgb, var(--s2) 10%, var(--surface)); border-color: color-mix(in srgb, var(--s2) 45%, var(--border)); }
.flash ul { margin: 6px 0 8px; padding-left: 18px; }
.badge.on { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.page-title { font-size: 16px; margin: 0 0 12px; }
.card-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin-right: auto; }
.card-h { margin-bottom: 12px; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; max-width: 900px; }
.settings .card { margin: 0; }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 13.5px; }
dl.info dt { color: var(--text-2); }
dl.info dd { margin: 0; overflow-wrap: anywhere; }

/* forms */
.uform .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; align-items: start; }
.uform .fields.one { grid-template-columns: 1fr; }
.uform label { display: grid; gap: 4px; color: var(--text-2); font-size: 13px; }
.uform label.wide { grid-column: 1 / -1; margin-top: 12px; }
.uform .fields label.wide { margin-top: 0; }
.uform input:not([type=checkbox]):not([type=color]), .uform select, .uform textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px; font: inherit; color: var(--text);
}
.uform textarea { resize: vertical; min-height: 60px; }
.uform input:focus, .uform select:focus, .uform textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: -1px; border-color: var(--accent); }
.uform label.chk { display: flex; align-items: center; gap: 8px; color: var(--text); }
.uform .checks { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 14px; }
.uform small { font-size: 11.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
form.del { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--grid); }
form.del .hint { margin: 0; }
.color-in { display: flex; align-items: center; gap: 8px; }
.color-in input { width: 46px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; }
.color-in input[data-empty] { opacity: .3; }
.pw-in { position: relative; display: block; }
.pw-in input { padding-right: 34px !important; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; padding: 4px; color: var(--muted); cursor: pointer; display: flex; }
.eye:hover, .eye.on { color: var(--accent); }
.narrow-form { max-width: 760px; }

/* settings tabs and lists */
.tabs { margin-bottom: 12px; flex-wrap: wrap; }
.seg a { display: inline-block; padding: 6px 13px; font-size: 13px; color: var(--text-2); text-decoration: none; }
.seg a:hover { background: var(--grid); }
.seg a.on { background: var(--accent); color: #fff; }
.table-wrap { overflow-x: auto; }
table.list { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.list th, table.list td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
table.list th { color: var(--text-2); font-weight: 600; font-size: 12.5px; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--grid); }
table.list tr.off td { color: var(--muted); }
.swatch, .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.exp.soon { color: var(--s2); font-weight: 600; }
.exp.bad { color: var(--bad); font-weight: 600; }

/* calendar editing */
.new-btn { padding: 6px 12px; }
body[data-edit="1"] .ev, body[data-edit="1"] .dev { cursor: pointer; }
body[data-edit="1"] .day-grid { cursor: cell; }
.ev.flash-ev { animation: flash 1.2s ease-out; }
.dlg { width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(0,0,0,.35); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 26px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 10px 18px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { font-size: 15px; }
.dlg-body { padding: 14px 18px; overflow-y: auto; display: grid; gap: 12px; }
.dlg-body .fields.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dlg-body .fields.f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dlg-body label.wide { margin-top: 0; }
.dlg-body .flash { margin: 0; }
.dlg-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.dlg-foot .spacer { flex: 1; }
.dlg-foot .small-btn { font-size: 13px; padding: 6px 12px; }
#nextDay { color: var(--s2); }
@media (max-width: 600px) {
  .dlg-body .fields.f3, .dlg-body .fields.f2 { grid-template-columns: 1fr 1fr; }
}

/* login */
body.login { display: flex; flex-direction: column; min-height: 100vh; padding-bottom: 0; }
.login-main { flex: 1; display: grid; place-items: center; padding: 24px 0 12vh; }
.login-box { width: 390px; max-width: calc(100vw - 32px); display: grid; gap: 12px; }
.login-box h1 { display: flex; justify-content: center; margin: 6px 0 10px; }
.login-box .brand-sub { display: none; }
.login-box label { display: grid; gap: 4px; color: var(--text-2); }
.login-box input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.login-box button[type=submit] { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 9px; cursor: pointer; }

/* v0.30 */
[hidden] { display: none !important; }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.confirm-dlg { width: min(440px, calc(100vw - 24px)); }
.confirm-msg { margin: 4px 0; font-size: 14px; line-height: 1.5; }
#infoDlg { width: min(520px, calc(100vw - 24px)); }
#infoDlg dl.info { grid-template-columns: max-content 1fr; }
#infoDlg dd a { color: var(--accent); }
.st-badge { display: inline-flex; align-items: center; gap: 6px; }
.st-badge i { width: 10px; height: 10px; border-radius: 3px; background: var(--st); }

/* v0.40: services list */
.list-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 12px; }
.list-filters label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.list-filters input, .list-filters select { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font: inherit; color: var(--text); }
.list-filters input[type=search] { width: 230px; }
.list-tot { color: var(--text-2); font-size: 13px; }
.list-tot b { color: var(--text); font-variant-numeric: tabular-nums; }
table.svc-list td { vertical-align: top; }
table.svc-list td.route { white-space: normal; min-width: 220px; }
table.svc-list td.date { font-weight: 600; }
table.svc-list tr.day-first td { border-top: 1px solid var(--border); }
table.svc-list th.num, table.svc-list td.num { text-align: right; }
table.svc-list tr.st-cancelled td { color: var(--muted); }
table.svc-list tr.st-cancelled td b { text-decoration: line-through; }

@media (max-width: 700px) {
  .list-filters input[type=search] { flex: 1; width: auto; min-width: 0; }
  table.svc-list thead { display: none; }
  table.svc-list, table.svc-list tbody { display: block; }
  table.svc-list tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 2px; border-bottom: 1px solid var(--grid); }
  table.svc-list tr.day-first td { border-top: 0; }
  table.svc-list td { display: block; padding: 0; border: 0; white-space: normal; text-align: left !important; }
  table.svc-list td:empty { display: none; }
  table.svc-list td.date { grid-column: 1 / -1; padding: 4px 0 6px; color: var(--accent); }
  table.svc-list td.time { grid-row: span 2; font-weight: 600; }
  table.svc-list td.route { min-width: 0; }
  table.svc-list td[data-l] { grid-column: 2; font-size: 13px; color: var(--text-2); }
  table.svc-list td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); }
  table.svc-list td.stat { grid-column: 2; }
}
.uform input:disabled, .uform select:disabled { opacity: .55; cursor: not-allowed; }
.uform label.chk.locked { color: var(--muted); cursor: not-allowed; }
.uform label.chk.locked input { opacity: .5; }

/* v0.50: personal appointments */
.ev.appt, .dev.appt { --st: var(--ap); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ap) 14%, var(--surface)) 0 6px, color-mix(in srgb, var(--ap) 8%, var(--surface)) 6px 12px); }
.ev.appt span, .dev.appt b { font-style: italic; }
.appt-badge { background: color-mix(in srgb, var(--ap) 16%, transparent); color: var(--ap); cursor: pointer; font-weight: 600; }
.appt-leg i { background: var(--ap); }
.btn.appt-btn { background: var(--surface); color: var(--ap); border-color: color-mix(in srgb, var(--ap) 55%, var(--border)); }
.btn.appt-btn:hover { background: color-mix(in srgb, var(--ap) 8%, var(--surface)); }
.hint.lead { margin: 0; }
#apptDlg { width: min(520px, calc(100vw - 24px)); }

.cal-bar .cal-legend { order: 10; flex-basis: 100%; justify-content: flex-end; margin: -4px 0 0; font-size: 12px; }
.cal-month { height: calc(100vh - 190px); }
.day-scroll { height: calc(100vh - 230px); }
@media (max-width: 760px) { .cal-bar .cal-legend { justify-content: flex-start; } .cal-month { height: auto; } }
@media (max-width: 760px) {
  .cal-cell.has-appt .cal-num::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ap); }
}
.cal-bar #newAppt { margin-left: 22px; }
@media (max-width: 760px) { .cal-bar #newAppt { margin-left: 0; } }

/* v0.60: logs (as in Wowza Stats) */
.seg.small a { padding: 4px 9px; font-size: 13px; }
table.logs { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.logs th, table.logs td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: left; font-size: 13px; white-space: nowrap; }
table.logs th { color: var(--text-2); font-weight: 600; font-size: 12.5px; }
table.logs tbody tr:hover { background: var(--grid); }
table.logs td.msg { max-width: 560px; overflow: hidden; text-overflow: ellipsis; }
.log-search input[type=search] { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; width: 220px; font: inherit; font-size: 13px; color: var(--text); }
.logs-foot { text-align: center; }
.logs-foot a { color: var(--accent); }
.badge.act-create { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.badge.act-delete, .badge.act-conflict { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.badge.act-update, .badge.act-status { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.badge.act-deactivate, .badge.act-password { background: color-mix(in srgb, var(--s2) 15%, transparent); color: var(--s2); }
.badge.act-backup { background: color-mix(in srgb, var(--s3) 15%, transparent); color: var(--s3); }
code { font-size: 12.5px; background: var(--grid); padding: 1px 5px; border-radius: 4px; }

/* v0.80: colour = vehicle (Impostazioni › Mezzi), style = status */
.st-completed, .st-pending, .st-confirmed, .st-cancelled { --st: #8a8984; }
.ev, .dev, .day-list li {
  background: color-mix(in srgb, var(--st) 16%, var(--surface));
  border-left: 3px solid color-mix(in srgb, var(--st) 70%, #000);
}
.dev:hover { background-color: color-mix(in srgb, var(--st) 26%, var(--surface)); }
.day-list li:hover { background-color: color-mix(in srgb, var(--st) 24%, var(--surface)); }
/* completed: thin oblique lines */
.ev.st-completed, .dev.st-completed, .day-list li.st-completed {
  background-image: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, var(--st) 45%, transparent) 5px 6.5px);
}
/* pending: dashed outline, lighter */
.ev.st-pending, .dev.st-pending, .day-list li.st-pending {
  background-color: color-mix(in srgb, var(--st) 7%, var(--surface));
  border-left-style: dashed; outline: 1px dashed color-mix(in srgb, var(--st) 55%, transparent); outline-offset: -1px;
}
/* cancelled: faded and struck through */
.ev.st-cancelled, .dev.st-cancelled, .day-list li.st-cancelled { opacity: .5; }
/* personal appointments: violet, italic, no lines */
.ev.appt, .dev.appt { --st: var(--ap); background: color-mix(in srgb, var(--ap) 12%, var(--surface)); border-left: 3px solid var(--ap); }
.dev.appt:hover { background: color-mix(in srgb, var(--ap) 20%, var(--surface)); }

/* legend samples (neutral grey) and vehicle colours */
.cal-legend .lg i, .st-badge i {
  display: inline-block; width: 16px; height: 11px; border-radius: 2px; margin-right: 5px; vertical-align: -1px;
  background: color-mix(in srgb, var(--st) 18%, var(--surface)); border-left: 3px solid color-mix(in srgb, var(--st) 70%, #000);
}
.cal-legend .lg.st-completed i, .st-badge.st-completed i {
  background-image: repeating-linear-gradient(135deg, transparent 0 3px, color-mix(in srgb, var(--st) 55%, transparent) 3px 4px);
}
.cal-legend .lg.st-pending i, .st-badge.st-pending i { background: var(--surface); border-left-style: dashed; outline: 1px dashed color-mix(in srgb, var(--st) 60%, transparent); outline-offset: -1px; }
.cal-legend .lg.st-cancelled i, .st-badge.st-cancelled i { opacity: .45; }
.cal-legend .appt-leg i { --st: var(--ap); background: color-mix(in srgb, var(--ap) 18%, var(--surface)); border-left-color: var(--ap); }
.st-badge i { margin-right: 0; }
.lg-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 2px; }
.lg-veh i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.cal-bar .cal-legend { margin-top: 8px; }
/* cancelled: horizontal line across the box */
.ev.st-cancelled, .dev.st-cancelled, .day-list li.st-cancelled, .cal-legend .lg.st-cancelled i, .st-badge.st-cancelled i {
  background-image: linear-gradient(to bottom, transparent calc(50% - 1px), color-mix(in srgb, var(--st) 75%, #000) calc(50% - 1px), color-mix(in srgb, var(--st) 75%, #000) calc(50% + 1px), transparent calc(50% + 1px));
}
.ev.st-cancelled, .dev.st-cancelled, .day-list li.st-cancelled { opacity: .6; }

/* v0.85: same background for every status; only the left marker and the lines change */
.ev.st-pending, .dev.st-pending, .day-list li.st-pending,
.ev.st-cancelled, .dev.st-cancelled, .day-list li.st-cancelled {
  background-color: color-mix(in srgb, var(--st) 16%, var(--surface)); outline: 0; opacity: 1;
}
.ev.st-pending, .dev.st-pending, .day-list li.st-pending { border-left-style: dashed; }
.ev.st-cancelled, .dev.st-cancelled, .day-list li.st-cancelled { border-left-style: dotted; }
.ev.st-cancelled span, .dev.st-cancelled b, .day-list .st-cancelled b { color: inherit; }
.cal-legend .lg.st-pending i, .st-badge.st-pending i,
.cal-legend .lg.st-cancelled i, .st-badge.st-cancelled i {
  background-color: color-mix(in srgb, var(--st) 18%, var(--surface)); outline: 0; opacity: 1;
}
.cal-legend .lg.st-cancelled i, .st-badge.st-cancelled i { border-left-style: dotted; }
@media (max-width: 700px) {
  table.svc-list td.time { grid-column: 1; grid-row: auto; }
  table.svc-list td.stat, table.svc-list td.cust, table.svc-list td.route { grid-column: 2; }
}

/* "+N altri" tooltip */
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip-row span { font-variant-numeric: tabular-nums; opacity: .8; }
.tip-row.canc { text-decoration: line-through; opacity: .7; }
.more { cursor: help; }

/* quick entry */
.dlg-head .mode-seg { margin-left: auto; margin-right: 10px; }
.dlg-head .mode-seg button { padding: 4px 10px; font-size: 13px; }
#svcForm.quick [data-full] { display: none; }
#svcForm.quick .fields.f3 { grid-template-columns: 1fr 1fr; }
#svcForm.quick .cust-f { grid-column: 1 / -1; }
.todo-mark { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #e0a100; margin-right: 4px; vertical-align: 1px; flex: none; }
.todo-txt { color: #b07d00; font-style: italic; }
.mode-seg[hidden] { display: none; }
/* thicker left marker */
.ev, .dev, .day-list li, .ev.appt, .dev.appt { border-left-width: 6px; }
.cal-legend .lg i, .st-badge i { border-left-width: 5px; }
.badge.act-sheet { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.sheet-h { margin-top: 22px; }

/* trip sheet box */
.sheet-box { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 10px; margin: 12px 0 4px; }
.sheet-box legend { font-size: 12px; font-weight: 600; color: var(--text-2); padding: 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.sheet-box p { margin: 4px 0; }
.sheet-act { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.sheet-act label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--text-2); }
.sheet-act .km-in { width: 140px; }
.sheet-link { margin-top: 8px; }
.sheet-fields { margin-top: 4px; }
.badge.warn { background: color-mix(in srgb, #e0a100 18%, transparent); color: #a37400; }
.sheet-act .km-in { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px; font-size: 16px; }
table.sheet-list td.route { white-space: normal; min-width: 200px; }
table.sheet-list th.num, table.sheet-list td.num { text-align: right; }
@media (max-width: 700px) {
  table.sheet-list thead { display: none; }
  table.sheet-list, table.sheet-list tbody { display: block; }
  table.sheet-list tr { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 2px; border-bottom: 1px solid var(--grid); }
  table.sheet-list td { display: block; padding: 0; border: 0; white-space: normal; text-align: left !important; min-width: 0; }
  table.sheet-list td:first-child { grid-row: span 2; }
  table.sheet-list td:not(:first-child) { grid-column: 2; }
  table.sheet-list td.date, table.sheet-list td.time { display: inline; }
  table.sheet-list td[data-l] { font-size: 13px; color: var(--text-2); }
  table.sheet-list td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); }
}

/* km and driving time */
.route-calc { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -2px 0 10px; font-size: 13px; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; font-size: 13px; text-decoration: underline; }
.err-txt { color: var(--bad); }
/* top menu on phones: wrap, never overflow */
@media (max-width: 700px) {
  .nav { flex-wrap: wrap; }
  .nav a { white-space: nowrap; padding: 6px 8px; }
  .nav a.on { padding: 5px 7px; }
}

/* password recovery */
.login-h { font-size: 15px; text-align: center; margin: -4px 0 2px; }
.login-link { text-align: center; font-size: 13px; color: var(--accent); }
.login-btn { text-align: center; text-decoration: none; }
.ok-box { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--text); border-radius: 6px; padding: 9px 11px; margin: 0; }
.login-box .hint { margin: 0; }
.badge.act-reset { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }

/* appointment reminders */
.rem-stack { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: grid; gap: 10px; max-width: calc(100vw - 32px); }
.rem-box { display: flex; align-items: center; gap: 12px; width: 380px; max-width: 100%; padding: 12px 14px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 6px solid var(--ap, #7a5ad6);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18); animation: rem-in .25s ease-out; }
.rem-ico { color: var(--ap, #7a5ad6); flex: none; animation: rem-ring 1s ease-in-out 3; }
.rem-txt { flex: 1; display: grid; gap: 2px; min-width: 0; }
.rem-txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rem-txt span { font-size: 13px; color: var(--text-2); }
.rem-act { display: flex; gap: 6px; flex: none; }
@keyframes rem-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes rem-ring { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(14deg); } 75% { transform: rotate(-14deg); } }
@media (max-width: 520px) { .rem-box { flex-wrap: wrap; } .rem-act { width: 100%; justify-content: flex-end; } }

/* automatic backup form */
.bk-form .span2 { grid-column: span 2; }
.bk-form .bk-pasv { align-self: end; padding-bottom: 8px; }
.bk-form .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge.act-autobackup { background: color-mix(in srgb, var(--s3) 15%, transparent); color: var(--s3); }
@media (max-width: 600px) { .bk-form .span2 { grid-column: auto; } }
.bk-form .bk-on { margin: 10px 0 8px; }
dl.info.bk-info { column-gap: 8px; }
.bk-status p { margin: 0 0 8px; font-size: 13.5px; }
.bk-status .lbl { color: var(--text-2); margin-right: 6px; }
.bk-status .nw { white-space: nowrap; }
.bk-status .bk-last { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bk-status .bk-last .lbl { margin-right: 0; flex: none; }
.bk-status .bk-file { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-status .bk-parts::before { content: "· "; }
@media (max-width: 640px) { .bk-status .bk-last { flex-wrap: wrap; } .bk-status .bk-parts::before { content: none; } }
.bk-form .bk-sub { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--text-2); }
.bk-form .bk-sub .muted { font-weight: 400; }
.bk-form .bk-local { margin: 0 0 4px; font-size: 13.5px; }

/* push notifications */
.push-ask { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); font-size: 13.5px; }
.push-ask span { flex: 1; min-width: 220px; }
.push-state { margin: 6px 0 10px; }
.push-state.ok { color: var(--good); }
.push-state.err { color: var(--bad); }
