/* FORMWORX 2.0 — night mode first; light mode available */
:root {
  --bg: #08090A; --ground: #121314; --surface: #1B1C1E; --surface-2: #202224; --line: #2C2E31; --line-2: #3A3C40;
  --text: #ECEAE6; --text-2: #C9CBCE; --muted: #A3A6AA;
  --brand: #C2410C; --brand-hover: #D4520F; --brand-text: #F08A5D; --on-brand: #FFFFFF;
  --good-bg: #1F3B25; --good: #8FD19E; --warn-bg: #3A2E14; --warn: #F2C46D; --bad-bg: #3F1D1D; --bad: #F29A9A; --info-bg: #1C2F44; --info: #9CC3EA;
  --radius: 12px; --shadow: 0 10px 40px rgba(0,0,0,.45);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; --display: 'Archivo', var(--font); --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #EDEBE7; --ground: #F6F5F2; --surface: #FFFFFF; --surface-2: #F3F2EF; --line: #E0DDD8; --line-2: #CFCBC4;
  --text: #1A1A1A; --text-2: #3A3A3A; --muted: #6A6660; --brand-text: #B03A08;
  --good-bg: #E3F4E6; --good: #1E6B32; --warn-bg: #FBF0D6; --warn: #7A5500; --bad-bg: #FBE3E3; --bad: #9B1C1C; --info-bg: #E3EEF9; --info: #1D4F85;
  --shadow: 0 10px 30px rgba(0,0,0,.12); color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ground); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-text); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 700; } h2 { font-size: 18px; font-weight: 700; } h3 { font-size: 15px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ico { display: inline-flex; line-height: 0; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--bg); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 8px; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand b { font-family: var(--display); font-size: 16px; letter-spacing: .02em; display: block; }
.brand small { color: var(--muted); font-size: 11px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group > span { font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--muted); padding: 6px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.nav a.on { background: var(--surface); color: var(--text); box-shadow: inset 3px 0 0 var(--brand); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--brand-text); flex: none; }
.me b { display: block; font-size: 13px; } .me small { color: var(--muted); font-size: 12px; }
.main { min-width: 0; padding: 26px 32px 60px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.banner-logo { width: 100%; max-height: 150px; object-fit: cover; object-position: center; border-radius: var(--radius); border: 1px solid var(--line); display: block; margin-bottom: 18px; background: #000; }

/* ---------- components ---------- */
.btn { height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); } .btn.primary:hover { background: var(--brand-hover); }
.btn.danger { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--surface); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card > h2, .card > h3 { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: var(--mono); }
.stat { display: flex; flex-direction: column; gap: 2px; } .stat b { font-family: var(--display); font-size: 26px; } .stat span { color: var(--muted); font-size: 13px; }
.pill { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); } .pill.brand { background: #3A2215; color: #F5A77A; }
:root[data-theme="light"] .pill.brand { background: #FBE6D8; color: #9A3408; }
.note { border-radius: 10px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.note.good { background: var(--good-bg); color: var(--good); } .note.warn { background: var(--warn-bg); color: var(--warn); } .note.bad { background: var(--bad-bg); color: var(--bad); } .note.info { background: var(--info-bg); color: var(--info); }
.note b { color: inherit; }
.list { display: flex; flex-direction: column; } .list > * { padding: 10px 0; border-top: 1px solid var(--line); } .list > *:first-child { border-top: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; } .kv dt { color: var(--muted); } .kv dd { margin: 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { background: none; border: 0; height: 42px; padding: 0 14px; color: var(--muted); font-weight: 500; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--brand); }
.tab .count { font-size: 12px; color: var(--muted); font-weight: 500; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; }
.chip.on { background: var(--line-2); border-color: var(--muted); }
.chip .n { color: var(--muted); font-weight: 500; margin-left: 4px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; padding: 10px 14px; background: var(--surface-2); color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=time], select, textarea {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--ground); width: 100%; outline: none; }
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-text); }
.form { display: grid; gap: 14px; } .form.two { grid-template-columns: 1fr 1fr; } .form .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; } .check input { width: 18px; height: 18px; accent-color: var(--brand); }
.search { position: relative; width: 320px; max-width: 100%; } .search input { padding-left: 36px; } .search .ico { position: absolute; left: 11px; top: 12px; color: var(--muted); }
.switch { position: relative; width: 44px; height: 26px; flex: none; } .switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: .15s; } .switch span::after { content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--brand); } .switch input:checked + span::after { left: 21px; }
.switch input:disabled + span { opacity: .5; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 0 10px; height: 30px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); border-left: 1px solid var(--line-2); }
.seg button:first-child { border-left: 0; } .seg button.on { background: var(--brand); color: #fff; }
.seg button:disabled { cursor: not-allowed; }

.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; width: 560px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); max-width: 380px; transition: .3s; }
.toast.ok { border-left: 4px solid var(--good); } .toast.bad { border-left: 4px solid var(--bad); } .toast.out { opacity: 0; transform: translateY(8px); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.loading { display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 30px 0; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-2); border-top-color: var(--brand-text); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* schedule board */
.board { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface); }
.board .cell { border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 8px; min-height: 88px; }
.board .hd { background: var(--surface-2); font-weight: 600; min-height: 0; position: sticky; top: 0; }
.board .crew { background: var(--surface-2); font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.board .drop.over { background: var(--info-bg); }
.slot { display: block; border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; background: var(--ground); border-left: 4px solid var(--brand); font-size: 12px; cursor: grab; }
.slot b { display: block; font-size: 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; margin-top: 4px; }
.weather-chip { font-size: 11px; color: var(--muted); font-weight: 500; display: block; }
.weather-chip.risk { color: var(--warn); }

/* access matrix */
.matrix td, .matrix th { padding: 8px 10px; }
.locked { display: inline-flex; gap: 6px; align-items: center; background: var(--good-bg); color: var(--good); padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 12px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }

/* auth screens */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.auth-art { background: #000 center/cover no-repeat; position: relative; display: flex; align-items: flex-end; padding: 40px; }
.auth-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.75)); }
.auth-art p { position: relative; z-index: 1; color: #ddd; max-width: 440px; font-size: 15px; }
.auth-box { display: flex; flex-direction: column; justify-content: center; padding: 40px; max-width: 480px; width: 100%; margin: 0 auto; gap: 18px; }
.auth-box .logo { width: 64px; height: 64px; object-fit: contain; }

.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.steps span { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; }
.steps span.on { background: var(--brand); color: #fff; } .steps span.done { background: var(--good-bg); color: var(--good); }

.photos { display: flex; gap: 8px; flex-wrap: wrap; } .photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--brand); }
pre.code { background: var(--ground); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3, .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .topbar img { width: 32px; height: 32px; object-fit: contain; }
  .main { padding: 18px 16px 60px; }
  .g2, .g4, .form.two { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  h1 { font-size: 24px; }
  .search { width: 100%; }
}
@media print { .side, .topbar, .actions, .btn { display: none !important; } .shell { display: block; } body { background: #fff; color: #000; } }
[hidden] { display: none !important; }
a.btn, a.tab, a.me, a.brand { color: var(--text); text-decoration: none; }
a.btn.primary { color: var(--on-brand); }
a.tab { color: var(--muted); } a.tab.on { color: var(--text); }
a.btn:hover, a.tab:hover, a.me:hover, a.brand:hover { text-decoration: none; }
.shell > div { min-width: 0; }
