:root {
  --bg: #0f172a;
  --bg-soft: #111c33;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --brand: #1f3a5f;
  --brand-light: #2f5c95;
  --accent: #c9a227;
  --success: #047857;
  --success-soft: #ecfdf5;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--brand-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header --- */
.topbar {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 62px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: .3px;
}
.brand:hover { text-decoration: none; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav a {
  color: rgba(255,255,255,.82);
  padding: 8px 13px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; }
.nav .user { color: rgba(255,255,255,.6); font-size: 13px; padding-left: 10px; }

/* --- Layout --- */
.container { max-width: 1200px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 23px; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* --- Stats --- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.stat .value { font-size: 27px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat .hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat.ok .value { color: var(--success); }
.stat.warn .value { color: var(--warn); }
.stat.brand .value { color: var(--brand); }

/* --- Forms --- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: #334155; }
.field .help { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
.input, input[type=text], input[type=number], input[type=date], input[type=time],
input[type=month], input[type=password], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(47, 92, 149, .14);
}
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row label { font-size: 14px; font-weight: 500; }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); }
.radio-row { display: flex; gap: 16px; }
.radio-row ul { list-style: none; display: flex; gap: 16px; margin: 0; padding: 0; }
.radio-row label { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.form-footer { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  background: var(--brand); color: #fff; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.btn.secondary:hover { background: var(--surface-alt); color: #334155; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-alt); color: var(--text); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn.block { width: 100%; justify-content: center; }

/* --- Table --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th {
  background: var(--surface-alt); font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); font-weight: 700;
}
table.data tbody tr:hover { background: #f8fafc; }
table.data tfoot td { font-weight: 700; background: var(--surface-alt); border-top: 2px solid var(--border); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .name { font-weight: 600; }
table.data .muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.row-overtime { background: #fffdf5; }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: #eff6ff; color: #1d4ed8; }
.badge.off { background: #f1f5f9; color: var(--muted); }
.badge.night { background: #eef2ff; color: #4338ca; }

/* --- Progress --- */
.bar { height: 7px; background: #e2e8f0; border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar span { display: block; height: 100%; background: var(--brand-light); border-radius: 99px; }
.bar span.over { background: var(--accent); }

/* --- Messages --- */
.messages { margin-bottom: 18px; display: grid; gap: 10px; }
.msg { padding: 11px 15px; border-radius: 9px; font-size: 14px; font-weight: 500; border: 1px solid; }
.msg.success { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.msg.error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.msg.warning { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.msg.info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; }

/* --- Login --- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0f172a 0%, #1f3a5f 100%); padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 34px; width: 100%; max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 21px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 15px; }

/* --- Print --- */
.print-only { display: none; }
@media print {
  .topbar, .actions, .no-print, .filter-card { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .container { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; margin: 0; }
  .print-only { display: block; }
  table.data th, table.data td { padding: 6px 8px; font-size: 11.5px; }
  table.data th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .row-overtime { background: #fff9e6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 720px) {
  .topbar-inner { min-height: auto; padding: 12px 16px; }
  .nav { margin-left: 0; width: 100%; }
  table.data th, table.data td { padding: 9px 10px; }
}
