:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --header: #fff;
  --rail: #f7f6f3;
  --card: #fff;
  --input: #fff;
  --hover: #efefed;
  --line: #e9e9e7;
  --text: #37352f;
  --muted: #787774;
  --accent: #2aabee;
  --ok: #0f7b6c;
  --bad: #e03e3e;
  --rate: #c86914;
  --time: #2383e2;
  --shadow: 0 1px 2px rgba(55, 53, 47, .06), 0 10px 28px rgba(55, 53, 47, .06);
  --ghost: #f1f1ef;
  --spin-track: #d3edf8;
  --focus: rgba(42, 171, 238, .22);
  --mark-aug: #9a6700;
  --mark-aug-bg: #fbf3db;
  --mark-sep: #0f7b6c;
  --mark-sep-bg: #edf3ec;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239b9a97' stroke-width='1.6' stroke-linecap='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
.rail {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 0 12px;
  background: var(--rail);
  border-right: 1px solid var(--line);
}
.rail-item {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-decoration: none;
}
.rail-item:hover { background: var(--hover); color: var(--text); }
.rail-item.active {
  background: var(--accent);
  color: #fff;
}
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--header);
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-weight: 500; margin-left: 8px; }
.account { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.account form { margin: 0; }
.icon-btn, .account button {
  height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
  background: var(--card); color: var(--text); font-weight: 600;
}
.icon-btn { width: 32px; padding: 0; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover, .account button:hover { background: var(--hover); }
main { padding: 20px 28px 56px; max-width: 1600px; }
.filters { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.hint { margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.mark-aug, .mark-sep {
  padding: .08em .4em;
  border-radius: 4px;
  font-weight: 650;
  white-space: nowrap;
}
.mark-aug { color: var(--mark-aug); background: var(--mark-aug-bg); }
.mark-sep { color: var(--mark-sep); background: var(--mark-sep-bg); }
td.mark-aug, td.mark-sep { font-weight: 650; }
.kpi.floor-04 { box-shadow: inset 3px 0 0 var(--mark-aug); }
.kpi.floor-04 b { color: var(--mark-aug); }
.kpi.floor-05 { box-shadow: inset 3px 0 0 var(--mark-sep); }
.kpi.floor-05 b { color: var(--mark-sep); }
.kpi.muted { box-shadow: inset 3px 0 0 var(--line); }
.kpi.muted b { color: var(--muted); }
.filters label {
  display: flex; flex-direction: column; gap: 6px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.filters input, .filters select {
  min-width: 280px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--input); color: var(--text);
}
.filters select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  overflow: hidden;
  background-color: var(--input);
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
.filters select::-ms-expand { display: none; }
.filters select option {
  background: var(--card);
  color: var(--text);
}
.filters select:disabled {
  opacity: .7;
}
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus);
}
.worker-field { position: relative; }
#worker-search { min-width: 380px; }
.filters #city { min-width: 200px; }
.worker-menu, .export-menu {
  position: absolute; z-index: 20;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow);
}
.worker-menu {
  top: 100%; left: 0; right: 0; max-height: 320px; overflow: auto; margin-top: 4px;
}
.worker-option, .export-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px 12px; cursor: pointer; color: var(--text);
}
.worker-option:hover, .worker-option.active, .export-menu button:hover { background: var(--hover); }
.worker-option small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.worker-empty { padding: 10px 12px; color: var(--muted); }
.status { color: var(--bad); }
.layout { display: grid; grid-template-columns: 1fr 240px; gap: 16px; align-items: start; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px 8px;
  margin-top: 16px;
}
.table-card { margin-top: 0; padding-bottom: 0; }
h2 { margin: 0 0 12px; font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.table-head h2, .table-head h3 { margin: 0; }
.export { position: relative; }
.export-toggle {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--input); color: var(--muted); cursor: pointer; font-weight: 700; letter-spacing: 1px;
}
.export-toggle:hover { color: var(--text); background: var(--hover); }
.export-menu {
  right: 0; top: calc(100% + 4px); z-index: 15; min-width: 132px; padding: 4px 0;
}
.table-wrap { overflow: auto; max-height: 70vh; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th {
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  position: sticky; top: 0; background: var(--card);
}
tbody tr:hover td { background: var(--hover); }
tbody tr.row-aug td { background: var(--mark-aug-bg); }
tbody tr.row-sep td { background: var(--mark-sep-bg); }
tbody tr.row-aug:hover td { background: #f3e4b8; }
tbody tr.row-sep:hover td { background: #dce9da; }
tbody tr.clickable { cursor: pointer; }
tfoot td { font-weight: 650; border-bottom: 0; position: sticky; bottom: 0; background: var(--card); }
.kpis { display: flex; flex-direction: column; gap: 10px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px 12px 16px;
  box-shadow: inset 3px 0 0 var(--accent);
}
.kpi span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 4px; letter-spacing: .04em; text-transform: uppercase; font-weight: 600; }
.kpi b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.kpi.time { box-shadow: inset 3px 0 0 var(--time); }
.kpi.rate { box-shadow: inset 3px 0 0 var(--rate); }
.kpi.ok { box-shadow: inset 3px 0 0 var(--ok); }
.kpi.bad { box-shadow: inset 3px 0 0 var(--bad); }
.kpi.paid { box-shadow: inset 3px 0 0 var(--time); }
.kpi.time b { color: var(--time); }
.kpi.rate b { color: var(--rate); }
.kpi.ok b { color: var(--ok); }
.kpi.bad b { color: var(--bad); }
.kpi.paid b { color: var(--time); }
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding-bottom: 12px;
}
.metrics .kpi { margin: 0; }
h3 { margin: 8px 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
td.reason { white-space: normal; min-width: 180px; max-width: 280px; }
.progress {
  position: fixed; z-index: 40; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), #7fd4f7, var(--accent));
  background-size: 200% 100%;
  animation: progress-slide 1s linear infinite;
}
@keyframes progress-slide { to { background-position: 200% 0; } }
.loader-label {
  align-self: end; display: inline-flex; align-items: center; gap: 8px;
  height: 36px; color: var(--accent); font-size: 13px; font-weight: 600;
}
.loader-label[hidden] { display: none !important; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--spin-track); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
body.loading main { opacity: .5; pointer-events: none; }
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 20px; font-size: 22px; letter-spacing: -.03em; font-weight: 650; }
.login-card label {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
  font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase;
}
.login-card input, .login-card button { height: 40px; border-radius: 8px; font: inherit; }
.login-card input {
  padding: 0 12px; border: 1px solid var(--line); background: var(--input); color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.login-card button[type="submit"] {
  width: 100%; margin-top: 8px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 650;
}
.login-card button[type="submit"]:hover { filter: brightness(1.05); }
.login-card .error { color: var(--bad); margin: 0 0 14px; font-weight: 650; }
.login-brand { position: fixed; top: 20px; left: 20px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
}
