/* CrewDesk mockup — shared styles */
:root {
  --navy: #0f2a44; --navy-2: #173a5c; --navy-3: #22507d;
  --bg: #f4f6f9; --card: #fff; --text: #1d2733; --muted: #6b7785; --line: #e1e6ec; --line-2: #eef1f5;
  --green: #1f9d55; --green-bg: #e6f6ed; --amber: #b87503; --amber-bg: #fff4dc; --red: #d64545; --red-bg: #fdeaea;
  --grey: #6f7a86; --grey-bg: #eef0f3; --blue: #2563eb; --blue-bg: #e8effd; --yellow-bg: #fff8c5;
  --radius: 8px; --shadow: 0 1px 2px rgba(15, 42, 68, .06), 0 1px 6px rgba(15, 42, 68, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 2px; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.red { color: var(--red); } .amber { color: var(--amber); } .green { color: var(--green); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #c9d6e3; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: #fff; padding: 4px 10px 18px; }
.logo-dark { color: var(--navy); padding: 0 0 4px; font-size: 22px; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--navy-3); color: #fff; font-size: 16px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; color: #c9d6e3; font-weight: 500; }
.nav a:hover { background: var(--navy-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--navy-3); color: #fff; }
.nav a.locked { opacity: .45; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .lock { margin-left: auto; font-size: 11px; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: #8aa0b6; padding: 10px; border-top: 1px solid var(--navy-2); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 1; max-width: 420px; }
.topbar input[type=search] { width: 100%; }
.topbar .spacer { flex: 1; }
.role-pick { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.role-pick select { font-weight: 600; color: var(--navy); border-color: var(--navy-3); }
.icon-btn { position: relative; background: none; border: 1px solid var(--line); border-radius: 6px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }
.icon-btn .count { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; font-size: 10px; border-radius: 10px; padding: 1px 5px; font-weight: 700; }
.dropdown { position: relative; }
.menu { display: none; position: absolute; right: 0; top: 40px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(15, 42, 68, .14); min-width: 320px; z-index: 30; padding: 6px; }
.menu.open { display: block; }
.menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.menu a:hover { background: var(--bg); text-decoration: none; }
.menu .ts { display: block; font-size: 11px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; background: none; border: 0; font: inherit; color: var(--text); }
main { padding: 22px 24px 48px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 6px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5cfdb; text-decoration: none; }
.btn-primary { background: var(--navy-3); border-color: var(--navy-3); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-danger { color: var(--red); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled], .perm-denied { opacity: .45; cursor: not-allowed; pointer-events: auto; }
input, select, textarea { font: inherit; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid #bcd3f5; border-color: var(--blue); }
input[disabled], select[disabled] { background: var(--bg); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.hint { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--grey-bg); color: var(--grey); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-navy { background: #e3ebf4; color: var(--navy-3); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--amber-bg); color: var(--amber); margin: 2px 4px 2px 0; }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.grey { background: var(--grey-bg); color: var(--grey); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: middle; }
.dot.amber { background: var(--amber); } .dot.red { background: var(--red); }

/* Tables */
.table-wrap { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: #f7f9fb; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: #fbfcfd; }
.table tbody tr:hover td { background: #f2f6fb; }
.table tr.row-missing td { background: var(--red-bg) !important; }
.table tr.row-warn td { background: #fffaf0; }
.table td.empty { text-align: center; color: var(--muted); padding: 28px; }
.table input[type=number] { width: 90px; padding: 3px 6px; text-align: right; }
.table-tall { max-height: 640px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { min-width: 140px; }
.filters input[type=search], .filters input[type=text] { min-width: 180px; }
.result-count { font-size: 13px; color: var(--muted); margin: 10px 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); box-shadow: var(--shadow); border-top: 3px solid var(--navy-3); }
.kpi:hover { text-decoration: none; border-color: #c5cfdb; }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi.green { border-top-color: var(--green); } .kpi.blue { border-top-color: var(--blue); } .kpi.amber { border-top-color: var(--amber); } .kpi.grey { border-top-color: var(--grey); }

/* Alerts */
.alert-list { display: flex; flex-direction: column; }
.alert-list details { border-bottom: 1px solid var(--line-2); }
.alert-list summary { display: flex; align-items: center; gap: 12px; padding: 9px 4px; cursor: pointer; list-style: none; }
.alert-list summary::-webkit-details-marker { display: none; }
.alert-list .n { min-width: 34px; height: 28px; display: grid; place-items: center; border-radius: 6px; font-weight: 700; background: var(--amber-bg); color: var(--amber); }
.alert-list .n.red { background: var(--red-bg); color: var(--red); }
.alert-list .n.zero { background: var(--grey-bg); color: var(--grey); }
.alert-list ul { margin: 0 0 10px 50px; padding: 0; list-style: none; font-size: 13px; }
.alert-list li { padding: 3px 0; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; font-size: 12px; }
.bar-track { background: var(--line-2); border-radius: 4px; height: 14px; overflow: hidden; display: flex; }
.bar-fill { background: var(--navy-3); height: 100%; }
.bar-fill.missing { background: var(--red); }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--navy-3); border-bottom-color: var(--navy-3); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Profiles */
.profile-head { display: flex; align-items: center; gap: 16px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #dbe6f2; color: var(--navy-3); display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; margin: 14px 0 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }
.dl input, .dl select { width: 100%; max-width: 320px; }
.note { background: var(--blue-bg); color: #1e3a8a; border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-top: 10px; }
.note.amber { background: var(--amber-bg); color: #7a4d02; }
.note.red { background: var(--red-bg); color: #8f2424; }
.locked { background: var(--green-bg); color: #14532d; border: 1px solid #b5e3c7; border-radius: var(--radius); padding: 10px 14px; font-weight: 600; }
.panel-msg { text-align: center; padding: 60px 20px; }
.panel-msg .big { font-size: 40px; }

/* Payroll */
.stepper { display: flex; gap: 0; counter-reset: step; overflow-x: auto; }
.stepper button { flex: 1; min-width: 120px; background: none; border: 0; border-top: 3px solid var(--line); padding: 10px 6px 4px; text-align: left; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; }
.stepper button b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stepper button.done { border-top-color: var(--green); color: var(--text); }
.stepper button.current { border-top-color: var(--navy-3); color: var(--navy-3); font-weight: 600; }
.cell-edited { background: var(--yellow-bg) !important; }
.cell-edited input { background: var(--yellow-bg); }
.cell-source { border-bottom: 1px dotted #9aa7b5; cursor: help; }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.total-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.total-card .v { font-size: 22px; font-weight: 700; }

/* Gantt */
.gantt { border: 1px solid var(--line); border-radius: 6px; overflow: auto; background: #fff; }
.g-row { display: grid; grid-template-columns: 250px 1fr; min-width: 980px; border-bottom: 1px solid var(--line-2); }
.g-label { padding: 6px 10px; font-size: 12px; border-right: 1px solid var(--line); background: #fff; position: sticky; left: 0; z-index: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-label .rk { color: var(--muted); display: inline-block; min-width: 92px; }
.g-track { position: relative; height: 34px; }
.g-head { position: sticky; top: 0; z-index: 3; background: #f7f9fb; }
.g-head .g-track { height: 28px; }
.g-month { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); font-size: 11px; color: var(--muted); padding: 6px 6px; font-weight: 600; }
.g-group { background: #f2f5f9; }
.g-group .g-label { background: #f2f5f9; font-weight: 700; font-size: 13px; }
.g-grid { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--line-2); }
.g-today { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--red); z-index: 1; }
.g-head .g-today::after { content: "Today"; position: absolute; top: 6px; left: 4px; font-size: 10px; color: var(--red); font-weight: 700; }
.g-bar { position: absolute; top: 6px; height: 22px; border-radius: 4px; font-size: 11px; color: #fff; padding: 3px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.g-bar:hover { text-decoration: none; filter: brightness(1.08); outline: 2px solid rgba(15, 42, 68, .25); }
.g-onboard { background: var(--green); }
.g-planned { background: #e6a417; color: #3d2a00; }
.g-missing { background: repeating-linear-gradient(45deg, var(--red-bg), var(--red-bg) 6px, #fbd5d5 6px, #fbd5d5 12px); border: 1px dashed var(--red); color: var(--red); font-weight: 600; }
.g-norepl { background: repeating-linear-gradient(45deg, #fff, #fff 5px, var(--red-bg) 5px, var(--red-bg) 10px); border: 1px dashed var(--red); color: var(--red); font-weight: 600; }
.g-bar .warn { background: #fff; color: var(--red); border-radius: 3px; padding: 0 3px; margin-right: 4px; font-weight: 700; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 22px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.side-list { max-height: 720px; overflow: auto; }
.side-list h4 { margin: 12px 0 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.side-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .wide { grid-column: span 2; }
.validation { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-3) 100%); }
.login-card { width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-card p { margin: 0; }

/* Toast */
.toast-box { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-size: 13px; max-width: 360px; }

/* Matrix */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .grp { border-left: 2px solid var(--line); }
.matrix .yes { color: var(--green); font-weight: 700; }
.matrix .no { color: #c3cad3; }
.matrix .na { background: #f5f6f8 !important; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 64px 1fr; }
  .nav a span.t, .logo .t, .sidebar-foot, .nav .lock { display: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media print {
  .sidebar, .topbar, .filters, .btn, .no-print, .tabs, .stepper { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tab-panel { display: block !important; }
  .table-wrap { overflow: visible; border: 0; max-height: none; }
}
.bar-track { gap: 2px; background: none; }
.bar-track .bar-rest { background: var(--line-2); flex: 1; border-radius: 4px; }
.bar-fill { border-radius: 4px; min-width: 2px; }
.bar-row .v { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.g-head .g-today::after { top: 15px; background: #f7f9fb; padding: 0 2px; }
.g-todo { background: #fff; border: 1px dashed #9aa7b5; color: var(--muted); }
