:root {
  --red: #b5121b;
  --red-dark: #8f0e15;
  --ink: #1e2227;
  --muted: #6b737c;
  --line: #dfe3e7;
  --panel: #ffffff;
  --bg: #f4f6f8;
  --soft: #eef1f4;
  --shadow: 0 8px 28px rgba(20, 26, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar { min-height: 78px; padding: 14px 22px; display:flex; align-items:center; justify-content:space-between; gap:16px; background:#171a1e; color:#fff; border-bottom:4px solid var(--red); }
.brand { display:flex; align-items:center; gap:12px; }
.brand-mark { width:48px; height:48px; border-radius:10px; background:var(--red); display:grid; place-items:center; font-weight:900; letter-spacing:.5px; }
.brand h1 { margin:0; font-size:22px; line-height:1.1; }
.brand p { margin:3px 0 0; font-size:12px; color:#c8cdd2; }
.top-actions { display:flex; align-items:center; gap:12px; }
.staging-pill { background:#2a2f35; border:1px solid #3d444c; padding:8px 10px; border-radius:999px; font-size:12px; color:#e7e9eb; }
.view-select { display:flex; align-items:center; gap:8px; font-size:12px; color:#d7dbe0; }
.view-select select { border-radius:8px; border:1px solid #49515a; background:#24292f; color:#fff; padding:8px 10px; }
.layout { display:grid; grid-template-columns: 340px minmax(0,1fr); gap:18px; padding:18px; min-height:calc(100vh - 82px); }
.jobs-panel, .schedule-panel { background:var(--panel); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); }
.jobs-panel { padding:16px; overflow:hidden; }
.panel-heading, .schedule-head, .dialog-head, .dialog-foot { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.panel-heading h2, .schedule-head h2, .dialog-head h2 { margin:0; }
.panel-heading p { margin:4px 0 0; color:var(--muted); font-size:12px; }
.icon-btn { width:38px; height:38px; border:0; border-radius:10px; background:var(--red); color:#fff; font-size:24px; line-height:1; }
.search { width:100%; margin:14px 0 10px; border:1px solid var(--line); border-radius:10px; padding:11px 12px; background:#fbfcfd; }
.filters { display:flex; gap:6px; overflow:auto; padding-bottom:8px; }
.filter, .secondary { border:1px solid var(--line); background:#fff; color:var(--ink); padding:8px 10px; border-radius:8px; font-size:12px; white-space:nowrap; }
.filter.active { background:var(--ink); color:#fff; border-color:var(--ink); }
.jobs-list { display:flex; flex-direction:column; gap:8px; max-height:calc(100vh - 275px); overflow:auto; padding:2px 2px 8px; }
.job-card { border:1px solid var(--line); border-left:4px solid var(--red); border-radius:10px; padding:10px; background:#fff; transition:.15s ease; }
.job-card[draggable="true"] { cursor:grab; }
.job-card:hover { transform:translateY(-1px); box-shadow:0 5px 16px rgba(25,30,35,.08); }
.job-card.dragging { opacity:.45; }
.job-title { font-weight:750; font-size:13px; line-height:1.25; }
.job-meta { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:7px; }
.badge { display:inline-flex; align-items:center; padding:4px 7px; border-radius:999px; font-size:10px; font-weight:700; background:#f1f3f5; color:#4c545d; }
.badge.scheduled { background:#e7f3ea; color:#23683a; }
.badge.hold { background:#fff1d8; color:#8a5d08; }
.ready-dot { font-size:10px; color:#8d969f; }
.ready-dot.ok { color:#27783d; }
.schedule-panel { padding:16px; min-width:0; overflow:auto; }
.eyebrow { margin:0 0 4px; text-transform:uppercase; letter-spacing:.09em; color:var(--red); font-size:10px; font-weight:900; }
.schedule-head { margin-bottom:14px; }
.week-controls { display:flex; gap:7px; }
.schedule-grid { display:grid; grid-template-columns: 120px repeat(5, minmax(160px, 1fr)); border:1px solid var(--line); border-radius:12px; overflow:hidden; min-width:980px; }
.grid-cell { min-height:150px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); background:#fff; padding:8px; }
.grid-cell:nth-child(6n) { border-right:0; }
.grid-cell.header { min-height:auto; background:#f5f6f7; font-weight:800; padding:10px; text-align:center; }
.grid-cell.crew { background:#f9fafb; font-weight:800; display:flex; align-items:flex-start; justify-content:center; padding-top:14px; }
.grid-cell.dropzone { transition:.12s ease; }
.grid-cell.dropzone.dragover { background:#fff0f1; outline:2px dashed var(--red); outline-offset:-5px; }
.visit { border:1px solid #d9dee3; border-radius:9px; padding:8px; margin-bottom:7px; background:#fbfcfd; border-left:4px solid var(--red); cursor:pointer; }
.visit .name { font-size:12px; font-weight:800; line-height:1.25; }
.visit .task { margin-top:4px; color:var(--muted); font-size:10px; }
.hint { color:var(--muted); font-size:11px; margin:12px 2px 0; }
.job-dialog, .event-dialog { width:min(720px, calc(100vw - 28px)); border:0; border-radius:14px; padding:0; box-shadow:0 24px 80px rgba(0,0,0,.3); }
.event-dialog { width:min(520px, calc(100vw - 28px)); }
dialog::backdrop { background:rgba(8,12,16,.55); }
.job-dialog form, .event-dialog form { padding:18px; }
.close-btn { border:0; background:#eef1f3; width:34px; height:34px; border-radius:50%; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:16px; }
.form-grid label, .event-dialog label { display:flex; flex-direction:column; gap:6px; font-size:11px; font-weight:750; color:#555d65; }
.form-grid input, .form-grid select, .form-grid textarea, .event-dialog select, .event-dialog textarea { width:100%; border:1px solid var(--line); border-radius:9px; padding:10px; background:#fff; color:var(--ink); }
.span2 { grid-column:span 2; }
.checks { display:flex; flex-wrap:wrap; gap:12px; padding:14px 0; }
.checks label { font-size:12px; font-weight:650; }
.primary, .danger { border:0; border-radius:9px; padding:10px 14px; font-weight:800; }
.primary { background:var(--red); color:#fff; }
.primary:hover { background:var(--red-dark); }
.danger { background:#fbeaec; color:#9c1620; }
.readiness { font-size:11px; font-weight:800; }
.readiness.ok { color:#27783d; }
.readiness.warn { color:#9a6400; }
.event-dialog label { margin:14px 0; }
.hidden { display:none !important; }
.readonly .jobs-panel { opacity:.95; }
.readonly .icon-btn, .readonly #jobFilters { display:none; }
.readonly .job-card { cursor:pointer !important; }

@media (max-width: 900px) {
  .topbar { align-items:flex-start; flex-direction:column; }
  .top-actions { width:100%; justify-content:space-between; }
  .staging-pill { display:none; }
  .layout { grid-template-columns:1fr; padding:10px; }
  .jobs-list { max-height:330px; }
  .schedule-panel { padding:12px; }
  .schedule-head { align-items:flex-start; flex-direction:column; }
  .form-grid { grid-template-columns:1fr; }
  .span2 { grid-column:span 1; }
}
.user-menu { display:flex; flex-direction:column; align-items:flex-end; line-height:1.1; }
.user-menu strong { font-size:12px; }
.user-menu span { margin-top:4px; font-size:10px; color:#adb5bd; text-transform:uppercase; letter-spacing:.08em; }
.top-btn { border:1px solid #49515a; background:#24292f; color:#fff; border-radius:8px; padding:8px 10px; font-size:12px; }
.login-page { min-height:100vh; background:linear-gradient(145deg,#16191d,#262c33); }
.login-shell { min-height:100vh; display:grid; place-items:center; padding:20px; }
.login-card { width:min(420px,100%); background:#fff; border-radius:18px; box-shadow:0 28px 90px rgba(0,0,0,.35); padding:28px; border-top:5px solid var(--red); }
.login-brand { display:flex; align-items:center; gap:14px; margin-bottom:24px; }
.login-brand h1 { margin:0; font-size:28px; }
.login-brand p:not(.eyebrow) { margin:3px 0 0; color:var(--muted); font-size:12px; }
.login-form { display:flex; flex-direction:column; gap:14px; }
.login-form label { display:flex; flex-direction:column; gap:7px; font-size:12px; font-weight:800; color:#505860; }
.login-form input { width:100%; border:1px solid var(--line); border-radius:10px; padding:12px; background:#fbfcfd; }
.login-submit { width:100%; margin-top:2px; }
.login-submit:disabled { opacity:.65; cursor:wait; }
.login-error { min-height:18px; margin:0; color:#a4161f; font-size:12px; font-weight:700; }
.login-note { margin:18px 0 0; font-size:10px; color:#8a929a; text-align:center; }
@media (max-width: 900px) { .user-menu { align-items:flex-start; } .top-actions { flex-wrap:wrap; } }


.user-dialog { width:min(760px, calc(100vw - 28px)); border:0; border-radius:14px; padding:0; box-shadow:0 24px 80px rgba(0,0,0,.3); }
.user-dialog form { padding:18px; }
.user-help { margin:10px 0 16px; line-height:1.45; }
.users-list { display:flex; flex-direction:column; gap:10px; margin:12px 0 18px; }
.user-row { display:grid; grid-template-columns:minmax(190px,1.2fr) minmax(190px,1fr) auto auto; gap:10px; align-items:center; border:1px solid var(--line); border-radius:12px; padding:12px; background:#fbfcfd; }
.user-summary { display:flex; flex-direction:column; gap:3px; min-width:0; }
.user-summary strong { font-size:13px; }
.user-summary span { color:var(--muted); font-size:10px; }
.user-summary em { width:max-content; font-style:normal; font-size:10px; font-weight:800; padding:3px 6px; border-radius:999px; }
.user-active { background:#e7f3ea; color:#23683a; }
.user-inactive { background:#f1f3f5; color:#68717a; }
.user-password { width:100%; min-width:0; border:1px solid var(--line); border-radius:9px; padding:10px; background:#fff; }
.user-active-check { display:flex; gap:5px; align-items:center; font-size:11px; font-weight:700; white-space:nowrap; }
.user-save { white-space:nowrap; }
@media (max-width: 700px) {
  .user-row { grid-template-columns:1fr; }
  .user-dialog .dialog-foot { align-items:flex-start; flex-direction:column; }
}

.plan-link-wrap { margin-top:2px; }
.plan-link {
  display:inline-flex; align-items:center; justify-content:center; width:max-content;
  max-width:100%; padding:10px 14px; border-radius:9px; background:var(--ink);
  color:#fff; text-decoration:none; font-size:12px; font-weight:800;
}
.plan-link:hover { background:#30363c; }
.event-dialog .plan-link { margin:2px 0 14px; }
