:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --line: #1e2a44;
  --text: #e8eefc;
  --muted: #93a0bc;
  --accent: #3b82f6;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: #93c5fd; text-decoration: none; }
.layout { display: flex; min-height: 100%; }
.sidebar { width: 250px; background: #0e1626; border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; }
.brand { font-weight: 800; letter-spacing: .12em; font-size: 13px; }
.tag { color: var(--muted); font-size: 11px; margin: 4px 0 18px; }
.nav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: #c9d4ea; font-size: 13px; margin-bottom: 4px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: #162033; color: #fff; }
.nav a.active {
  background: #162033; color: #fff; border-left-color: #64748b; font-weight: 650;
}
.main { flex: 1; padding: 28px; overflow: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.grid { display: grid; gap: 12px; }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.stat { cursor: pointer; }
.stat h3 { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.stat p { margin: 8px 0 0; font-size: 26px; font-weight: 800; }
input, select, button, textarea { font: inherit; }
input, select, textarea { width: 100%; background: #0b1220; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
label { display: block; font-size: 11px; color: var(--muted); margin: 8px 0 4px; font-weight: 700; }
button, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; font-weight: 700; font-size: 12px; display: inline-block; }
.btn-ghost { background: #1e293b; }
.btn-bad { background: #b91c1c; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.row input, .row select { width: auto; min-width: 160px; flex: 1; }
.row button { width: auto; flex: 0 0 auto; }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 6px 0; }
.report-actions { justify-content: flex-start; }
.dropdown { position: relative; margin-left: auto; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: #0b1220; border: 1px solid var(--line); border-radius: 10px; padding: 10px; z-index: 20; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.dropdown-menu label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 5px 4px; font-size: 13px; color: var(--text); font-weight: 500; }
.dropdown-menu input { width: auto; min-width: 0; flex: 0 0 auto; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.online { background: var(--ok); }
.offline { background: var(--bad); }
.msg { background: #152036; border: 1px solid #2a3a58; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; font-size: 12px; }
h1 { margin: 0 0 16px; font-size: 22px; }
.login-page { min-height: 100%; background:
  radial-gradient(ellipse 80% 50% at 50% -10%, #1a2744 0%, transparent 55%),
  var(--bg);
}
.login-wrap {
  min-height: 100%; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.login-card {
  width: min(400px, 100%);
  padding: 22px 20px 20px;
}
.login-logo { text-align: center; margin-bottom: 14px; }
.login-logo img { max-height: 72px; max-width: min(220px, 70vw); object-fit: contain; }
.login-title { text-align: center; font-weight: 800; letter-spacing: .14em; font-size: 18px; margin-bottom: 4px; }
.login-sub { text-align: center; margin: 0 0 12px; }
.login-submit { width: 100%; margin-top: 14px; padding: 12px; font-size: 14px; }
.dash-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.dash-head h1 { margin: 0; }
.dash-sub { margin: 4px 0 0; }
.dash-filters { margin: 0; }
.dash-stats { margin-top: 4px; }
.stat-tile {
  display: flex; flex-direction: column; justify-content: space-between;
  gap: 10px; min-height: 88px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 14px 12px;
  color: inherit; text-decoration: none;
  border-top: 3px solid var(--line);
  transition: border-color .15s ease, background .15s ease;
}
.stat-tile:hover { background: #152036; }
.stat-tile.present { border-top-color: #34d399; }
.stat-tile.late { border-top-color: #fbbf24; }
.stat-tile.missing { border-top-color: #fb923c; }
.stat-tile.absent { border-top-color: #f87171; }
.stat-tile.sick { border-top-color: #60a5fa; }
.stat-tile.annual { border-top-color: #a78bfa; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: .02em; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.stat-tile.present .stat-value { color: #34d399; }
.stat-tile.late .stat-value { color: #fbbf24; }
.stat-tile.missing .stat-value { color: #fb923c; }
.stat-tile.absent .stat-value { color: #f87171; }
.stat-tile.sick .stat-value { color: #60a5fa; }
.stat-tile.annual .stat-value { color: #a78bfa; }
.dash-note { font-size: 12px; margin-top: 16px; }
.card.row { overflow: visible; }
.suggest { position: relative; min-width: 220px; flex: 1; }
.suggest-list { position: absolute; left: 0; right: 0; top: 100%; background: #0b1220; border: 1px solid var(--line); min-width: 260px; max-height: 320px; overflow: auto; z-index: 400; box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.suggest-list:empty { display: none; }
.suggest-list div { padding: 8px; cursor: pointer; }
.suggest-list div:hover { background: #1e293b; }
img.face { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.crop-stage { position: relative; display: inline-block; max-width: 100%; user-select: none; }
.crop-stage img { max-width: 420px; max-height: 320px; display: block; border: 1px solid var(--line); cursor: crosshair; }
.crop-box { position: absolute; border: 2px solid #3b82f6; background: rgba(59,130,246,.2); display: none; cursor: move; box-sizing: border-box; }
.crop-h { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid #3b82f6; }
.crop-h.nw { left: -7px; top: -7px; cursor: nwse-resize; }
.crop-h.ne { right: -7px; top: -7px; cursor: nesw-resize; }
.crop-h.sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.crop-h.se { right: -7px; bottom: -7px; cursor: nwse-resize; }
.logo-sm { max-height: 36px; max-width: 110px; object-fit: contain; background: #fff; padding: 3px; border-radius: 6px; }
.co-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.co-toolbar h1 { margin: 0; }
.co-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel); }
.co-head, .site-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.site-row { padding: 8px 0 0 12px; border-top: 1px solid var(--line); margin-top: 8px; }
.co-title { flex: 1; font-weight: 650; }
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 14px; }
.person-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px 12px; text-align: center; color: inherit; }
.person-card:hover { border-color: var(--accent); }
.avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; margin: 0 auto 8px; background: #1e293b; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person-card-name { font-weight: 700; font-size: 13px; }
.shift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.shift-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; min-width: 0; }
.shift-card.is-editing { grid-column: 1 / -1; }
.shift-edit { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-top: 10px; }
.shift-edit button { width: auto; justify-self: start; align-self: end; }
.muted { color: var(--muted); font-weight: 500; font-size: 12px; }
.co-edit { margin-top: 10px; }
.crop-wrap { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin: 8px 0; }
.stock-list { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 8px 0; }
.stock-row { display: block; padding: 6px; font-size: 13px; }
.letter-paper { background: #f8fafc; color: #0f172a; }
.letter-paper .footer-note { font-size: 12px; color: #334155; border-top: 1px solid #cbd5e1; padding-top: 10px; }
.pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding: 8px 0; }
.pager-meta { color: var(--muted); font-size: 12px; margin-right: 8px; }
.pager-jump { display: flex; align-items: center; gap: 8px; margin: 0; }
.pager-jump label { margin: 0; }
.pager-jump select { width: 110px; min-width: 110px; flex: none; }
.nav-toggle, .nav-close { display: none; }
.nav-backdrop { display: none; }
.brand-row { display: block; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #93a0bc; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media print { .sidebar, .row button, .btn, form.row, .nav-toggle { display: none !important; } .letter-paper { border: 0; } }
@media (max-width: 1100px) {
  .grid-6, .grid-5, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .layout { display: block; min-height: 100%; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 12px; left: 12px; z-index: 60;
    width: 42px; height: 42px; border-radius: 10px;
    background: #1e293b; color: #fff; border: 1px solid var(--line); font-size: 20px; font-weight: 700;
    box-shadow: 0 8px 20px rgba(0,0,0,.35);
  }
  .dash-head { align-items: stretch; }
  .dash-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-tile { min-height: 76px; padding: 12px; }
  .stat-value { font-size: 24px; }
  .login-card { width: 100%; max-width: 400px; }
  .nav-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px; border: 0;
    background: #1e293b; color: #fff; font-size: 16px;
  }
  .brand-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(280px, 86vw); z-index: 70;
    transform: translateX(-105%); transition: transform .2s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,.45); padding-top: 16px;
  }
  .layout.nav-open .sidebar { transform: translateX(0); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(2, 6, 23, .55);
  }
  .nav-backdrop[hidden] { display: none !important; }
  .main { padding: 64px 14px 24px; width: 100%; }
  .grid-6, .grid-5, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .dash-stats.grid-6 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 18px; }
  .row { flex-direction: column; align-items: stretch; }
  .row input, .row select, .row button, .row .btn { width: 100%; min-width: 0; }
  .suggest { min-width: 0; width: 100%; }
  .table { font-size: 12px; min-width: 560px; }
  .table th, .table td { padding: 8px 6px; white-space: nowrap; }
  .dropdown { margin-left: 0; width: 100%; }
  .dropdown-menu { left: 0; right: 0; min-width: 0; }
  .co-toolbar { flex-direction: column; align-items: stretch; }
  .person-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .stat p { font-size: 22px; }
  .card .row { overflow: visible; }
  table.table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width: 520px) {
  .main { padding: 58px 10px 20px; }
  button, .btn { padding: 10px 12px; font-size: 13px; }
  .person-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
}
