:root {
  --navy: #12305a;
  --navy-2: #0c2242;
  --teal: #1fa896;
  --teal-soft: #e3f6f3;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1b2433;
  --muted: #5d6b80;
  --line: #e1e6ee;
  --red: #c8372d;
  --red-soft: #fdecea;
  --amber: #b26a00;
  --amber-soft: #fff4e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 64, .06), 0 2px 8px rgba(16, 32, 64, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.45; color: var(--text); background: var(--bg);
}
a { color: var(--navy); }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.loading { padding: 40px; color: var(--muted); }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 8px 18px; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: #a9bcd8; }
.nav a { display: flex; align-items: center; justify-content: space-between; color: #d9e3f2; text-decoration: none; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .13); color: #fff; }
.nav .count { background: var(--teal); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.side .who { margin-top: auto; font-size: 13px; color: #a9bcd8; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.side .who strong { color: #fff; display: block; }
.side .who button { margin-top: 8px; }
.main { padding: 28px 32px 60px; max-width: 1200px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card.flush { padding: 0; overflow: hidden; }
.stat { display: flex; flex-direction: column; }
.stat b { font-size: 26px; letter-spacing: -.02em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* buttons and inputs */
button, .btn {
  font: inherit; font-weight: 600; font-size: 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--text); padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { border-color: #c6cfdc; background: #fafbfd; }
button.primary, .btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
button.primary:hover { background: #1a9584; }
button.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
button.danger { color: var(--red); }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--muted); font-weight: 500; }
button.link:hover { color: var(--text); }
button.small, .btn.small { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }
.side button { background: transparent; color: #d9e3f2; border-color: rgba(255, 255, 255, .25); }
input, select, textarea {
  font: inherit; font-size: 15px; width: 100%; padding: 9px 11px; border: 1px solid #cfd7e3; border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.fields .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 14px; }
.search { max-width: 380px; }

/* chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip .n { opacity: .7; margin-left: 4px; font-weight: 500; }
.tag { display: inline-block; background: var(--teal-soft); color: #0f6f62; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.tag.grey { background: #eef1f5; color: var(--muted); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f9fc; }
td .sub { display: block; font-size: 13px; color: var(--muted); }

/* call-backs */
.task { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .when { font-weight: 700; font-size: 14px; }
.task .when.late { color: var(--red); }
.task .what b { display: block; }
.task .what a.phone { font-weight: 600; text-decoration: none; color: var(--teal); }
.task.done { opacity: .5; }

/* history */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.history .text { white-space: pre-wrap; }

.kinds { display: flex; gap: 6px; margin-bottom: 8px; }
.quickdates { display: flex; gap: 6px; flex-wrap: wrap; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%); }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { color: var(--navy); padding: 0 0 20px; }
.login .brand small { color: var(--muted); }
.login form { display: flex; flex-direction: column; gap: 14px; }
.err { background: var(--red-soft); color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: 14px; }
.ok { background: var(--teal-soft); color: #0f6f62; padding: 12px 14px; border-radius: 8px; font-size: 14px; }
.pw { font-family: ui-monospace, Menlo, monospace; font-size: 17px; font-weight: 700; letter-spacing: .04em; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 500; box-shadow: 0 6px 24px rgba(0, 0, 0, .2); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--red); }

/* import */
.map td { padding: 7px 14px; }
.map select { padding: 6px 8px; font-size: 14px; }
.preview { overflow-x: auto; }
.preview td, .preview th { white-space: nowrap; font-size: 13px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side .who { margin: 0 0 0 auto; border: 0; padding: 0; }
  .side .who strong, .side .who span { display: none; }
  .side .who button { margin: 0; }
  .main { padding: 18px 16px 50px; }
  .grid2 { grid-template-columns: 1fr; }
  .fields { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .task { grid-template-columns: 56px 1fr; }
  .task .acts { grid-column: 1 / -1; }
}

/* small helpers */
.cardhead { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cardhead h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.cardhead p { margin: 4px 0 0; }
.formstack { display: flex; flex-direction: column; gap: 12px; }
.gap { margin-top: 16px; }
.grow { flex: 1; min-width: 160px; width: auto; }
.tips { margin: 0 0 14px; padding-left: 18px; color: var(--muted); font-size: 14px; }
.tips li { margin-bottom: 4px; }
.stagelist { list-style: none; margin: 0 0 12px; padding: 0; }
.stagelist li { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.picker { display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; margin-top: 4px; padding: 4px; }
.picker .link { text-align: left; color: var(--text); width: 100%; }
.taskform { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; background: #fafbfd; }
.time { width: 130px; }
.dateinput { width: 160px; padding: 5px 8px; font-size: 13px; }
.stagebar { margin-bottom: 20px; padding: 14px 18px; }
.stagebar h3 { margin-bottom: 8px; }
.toolbar { margin-bottom: 14px; }
.more { justify-content: center; margin-top: 14px; }
.userline { padding: 6px 0; }
tr.off td { opacity: .6; }
a.phone { color: var(--teal); font-weight: 600; text-decoration: none; }
.task .sub { display: block; font-weight: 500; }

/* Admin "Open account" (support access) */
.supportbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--amber-soft); color: var(--amber); border: 1px solid currentColor; border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.supportbar button { background: #fff; }

.cosearch { padding: 14px 16px; border-bottom: 1px solid var(--line, #e6eaf0); display: flex; flex-direction: column; gap: 6px; }
.cosearch input { width: 100%; }

.task .tasknote { display: block; color: var(--muted); font-size: 13px; white-space: pre-wrap; margin: 2px 0; }
.taskform textarea { width: 100%; }

/* Today page: compact call-back and task boxes so everything fits on one screen */
.compactform { padding: 14px 18px; }
.compactform h2 { font-size: 16px; margin-bottom: 8px; }
.compactform .formstack { gap: 9px; }
.compactform .chip { padding: 3px 10px; font-size: 12px; }
.fields3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.fieldsrow { display: grid; grid-template-columns: minmax(7.5rem, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 10px 12px; align-items: end; }
.fieldsrow button { white-space: nowrap; }
@media (max-width: 700px) { .fields3, .fieldsrow { grid-template-columns: 1fr; } }
