:root {
    /* Dark by design: this panel is looked at for long stretches, often next to
       a phone showing the same data. `color-scheme` also darkens the things CSS
       cannot reach - date pickers, select popups, scrollbars. */
    color-scheme: dark;

    --bg: #0f1117;
    --card: #171a23;
    --surface-2: #1f2430;
    --input-bg: #12151d;
    --ink: #e5e7eb;
    --muted: #9ca3af;
    --line: #2a2f3a;
    --topbar: #1b1a35;
    /* Strong enough to carry white button text; links get the lighter tint. */
    --brand: #4f46e5;
    --link: #a5b4fc;
    --brand-soft: #23214d;
    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;
    --blue: #3b82f6;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

.topbar {
    background: var(--topbar);
    color: #fff;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    min-height: 56px;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; margin-right: 8px; }
.topbar a { color: #c7d2fe; padding: 6px 0; }
.topbar a:hover, .topbar a.active { color: #fff; text-decoration: none; }
.topbar a.active { border-bottom: 2px solid #a5b4fc; }
.topbar form { margin-left: auto; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
    .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
}
.badge.pending { background: #402406; color: #fbbf24; }
.badge.assigned { background: #172554; color: #93c5fd; }
.badge.on_the_way { background: #221f52; color: #a5b4fc; }
.badge.in_progress { background: #083344; color: #67e8f9; }
.badge.completed { background: #08331a; color: #86efac; }
.badge.cancelled { background: #3f1212; color: #fca5a5; }
.badge.online { background: #08331a; color: #86efac; }
.badge.offline { background: #262b36; color: #9ca3af; }

.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 11px; font-size: 13px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=tel], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    background: var(--input-bg);
    color: var(--ink);
}
input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; }
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.help { color: var(--muted); font-size: 12px; margin-top: 4px; }

.flash { background: #08331a; border: 1px solid #166534; color: #86efac; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }
.errors { background: #3f1212; border: 1px solid #7f1d1d; color: #fca5a5; padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; }
.errors ul { margin: 6px 0 0 18px; padding: 0; }

.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { text-align: center; padding: 8px 0; }
.cal td { border: 1px solid var(--line); height: 120px; padding: 6px; vertical-align: top; }
.cal td.dim { background: var(--surface-2); color: var(--muted); }
.cal td.today { background: var(--brand-soft); }
.cal .daynum { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.cal .chip {
    display: block;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 5px;
    margin-bottom: 3px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cal .chip:hover { text-decoration: none; opacity: .9; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

.login-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }

.map-frame { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 10px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.pill { background: var(--surface-2); border-radius: 6px; padding: 1px 7px; font-size: 12px; }

/* The PIN is the whole credential, so it gets typed in something that reads
   like a keypad rather than a normal text box. */
.pin-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 24px;
    letter-spacing: 10px;
    text-align: center;
}
