/* Installation Scheduler
   Visual language borrowed from a setting-out schedule: hairline rules, a
   strict grid, and every identifier, time and duration set in mono so the
   scannable data reads differently from the prose around it. */

:root {
  --ink:        #12151a;
  --surface:    #ffffff;
  --raised:     #f7f8fa;
  --sunken:     #eef1f5;
  --line:       #dfe4ea;
  --line-soft:  #eaeef3;
  --text:       #12151a;
  --text-mute:  #5c6673;
  --text-faint: #8b95a3;

  --accent:      #1f5fd0;
  --accent-ink:  #ffffff;
  --accent-soft: #e8f0fd;
  --accent-line: #b9d0f5;

  --grey:   #6b7684;  --grey-soft:   #eef0f3;
  --blue:   #1f5fd0;  --blue-soft:   #e7f0fd;
  --violet: #6340d4;  --violet-soft: #eee9fd;
  --amber:  #b3690a;  --amber-soft:  #fdf0dd;
  --green:  #0e7a52;  --green-soft:  #e2f5ec;
  --yellow: #96770a;  --yellow-soft: #fbf3d8;
  --red:    #bb2d2d;  --red-soft:    #fbe8e8;
  --slate:  #4a5666;  --slate-soft:  #eceff3;

  --radius:    8px;
  --radius-sm: 5px;
  --shadow:    0 1px 2px rgba(18, 21, 26, .06), 0 4px 14px rgba(18, 21, 26, .05);
  --shadow-lg: 0 12px 40px rgba(18, 21, 26, .18);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo,
          Consolas, monospace;

  --sidebar: 216px;
  --header: 56px;
}

[data-theme="dark"] {
  --ink:        #0c0e12;
  --surface:    #171b21;
  --raised:     #1e232b;
  --sunken:     #12161c;
  --line:       #2b323c;
  --line-soft:  #232932;
  --text:       #e6eaf0;
  --text-mute:  #9aa5b4;
  --text-faint: #6d7885;

  --accent:      #558ff0;
  --accent-ink:  #0c0e12;
  --accent-soft: #16253c;
  --accent-line: #2b3f5e;

  --grey:   #97a2b0;  --grey-soft:   #232932;
  --blue:   #6ea1f5;  --blue-soft:   #16253c;
  --violet: #a68bf5;  --violet-soft: #241f3d;
  --amber:  #e8a548;  --amber-soft:  #33260f;
  --green:  #4cbf90;  --green-soft:  #102b21;
  --yellow: #d9bd52;  --yellow-soft: #2e2810;
  --red:    #e87070;  --red-soft:    #351a1a;
  --slate:  #8e9aab;  --slate-soft:  #212730;

  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sunken);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 { margin: 0; font-weight: 620; letter-spacing: -.011em; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.02rem; }
h3 { font-size: .92rem; }
p  { margin: 0 0 .7rem; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Micro label: the eyebrow used above every data group */
.eyebrow {
  font-family: var(--mono);
  font-size: .655rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
}

.muted { color: var(--text-mute); }
.faint { color: var(--text-faint); }
.small { font-size: .82rem; }
.tiny  { font-size: .74rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--ink);
  color: #d3dae4;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1rem;
  height: var(--header);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  color: #fff;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px;
  border-radius: 5px;
  background: linear-gradient(150deg, #3f7ee8, #1f5fd0 60%, #123a80);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: .68rem; font-weight: 700; color: #fff;
  flex: 0 0 auto;
}
.brand-text { line-height: 1.15; overflow: hidden; }
.brand-text strong { display: block; font-size: .82rem; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: .64rem; color: #7c8899; letter-spacing: .07em;
  text-transform: uppercase; font-family: var(--mono); }

.nav { padding: .6rem .5rem; overflow-y: auto; flex: 1; }
.nav-group { margin-bottom: .9rem; }
.nav-group > .eyebrow { padding: .2rem .55rem .35rem; color: #626f80; }
.nav a {
  display: flex; align-items: center; gap: .55rem;
  padding: .43rem .55rem;
  border-radius: var(--radius-sm);
  color: #b4bfcd;
  font-size: .855rem;
  font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff;
  text-decoration: none; }
.nav a.active { background: rgba(80, 140, 240, .17); color: #fff; }
.nav a.active .nav-icon { color: #79a8f5; }
.nav-icon { width: 16px; height: 16px; flex: 0 0 16px; color: #7d8b9d; }
.nav-count {
  margin-left: auto;
  font-family: var(--mono); font-size: .68rem;
  background: rgba(255, 255, 255, .1); color: #cdd6e2;
  padding: .05rem .34rem; border-radius: 20px;
}
.nav-count.alert { background: var(--red); color: #fff; }

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: .55rem;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .7rem;
  padding: 0 1.1rem;
  position: sticky; top: 0; z-index: 40;
}

.search {
  flex: 1; max-width: 440px;
  position: relative;
}
.search input {
  width: 100%;
  padding: .42rem .7rem .42rem 2rem;
  border: 1px solid var(--line);
  background: var(--raised);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}
.search svg {
  position: absolute; left: .55rem; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-faint); pointer-events: none;
}

.content { padding: 1.15rem 1.25rem 3rem; flex: 1; }
.content.wide { padding-left: .9rem; padding-right: .9rem; }

.page-head {
  display: flex; align-items: flex-start; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.page-head .titles { min-width: 0; }
.page-head h1 { display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: .45rem;
  flex-wrap: wrap; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .38rem;
  padding: .43rem .82rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: .845rem; font-weight: 550; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--raised); text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-primary:hover { background: #1a52b8; border-color: #1a52b8; }
[data-theme="dark"] .btn-primary { color: #08111f; }
[data-theme="dark"] .btn-primary:hover { background: #74a3f5; }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--raised); }
.btn-sm { padding: .26rem .55rem; font-size: .785rem; }
.btn-lg { padding: .6rem 1.1rem; font-size: .92rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text-mute);
  position: relative;
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.badge-dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--red); color: #fff;
  border-radius: 20px; font-size: .6rem; font-weight: 700;
  display: grid; place-items: center; font-family: var(--mono);
}

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: .72rem; font-weight: 700; font-family: var(--mono);
  border: 1px solid var(--accent-line);
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: .9rem; }
.card-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .68rem .9rem;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; display: flex; gap: .4rem;
  align-items: center; }
.card-body { padding: .9rem; }
.card-body.tight { padding: .6rem .9rem; }
.card-foot {
  padding: .6rem .9rem; border-top: 1px solid var(--line-soft);
  background: var(--raised);
  border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: .9rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }

/* ------------------------------------------------------------ stat tiles */

.stats { display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .72rem .8rem;
  position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.stat.tone-green::before { background: var(--green); }
.stat.tone-amber::before { background: var(--amber); }
.stat.tone-red::before   { background: var(--red); }
.stat.tone-grey::before  { background: var(--grey); }
.stat.tone-violet::before { background: var(--violet); }
.stat .value {
  font-family: var(--mono); font-size: 1.6rem; font-weight: 620;
  letter-spacing: -.03em; line-height: 1.1; display: block;
  font-variant-numeric: tabular-nums;
}
.stat .label { font-size: .78rem; color: var(--text-mute); }
a.stat:hover { border-color: var(--accent-line); text-decoration: none; }

/* --------------------------------------------------------------- badges */

.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .1rem .45rem;
  border-radius: 20px;
  font-size: .715rem; font-weight: 620;
  font-family: var(--mono); letter-spacing: .01em;
  white-space: nowrap;
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: 0 0 6px;
}
.pill.no-dot::before { display: none; }
.pill-grey   { background: var(--grey-soft);   color: var(--grey); }
.pill-blue   { background: var(--blue-soft);   color: var(--blue); }
.pill-violet { background: var(--violet-soft); color: var(--violet); }
.pill-amber  { background: var(--amber-soft);  color: var(--amber); }
.pill-green  { background: var(--green-soft);  color: var(--green); }
.pill-yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill-red    { background: var(--red-soft);    color: var(--red); }
.pill-slate  { background: var(--slate-soft);  color: var(--slate); }

.tag {
  display: inline-block; padding: .08rem .4rem;
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: 3px; font-size: .715rem; color: var(--text-mute);
  font-family: var(--mono);
}

.priority-Urgent { color: var(--red); font-weight: 700; }
.priority-High   { color: var(--amber); font-weight: 650; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th {
  text-align: left; padding: .45rem .6rem;
  font-family: var(--mono); font-size: .655rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--text-faint); font-weight: 600;
  border-bottom: 1px solid var(--line);
  white-space: nowrap; background: var(--raised);
  position: sticky; top: 0;
}
table.data td {
  padding: .5rem .6rem; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--raised); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data a.strong { font-weight: 600; color: var(--text); }
table.data a.strong:hover { color: var(--accent); }

/* ----------------------------------------------------------------- forms */

.field { margin-bottom: .8rem; }
.field label, .label {
  display: block; margin-bottom: .22rem;
  font-size: .78rem; font-weight: 600; color: var(--text);
}
.field .hint { font-size: .755rem; color: var(--text-faint); margin-top: .2rem; }
.req { color: var(--red); font-weight: 700; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"],
input[type="search"], input[type="tel"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: .43rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit; font-size: .875rem;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="date"], input[type="time"], input[type="number"] {
  font-family: var(--mono);
}
textarea { resize: vertical; min-height: 68px; line-height: 1.5; }
input.error, select.error, textarea.error { border-color: var(--red); }
.error-text { color: var(--red); font-size: .775rem; margin-top: .2rem; }

.field-row { display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.check {
  display: flex; align-items: flex-start; gap: .45rem;
  font-size: .845rem; padding: .18rem 0; cursor: pointer;
}
.check input { width: auto; margin: .22rem 0 0; flex: 0 0 auto; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .24rem .55rem;
  border: 1px solid var(--line); border-radius: 20px;
  font-size: .785rem; cursor: pointer; background: var(--surface);
  user-select: none;
}
.chip input { display: none; }
.chip:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent-line);
  color: var(--accent); font-weight: 600;
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent);
  outline-offset: 2px; }

.filters {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
}
.filters .field { margin: 0; min-width: 130px; }
.filters .field label { font-size: .68rem; font-family: var(--mono);
  letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); }

fieldset {
  border: none; padding: 0; margin: 0 0 1.4rem;
}
.form-section {
  border-top: 1px solid var(--line);
  padding-top: .9rem; margin-top: 1.3rem;
}
.form-section:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }
.form-section > header {
  display: flex; align-items: baseline; gap: .6rem; margin-bottom: .75rem;
}
.form-section > header .step {
  font-family: var(--mono); font-size: .7rem; color: var(--text-faint);
  border: 1px solid var(--line); border-radius: 3px; padding: 0 .3rem;
}

/* --------------------------------------------------------- THE CALENDAR */

.cal-toolbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .6rem .8rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .8rem;
}
.cal-range {
  font-family: var(--mono); font-weight: 620; font-size: .9rem;
  letter-spacing: -.01em; min-width: 190px; text-align: center;
}
.seg {
  display: inline-flex; border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.seg a {
  padding: .3rem .6rem; font-size: .8rem; color: var(--text-mute);
  border-right: 1px solid var(--line); background: var(--surface);
  font-weight: 550;
}
.seg a:last-child { border-right: none; }
.seg a:hover { background: var(--raised); text-decoration: none; }
.seg a.active { background: var(--accent); color: #fff; }
[data-theme="dark"] .seg a.active { color: #08111f; }

.cal-scroll { overflow-x: auto; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); }

.cal-grid {
  display: grid;
  min-width: 940px;
  --team-col: 132px;
}
.cal-grid.days-1  { grid-template-columns: var(--team-col) 1fr; min-width: 520px; }
.cal-grid.days-7  { grid-template-columns: var(--team-col) repeat(7, minmax(112px, 1fr)); }
.cal-grid.days-14 { grid-template-columns: var(--team-col) repeat(14, minmax(78px, 1fr)); min-width: 1240px; }

.cal-head {
  position: sticky; top: 0; z-index: 5;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  padding: .38rem .4rem; text-align: center;
}
.cal-head .dow {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-faint); display: block;
}
.cal-head .dom {
  font-family: var(--mono); font-size: .95rem; font-weight: 620;
  line-height: 1.1;
}
.cal-head.is-today { background: var(--accent-soft); }
.cal-head.is-today .dom { color: var(--accent); }
.cal-head.is-weekend { background: var(--sunken); }
.cal-head.week-start { border-left: 2px solid var(--line); }
.cal-corner {
  position: sticky; left: 0; top: 0; z-index: 6;
  background: var(--raised); border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: .38rem .55rem; display: flex; align-items: center;
}

.cal-team {
  position: sticky; left: 0; z-index: 4;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
  padding: .5rem .55rem;
  display: flex; flex-direction: column; gap: .12rem; justify-content: center;
}
.cal-team .code {
  font-family: var(--mono); font-weight: 650; font-size: .82rem;
  letter-spacing: -.01em;
}
.cal-team .code a { color: var(--text); }
.cal-team .meta { font-size: .68rem; color: var(--text-faint); }
.cal-team .util {
  height: 3px; background: var(--sunken); border-radius: 2px; overflow: hidden;
  margin-top: .18rem;
}
.cal-team .util span { display: block; height: 100%; background: var(--accent); }

.cal-cell {
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  padding: .22rem;
  min-height: 74px;
  display: flex; flex-direction: column; gap: .18rem;
  background: var(--surface);
}
.cal-cell.is-weekend, .cal-cell.non-working { background: var(--sunken); }
.cal-cell.is-today { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.cal-cell.is-past { opacity: .62; }
.cal-cell.week-start { border-left: 2px solid var(--line); }
.cal-cell.drop-target {
  outline: 2px dashed var(--accent); outline-offset: -3px;
  background: var(--accent-soft);
}
.cal-cell.drop-block {
  outline: 2px dashed var(--red); outline-offset: -3px;
  background: var(--red-soft);
}

.slot-open {
  display: flex; align-items: center; justify-content: center; gap: .25rem;
  border: 1px dashed var(--line);
  border-radius: 4px; padding: .2rem .25rem;
  font-family: var(--mono); font-size: .66rem; color: var(--text-faint);
  background: transparent; cursor: pointer; width: 100%;
  transition: all .1s; min-height: 22px; text-align: center;
}
.slot-open:hover {
  border-color: var(--accent); border-style: solid;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.slot-open .plus { font-weight: 700; }

.slot-blocked {
  border-radius: 4px; padding: .18rem .3rem;
  font-family: var(--mono); font-size: .64rem;
  color: var(--text-faint);
  background: repeating-linear-gradient(
    -45deg, transparent, transparent 4px,
    var(--line-soft) 4px, var(--line-soft) 8px);
  border: 1px solid var(--line-soft);
  text-align: center; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}

.job-chip {
  display: block; border-radius: 4px; padding: .22rem .32rem;
  border-left: 3px solid var(--grey);
  background: var(--grey-soft);
  font-size: .705rem; line-height: 1.25; cursor: grab;
  overflow: hidden; color: var(--text);
}
.job-chip:hover { text-decoration: none; filter: brightness(.97); }
[data-theme="dark"] .job-chip:hover { filter: brightness(1.18); }
.job-chip.dragging { opacity: .4; }
.job-chip .time {
  font-family: var(--mono); font-size: .655rem; font-weight: 620;
  display: block; letter-spacing: -.02em;
}
.job-chip .who {
  display: block; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-weight: 550;
}
.job-chip .what {
  display: block; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--text-mute); font-size: .665rem;
}
.job-chip.tone-blue   { border-color: var(--blue);   background: var(--blue-soft); }
.job-chip.tone-violet { border-color: var(--violet); background: var(--violet-soft); }
.job-chip.tone-amber  { border-color: var(--amber);  background: var(--amber-soft); }
.job-chip.tone-green  { border-color: var(--green);  background: var(--green-soft); }
.job-chip.tone-yellow { border-color: var(--yellow); background: var(--yellow-soft); }
.job-chip.tone-red    { border-color: var(--red);    background: var(--red-soft); }
.job-chip.tone-slate  { border-color: var(--slate);  background: var(--slate-soft); }
.job-chip .time { color: inherit; }

.cal-legend {
  display: flex; flex-wrap: wrap; gap: .8rem; align-items: center;
  padding: .55rem .8rem; font-size: .74rem; color: var(--text-mute);
}
.cal-legend .key { display: inline-flex; align-items: center; gap: .3rem; }
.cal-legend .swatch {
  width: 11px; height: 11px; border-radius: 3px; border-left: 3px solid;
}

/* Day view */
.day-lanes { display: grid; gap: .5rem; padding: .8rem; }
.day-lane {
  display: grid; grid-template-columns: 130px 1fr; gap: .6rem;
  align-items: stretch;
}
.day-lane .lane-slots { display: flex; gap: .35rem; flex-wrap: wrap; }
.day-lane .lane-slots > * { flex: 1 1 130px; min-height: 46px; }

/* ------------------------------------------------------------ side panel */

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(12, 16, 22, .5);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .16s;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg); z-index: 91;
  transform: translateX(100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer header {
  display: flex; align-items: center; gap: .6rem;
  padding: .8rem .95rem; border-bottom: 1px solid var(--line);
}
.drawer .drawer-body { padding: .95rem; overflow-y: auto; flex: 1; }
.drawer footer {
  padding: .7rem .95rem; border-top: 1px solid var(--line);
  display: flex; gap: .5rem; justify-content: flex-end; background: var(--raised);
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12, 16, 22, .5);
  z-index: 95; display: grid; place-items: center; padding: 1rem;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  width: min(520px, 100%); max-height: 90vh; overflow-y: auto;
}
.modal header { padding: .85rem .95rem; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: .5rem; }
.modal .modal-body { padding: .95rem; }
.modal footer { padding: .7rem .95rem; border-top: 1px solid var(--line);
  display: flex; gap: .5rem; justify-content: flex-end; background: var(--raised);
  border-radius: 0 0 var(--radius) var(--radius); }

dialog.modal-native {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 2rem)); box-shadow: var(--shadow-lg);
}
dialog.modal-native::backdrop { background: rgba(12, 16, 22, .5); }

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 120;
  display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .6rem .75rem; font-size: .85rem;
  display: flex; gap: .5rem; align-items: flex-start;
  animation: toast-in .18s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.warn  { border-left-color: var(--amber); }
.toast.ok    { border-left-color: var(--green); }
.toast button { background: none; border: none; cursor: pointer;
  color: var(--text-faint); padding: 0; margin-left: auto; font-size: 1rem;
  line-height: 1; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* --------------------------------------------------------------- states */

.empty {
  text-align: center; padding: 2.4rem 1rem; color: var(--text-mute);
}
.empty .glyph {
  width: 42px; height: 42px; margin: 0 auto .6rem; color: var(--text-faint);
  opacity: .6;
}
.empty h3 { margin-bottom: .3rem; color: var(--text); }
.empty p { max-width: 380px; margin: 0 auto .9rem; font-size: .865rem; }

.banner {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .65rem .8rem; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--raised);
  font-size: .855rem; margin-bottom: .9rem;
}
.banner svg { width: 17px; height: 17px; flex: 0 0 17px; margin-top: .1rem; }
.banner.warn  { background: var(--amber-soft); border-color: transparent;
  color: var(--amber); }
.banner.error { background: var(--red-soft); border-color: transparent;
  color: var(--red); }
.banner.info  { background: var(--accent-soft); border-color: transparent;
  color: var(--accent); }
.banner strong { color: inherit; }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ job detail */

.job-hero {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .95rem 1.05rem; margin-bottom: .9rem;
}
.job-hero .number {
  font-family: var(--mono); font-size: 1.35rem; font-weight: 650;
  letter-spacing: -.02em;
}
.job-hero .schedule-strip {
  display: flex; flex-wrap: wrap; gap: .9rem; margin-top: .7rem;
  padding-top: .7rem; border-top: 1px solid var(--line-soft);
}
.job-hero .schedule-strip .item { min-width: 110px; }
.job-hero .schedule-strip .val {
  font-family: var(--mono); font-size: .95rem; font-weight: 600;
  display: block; margin-top: .05rem;
}

.detail-list { display: grid; gap: .1rem; }
.detail-row {
  display: grid; grid-template-columns: 158px 1fr; gap: .7rem;
  padding: .34rem 0; border-bottom: 1px solid var(--line-soft);
  font-size: .86rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--text-mute); font-size: .8rem; }
.detail-row dd { margin: 0; white-space: pre-wrap; }
.detail-row dd:empty::after { content: "—"; color: var(--text-faint); }

.section-nav {
  display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .35rem;
  margin-bottom: .8rem; border-bottom: 1px solid var(--line);
}
.section-nav a {
  padding: .3rem .55rem; font-size: .8rem; color: var(--text-mute);
  border-radius: var(--radius-sm); white-space: nowrap; font-weight: 550;
}
.section-nav a:hover { background: var(--raised); text-decoration: none; }

.timeline { position: relative; padding-left: 1.1rem; }
.timeline::before {
  content: ""; position: absolute; left: 4px; top: .4rem; bottom: .4rem;
  width: 1px; background: var(--line);
}
.timeline-item { position: relative; padding: 0 0 .85rem; }
.timeline-item::before {
  content: ""; position: absolute; left: -1.1rem; top: .32rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.timeline-item.muted-dot::before { border-color: var(--line); }
.timeline-item .when {
  font-family: var(--mono); font-size: .7rem; color: var(--text-faint);
}
.timeline-item .move {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  margin-top: .25rem; font-size: .78rem;
}
.move-box {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: .25rem .45rem; font-family: var(--mono); font-size: .72rem;
  background: var(--raised);
}
.move-box.to { border-color: var(--accent-line); background: var(--accent-soft);
  color: var(--accent); }

.note {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6rem .7rem; margin-bottom: .5rem; background: var(--surface);
}
.note.vis-management { border-left: 3px solid var(--violet); }
.note.vis-pm { border-left: 3px solid var(--blue); }
.note.vis-installer { border-left: 3px solid var(--green); }
.note header { display: flex; gap: .5rem; align-items: center;
  margin-bottom: .3rem; font-size: .76rem; color: var(--text-mute); }
.note p { margin: 0; white-space: pre-wrap; font-size: .875rem; }

.file-grid { display: grid; gap: .55rem;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.file-tile {
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--surface); display: flex;
  flex-direction: column;
}
.file-tile .thumb {
  height: 96px; background: var(--sunken); display: grid; place-items: center;
  overflow: hidden;
}
.file-tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-tile .thumb svg { width: 26px; height: 26px; color: var(--text-faint); }
.file-tile .meta { padding: .4rem .5rem; font-size: .755rem; }
.file-tile .meta .name {
  display: block; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

.file-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .55rem; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: .4rem; background: var(--surface);
}
.file-row .ftype {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--sunken); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: .6rem; font-weight: 700;
  color: var(--text-mute); flex: 0 0 30px;
}

/* ------------------------------------------------------- installer view */

.job-card-mobile {
  border: 1px solid var(--line); border-left: 4px solid var(--blue);
  border-radius: var(--radius); background: var(--surface);
  padding: .8rem .85rem; margin-bottom: .65rem; display: block; color: inherit;
}
.job-card-mobile:hover { text-decoration: none; border-color: var(--accent-line); }
.job-card-mobile.tone-violet { border-left-color: var(--violet); }
.job-card-mobile.tone-amber  { border-left-color: var(--amber); }
.job-card-mobile.tone-green  { border-left-color: var(--green); }
.job-card-mobile.tone-red    { border-left-color: var(--red); }
.job-card-mobile.tone-grey   { border-left-color: var(--grey); }
.job-card-mobile .when {
  font-family: var(--mono); font-size: 1.02rem; font-weight: 650;
  letter-spacing: -.02em;
}
.job-card-mobile .addr { font-size: .84rem; color: var(--text-mute);
  margin-top: .15rem; }
.job-card-mobile .strip {
  display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .45rem;
}

.next-up {
  border: 1px solid var(--accent-line); background: var(--accent-soft);
  border-radius: var(--radius); padding: .9rem;
}
.next-up .eyebrow { color: var(--accent); }

.contact-row {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: .4rem; background: var(--surface);
}
.contact-row .who { flex: 1; min-width: 0; }
.contact-row .who strong { display: block; font-size: .875rem; }

/* --------------------------------------------------------------- auth */

.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  padding: 1.5rem; background:
    radial-gradient(1100px 500px at 12% -8%, rgba(31, 95, 208, .14), transparent 60%),
    var(--sunken);
}
.auth-card {
  width: min(420px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 1.6rem 1.5rem;
}
.auth-card.wide { width: min(600px, 100%); }
.auth-mark {
  display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem;
}
.auth-mark .brand-mark { width: 32px; height: 32px; font-size: .76rem; }
.auth-card h1 { font-size: 1.18rem; margin-bottom: .3rem; }
.auth-card > p.lead { color: var(--text-mute); font-size: .875rem;
  margin-bottom: 1.1rem; }

/* -------------------------------------------------------------- reports */

.bar-row {
  display: grid; grid-template-columns: 130px 1fr 52px; gap: .6rem;
  align-items: center; padding: .28rem 0; font-size: .84rem;
}
.bar-track { background: var(--sunken); border-radius: 3px; height: 16px;
  overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px;
  min-width: 2px; }
.bar-fill.green { background: var(--green); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red   { background: var(--red); }
.bar-value { font-family: var(--mono); font-size: .8rem; text-align: right; }

.spark { display: flex; align-items: flex-end; gap: 2px; height: 60px; }
.spark div {
  flex: 1; background: var(--accent-soft); border-top: 2px solid var(--accent);
  border-radius: 2px 2px 0 0; min-height: 2px;
}

.pagination {
  display: flex; gap: .4rem; align-items: center; justify-content: center;
  padding: .7rem; font-size: .84rem;
}

/* ---------------------------------------------------------- responsive */

.mobile-only { display: none; }
.mobile-bar { display: none; }

@media (max-width: 1100px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --header: 52px; }
  .shell { flex-direction: column; }
  .sidebar { display: none; }
  .sidebar.open {
    display: flex; position: fixed; inset: 0 auto 0 0; z-index: 100;
    width: 254px; height: 100vh;
  }
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }
  .content { padding: .8rem .75rem 4.6rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .detail-row { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .detail-row dt { font-size: .72rem; text-transform: uppercase;
    letter-spacing: .06em; font-family: var(--mono); }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  table.data th { position: static; }

  /* Bottom navigation for installers on site */
  .mobile-bar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .mobile-bar a {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: .12rem; padding: .35rem .2rem; font-size: .66rem;
    color: var(--text-mute); font-weight: 550;
  }
  .mobile-bar a.active { color: var(--accent); }
  .mobile-bar a:hover { text-decoration: none; }
  .mobile-bar svg { width: 19px; height: 19px; }

  .toasts { left: .6rem; right: .6rem; bottom: 4.6rem; max-width: none; }
  .drawer { width: 100%; }
}

@media (max-width: 560px) {
  .cal-grid.days-14, .cal-grid.days-7 { --team-col: 96px; }
  .job-hero .number { font-size: 1.15rem; }
}

@media print {
  .sidebar, .topbar, .mobile-bar, .page-head .actions, .toasts { display: none; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
