:root {
  --bg: #f5f7f8; --card: #fff; --ink: #14202b; --muted: #5d6b78; --line: #e2e8ee;
  --brand: #0f766e; --brand-ink: #fff; --brand-soft: #e3f4f1;
  --warn: #b45309; --warn-soft: #fef3e2; --bad: #b42318; --bad-soft: #fde8e7;
  --ok: #157f3b; --ok-soft: #e4f6ea; --info: #1d4ed8; --info-soft: #e6edfd;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft); }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { padding: 7px 11px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; position: relative; }
nav a:hover { background: var(--bg); color: var(--ink); }
nav a.active { background: var(--brand-soft); color: var(--brand); }
nav .spacer { flex: 1; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.menu-btn { display: none; margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 14px 16px; }
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }

button, .btn { font: inherit; font-weight: 600; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #c9d3dc; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.primary:hover { background: #0b5f59; border-color: #0b5f59; }
.danger { color: var(--bad); }
.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.ghost { background: none; border-color: transparent; color: var(--muted); }
.sm { padding: 5px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { justify-content: space-between; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #cfd8e0; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.inline-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields .field { margin: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.neutral { background: #eef1f4; color: var(--muted); }
.pos { color: var(--warn); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }

/* clock page */
.clock-card { text-align: center; padding: 28px 18px; }
.clock-state { font-size: 14px; font-weight: 600; }
.big-time { font-size: 56px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; margin: 6px 0; }
.clock-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.clock-actions button { padding: 16px 26px; font-size: 17px; border-radius: 12px; min-width: 170px; justify-content: center; }
.break-box { margin: 16px auto 0; max-width: 420px; padding: 14px; border-radius: 12px; background: var(--info-soft); }
.break-box.over { background: var(--bad-soft); }
.break-time { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: rgba(0,0,0,.08); overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; background: var(--info); transition: width .5s; }
.over .bar > div { background: var(--bad); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 10px; }
.timeline li:last-child { border: 0; }

/* approvals */
.appr { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; }
.appr + .appr { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.appr .facts { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0; font-size: 14px; }
.appr .facts b { font-variant-numeric: tabular-nums; }
.appr .actions { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.note { background: #f7f9fb; border-left: 3px solid var(--line); padding: 6px 10px; border-radius: 4px; font-size: 13px; margin-top: 6px; }
.empty { text-align: center; padding: 36px; color: var(--muted); }
.empty .big { font-size: 34px; }

/* auth */
.auth { max-width: 380px; margin: 8vh auto; }
.auth .brand { justify-content: center; font-size: 20px; margin-bottom: 18px; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(680px, 94vw); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15, 23, 32, .45); }
#modalBody { padding: 20px; max-height: 86vh; overflow: auto; }
.entry-edit { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.break-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; flex-wrap: wrap; }
.break-row .field { margin: 0; flex: 1; min-width: 140px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #14202b; color: #fff; padding: 10px 16px; border-radius: 10px; transition: .2s; pointer-events: none; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); }

@media (max-width: 860px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .menu-btn { display: block; }
  nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; flex-direction: column;
    padding: 8px; border-bottom: 1px solid var(--line); }
  nav.open { display: flex; }
  .appr { grid-template-columns: 24px 1fr; }
  .appr .actions { grid-column: 2; flex-direction: row; flex-wrap: wrap; min-width: 0; }
}
@media (max-width: 560px) {
  main { padding: 16px 12px 64px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .big-time { font-size: 44px; }
  .clock-actions button { min-width: 0; flex: 1; }
  th, td { padding: 8px 6px; }
}
@media print { .topbar, button { display: none !important; } }
