:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #66706b;
  --line: #dfe4e0;
  --surface: #ffffff;
  --soft: #f4f6f4;
  --canvas: #edf0ed;
  --forest: #173c2c;
  --forest-2: #246044;
  --mint: #dceee3;
  --orange: #e96733;
  --orange-soft: #fff0e8;
  --blue: #28678d;
  --blue-soft: #e7f1f7;
  --red: #a83c35;
  --red-soft: #fbeceb;
  --yellow: #79570a;
  --yellow-soft: #fff5d7;
  --shadow: 0 12px 34px rgba(24, 32, 29, .08);
  --sidebar: 224px;
  --topbar: 72px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(40, 103, 141, .24);
  outline-offset: 2px;
}

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(360px, .95fr);
  background: var(--surface);
}

.login-intro {
  min-height: 100vh;
  padding: clamp(32px, 6vw, 84px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--forest);
  color: white;
}

.login-mark, .brand-mark {
  font-size: 25px;
  line-height: 1;
  font-weight: 800;
}
.login-mark small {
  display: block;
  margin-top: 9px;
  color: #aebfb5;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-copy { max-width: 700px; }
.login-copy h1 {
  max-width: 760px;
  margin: 0 0 24px;
  font-size: 72px;
  line-height: 1.02;
  letter-spacing: 0;
}
.login-copy p {
  max-width: 620px;
  margin: 0;
  font-size: 22px;
  line-height: 1.45;
  color: #cddbd3;
}

.login-proof {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-top: 1px solid rgba(255,255,255,.18);
}
.login-proof div { padding: 20px 14px 0 0; }
.login-proof strong { display: block; font-size: 22px; }
.login-proof span { color: #aebfb5; font-size: 13px; }

.login-panel {
  align-self: center;
  width: min(540px, 100%);
  padding: clamp(28px, 6vw, 72px);
  justify-self: center;
}
.login-panel h2 { margin: 0 0 8px; font-size: 28px; }
.login-panel > p { margin: 0 0 28px; color: var(--muted); line-height: 1.5; }
.role-list { display: grid; gap: 10px; }
.role-entry {
  width: 100%; min-height: 66px; padding: 12px 15px;
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); text-align: left;
}
.role-entry:hover { border-color: var(--forest-2); background: var(--soft); }
.role-code {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 50%; background: var(--mint); color: var(--forest); font-weight: 800;
}
.role-entry strong, .role-entry small { display: block; }
.role-entry small { margin-top: 3px; color: var(--muted); }
.role-entry b { color: var(--orange); font-size: 20px; }

.register-box { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.register-box summary { cursor: pointer; font-weight: 700; }
.register-form { display: grid; gap: 10px; margin-top: 16px; }
.register-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: grid; gap: 6px; }
.field span { font-size: 12px; font-weight: 700; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 5px;
  padding: 9px 11px; color: var(--ink); background: white;
}
textarea { min-height: 86px; resize: vertical; }

.primary, .secondary, .danger, .ghost, .compact-button {
  min-height: 40px; border-radius: 5px; padding: 8px 13px; border: 1px solid transparent; font-weight: 700;
}
.primary { background: var(--forest-2); color: white; }
.primary:hover { background: var(--forest); }
.secondary { background: white; border-color: var(--line); color: var(--ink); }
.secondary:hover { border-color: #9aa69f; }
.danger { background: var(--red-soft); color: var(--red); border-color: #efc7c3; }
.ghost { background: transparent; color: var(--muted); padding-left: 6px; padding-right: 6px; }
.compact-button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar);
  display: flex; flex-direction: column; padding: 26px 18px 18px;
  background: var(--forest); color: white;
}
.brand-lockup { padding: 0 8px 26px; }
.brand-lockup small { display: block; margin-top: 7px; color: #aebfb5; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; }
.nav-button {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; border: 0; border-radius: 5px; background: transparent; color: #cad7d0; text-align: left;
}
.nav-button:hover { background: rgba(255,255,255,.08); color: white; }
.nav-button.active { background: white; color: var(--forest); font-weight: 800; }
.nav-symbol { width: 20px; font-size: 16px; text-align: center; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); padding: 16px 8px 0; }
.sidebar-bottom strong { display: block; font-size: 13px; }
.sidebar-bottom span { display: block; margin-top: 4px; color: #aebfb5; font-size: 12px; }

.main-shell { grid-column: 2; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 15; min-height: var(--topbar); padding: 13px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px);
}
.page-title h1 { margin: 0; font-size: 22px; line-height: 1.15; }
.page-title p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.mode-badge {
  padding: 6px 9px; border-radius: 4px; color: var(--forest); background: var(--mint); font-size: 11px; font-weight: 800;
}
.role-switch { width: 180px; min-height: 38px; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: 24px 28px 46px; }

.metrics {
  display: grid; grid-template-columns: repeat(7, minmax(105px, 1fr));
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden;
}
.metric { min-height: 92px; padding: 16px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; min-height: 30px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.metric strong { display: block; margin-top: 5px; font-size: 25px; line-height: 1; }
.metric.money strong { color: var(--forest-2); }

.section { margin-top: 24px; }
.section-head { min-height: 36px; display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head p { margin: 0; color: var(--muted); font-size: 12px; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 18px; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); overflow: hidden; }
.panel-body { padding: 17px; }
.panel-title { margin: 0 0 4px; font-size: 15px; }
.panel-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.attention-list { display: grid; }
.attention-item {
  min-height: 66px; display: grid; grid-template-columns: 5px 1fr auto; gap: 13px; align-items: center;
  padding: 10px 14px 10px 0; border-bottom: 1px solid var(--line); background: white; text-align: left; border-top: 0; border-left: 0; border-right: 0;
}
.attention-item:last-child { border-bottom: 0; }
.attention-item:hover { background: var(--soft); }
.attention-bar { align-self: stretch; background: var(--orange); }
.attention-item.review .attention-bar { background: var(--blue); }
.attention-item.money .attention-bar { background: var(--forest-2); }
.attention-item strong, .attention-item small { display: block; }
.attention-item small { margin-top: 4px; color: var(--muted); }
.attention-item b { color: var(--muted); font-size: 18px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: white; font-size: 13px; }
.data-table th {
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--soft);
  text-align: left; font-size: 11px; font-weight: 800; white-space: nowrap;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafbfa; }
.data-table .row-button { cursor: pointer; }
.cell-main { font-weight: 750; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.number { font-variant-numeric: tabular-nums; white-space: nowrap; }

.status {
  display: inline-flex; align-items: center; min-height: 24px; padding: 3px 7px; border-radius: 4px;
  background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap;
}
.status.ready, .status.paid, .status.complete, .status.accepted, .status.active, .status.confirmed { background: var(--mint); color: var(--forest-2); }
.status.recruiting, .status.awaiting_worker, .status.submitted, .status.planned { background: var(--yellow-soft); color: var(--yellow); }
.status.in_progress, .status.proof_review, .status.approved { background: var(--blue-soft); color: var(--blue); }
.status.on_hold, .status.rejected, .status.declined, .status.no_show, .status.blocked { background: var(--red-soft); color: var(--red); }

.progress { width: 110px; height: 6px; overflow: hidden; border-radius: 3px; background: var(--line); }
.progress span { display: block; height: 100%; background: var(--forest-2); }

.order-workspace { display: grid; grid-template-columns: minmax(320px, .72fr) minmax(0, 1.28fr); min-height: 620px; }
.order-list { border-right: 1px solid var(--line); background: #fafbfa; }
.order-list-button {
  width: 100%; padding: 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left;
}
.order-list-button:hover, .order-list-button.active { background: white; }
.order-list-button.active { box-shadow: inset 4px 0 var(--orange); }
.order-list-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-list-button strong { font-size: 13px; }
.order-list-button p { margin: 7px 0 8px; font-size: 13px; }
.order-list-button small { color: var(--muted); }
.order-detail { min-width: 0; padding: 20px; }
.order-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.order-detail-head h2 { margin: 0; font-size: 23px; }
.order-detail-head p { margin: 6px 0 0; color: var(--muted); }
.money-split {
  min-width: 240px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 12px; border: 1px solid #c9dfd0; border-radius: 6px; background: #f4fbf6;
}
.money-split div:last-child { text-align: right; }
.money-split span, .money-split strong { display: block; }
.money-split span { color: var(--muted); font-size: 10px; }
.money-split strong { margin-top: 3px; font-size: 17px; }
.money-split b { color: var(--orange); }
.facts-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.fact { min-height: 74px; padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact span, .fact strong { display: block; }
.fact span { color: var(--muted); font-size: 11px; }
.fact strong { margin-top: 5px; font-size: 13px; line-height: 1.35; }
.crew-board { margin-top: 20px; }
.crew-row { display: grid; grid-template-columns: minmax(130px, 1fr) 110px minmax(120px, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.crew-row:last-child { border-bottom: 0; }
.crew-row small { color: var(--muted); }

.worker-grid { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 12px; }
.worker-card { border: 1px solid var(--line); border-radius: 6px; padding: 14px; background: white; }
.worker-card-head { display: flex; justify-content: space-between; gap: 8px; }
.worker-card h3 { margin: 0; font-size: 15px; }
.worker-card p { margin: 6px 0 12px; color: var(--muted); font-size: 12px; }
.role-tags { min-height: 27px; display: flex; flex-wrap: wrap; gap: 5px; }
.role-tag { padding: 3px 6px; border-radius: 3px; background: var(--soft); color: var(--muted); font-size: 10px; font-weight: 700; }
.gate-line { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 12px; }
.gate { padding: 6px 4px; border-radius: 3px; text-align: center; background: var(--red-soft); color: var(--red); font-size: 10px; font-weight: 750; }
.gate.ok { background: var(--mint); color: var(--forest-2); }
.worker-score { margin-top: 12px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

.filter-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-row input { width: min(340px, 100%); }
.filter-row select { width: auto; min-width: 150px; }

.chat-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr) 310px; min-height: 650px; }
.room-list { border-right: 1px solid var(--line); background: #fafbfa; }
.room-button { width: 100%; padding: 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.room-button:hover, .room-button.active { background: white; }
.room-button.active { box-shadow: inset 4px 0 var(--orange); }
.room-button strong, .room-button small { display: block; }
.room-button small { margin-top: 5px; color: var(--muted); }
.messages { display: flex; flex-direction: column; min-width: 0; }
.message-scroll { flex: 1; min-height: 510px; max-height: 590px; padding: 18px; overflow-y: auto; background: #f6f8f6; }
.message { max-width: 76%; margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.message.worker { margin-left: auto; background: #eef7f1; border-color: #cfe4d6; }
.message.proof { border-left: 4px solid var(--blue); }
.message.system { max-width: 88%; margin-left: auto; margin-right: auto; background: transparent; border-style: dashed; color: var(--muted); }
.message-head { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; }
.message p { margin: 5px 0 0; font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.message-form input { min-width: 0; }
.room-context { border-left: 1px solid var(--line); padding: 16px; }
.context-list { display: grid; gap: 10px; margin-top: 16px; }
.context-item { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.context-item span, .context-item strong { display: block; }
.context-item span { color: var(--muted); font-size: 10px; }
.context-item strong { margin-top: 4px; font-size: 12px; line-height: 1.4; }

.mobile-stack { display: grid; gap: 12px; }
.shift-card, .offer-card, .proof-card {
  border: 1px solid var(--line); border-radius: 6px; background: white; overflow: hidden;
}
.card-main { padding: 16px; }
.card-kicker { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.card-main h3 { margin: 10px 0 5px; font-size: 18px; }
.card-main > p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.offer-money { margin: 15px 0; padding: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; background: var(--mint); border-radius: 5px; }
.offer-money strong { font-size: 22px; color: var(--forest); }
.offer-money span { color: var(--forest-2); font-size: 11px; }
.terms { display: grid; gap: 7px; margin-top: 12px; }
.term { display: grid; grid-template-columns: 92px 1fr; gap: 8px; font-size: 12px; }
.term span { color: var(--muted); }
.card-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--soft); }
.card-actions > * { flex: 1; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; width: 100%; }

.timeline { display: grid; }
.timeline-row { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline-row time { color: var(--muted); font-size: 11px; }
.timeline-row strong { display: block; font-size: 13px; }
.timeline-row small { display: block; margin-top: 4px; color: var(--muted); }

.empty { padding: 34px 18px; color: var(--muted); text-align: center; }
.toast {
  position: fixed; z-index: 100; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px));
  padding: 12px 15px; border-radius: 5px; background: var(--ink); color: white; box-shadow: var(--shadow);
  transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }
.bottom-nav { display: none; }
.mobile-only { display: none; }

@media (max-width: 1160px) {
  :root { --sidebar: 82px; }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .brand-mark { font-size: 17px; }
  .brand-lockup small, .nav-label, .sidebar-bottom { display: none; }
  .nav-button { justify-content: center; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(4) { border-right: 0; }
  .worker-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
  .chat-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .room-context { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar: 64px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 40vh; padding: 28px 22px; gap: 48px; }
  .login-copy h1 { font-size: 42px; }
  .login-copy p { font-size: 17px; }
  .login-proof { margin-top: 20px; }
  .login-proof strong { font-size: 18px; }
  .login-panel { padding: 30px 20px 50px; }
  .register-form .field-row { grid-template-columns: 1fr; }

  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-shell { padding-bottom: 68px; }
  .topbar { padding: 10px 14px; }
  .page-title h1 { font-size: 18px; }
  .page-title p { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mode-badge { display: none; }
  .role-switch { width: 126px; font-size: 12px; }
  .content { padding: 14px 12px 30px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 76px; padding: 12px; }
  .metric:nth-child(2n) { border-right: 0; }
  .metric strong { font-size: 21px; }
  .metric span { min-height: 26px; }
  .two-column, .three-column { grid-template-columns: 1fr; }
  .section { margin-top: 18px; }
  .section-head { align-items: flex-start; }
  .section-head p { text-align: right; }
  .worker-grid { grid-template-columns: 1fr; }
  .order-workspace { display: block; min-height: 0; }
  .order-list { border-right: 0; max-height: 285px; overflow-y: auto; }
  .order-detail { padding: 16px 13px; }
  .order-detail-head { display: grid; }
  .money-split { min-width: 0; width: 100%; }
  .facts-grid { grid-template-columns: 1fr; }
  .crew-row { grid-template-columns: 1fr auto; }
  .crew-row > :nth-child(2), .crew-row > :nth-child(3) { grid-column: 1 / -1; }
  .chat-layout { display: block; min-height: 0; }
  .room-list { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .room-button { min-width: 220px; border-right: 1px solid var(--line); border-bottom: 0; }
  .message-scroll { min-height: 390px; max-height: 50vh; padding: 12px; }
  .message { max-width: 88%; }
  .message-form { grid-template-columns: 1fr auto; padding: 9px; }
  .message-form button { padding-left: 10px; padding-right: 10px; }
  .table-wrap.mobile-cards .data-table, .table-wrap.mobile-cards tbody { display: block; }
  .table-wrap.mobile-cards thead { display: none; }
  .table-wrap.mobile-cards tr { display: grid; grid-template-columns: 1fr 1fr; padding: 12px; border-bottom: 1px solid var(--line); }
  .table-wrap.mobile-cards td { display: block; padding: 4px; border: 0; }
  .table-wrap.mobile-cards td:first-child { grid-column: 1 / -1; }
  .bottom-nav {
    position: fixed; z-index: 30; inset: auto 0 0; height: 62px;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--line); background: rgba(255,255,255,.97);
  }
  .bottom-nav button { min-width: 0; padding: 7px 2px; border: 0; background: transparent; color: var(--muted); font-size: 10px; }
  .bottom-nav button span { display: block; margin-bottom: 3px; font-size: 17px; }
  .bottom-nav button.active { color: var(--forest-2); font-weight: 800; }
  .desktop-only { display: none !important; }
  .mobile-only { display: initial; }
  .timeline-row { grid-template-columns: 92px 1fr; }
  .filter-row input, .filter-row select { width: 100%; }
}

@media (max-width: 390px) {
  .login-copy h1 { font-size: 36px; }
  .login-proof span { font-size: 11px; }
  .topbar { align-items: flex-start; }
  .role-switch { width: 112px; }
  .term { grid-template-columns: 78px 1fr; }
  .card-actions { flex-wrap: wrap; }
  .inline-form { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
