:root {
  --blue: #37446E; --blue-dark: #2A3557; --red: #C0392B; --red-dark: #A93226;
  --bg: #fff; --soft: #F6F7FA; --line: #E3E6EE; --text: #1F2433; --muted: #6B7280;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { display: flex; min-height: 100vh; }
button, input, select { font: inherit; }
.muted { color: var(--muted); }
.pad { padding: 24px; }

/* Sidebar */
#side { width: 200px; flex: none; background: var(--blue); color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 18px; padding: 18px 20px; letter-spacing: .2px; }
#nav { display: flex; flex-direction: column; }
#nav a { color: #DDE2F0; text-decoration: none; padding: 10px 20px; border-left: 3px solid transparent; }
#nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
#nav a.on { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; }
.admin-only { display: none !important; }
body.admin .admin-only { display: block !important; }
#who { margin-top: auto; padding: 14px 20px; font-size: 12px; color: #C9D0E4; }

main { flex: 1; min-width: 0; padding: 24px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 24px 0 8px; }

/* Timer bar */
.bar { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; background: #fff; position: sticky; top: 0; z-index: 5; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.bar input[type=text] { flex: 1; min-width: 0; border: 0; outline: 0; padding: 8px; font-size: 15px; }
.bar select { max-width: 260px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: #fff; }
.clock { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; min-width: 90px; text-align: right; }
.btn { border: 0; border-radius: 6px; padding: 0 18px; height: 40px; cursor: pointer; font-weight: 600; background: var(--soft); color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.blue { background: var(--blue); color: #fff; } .btn.blue:hover:not(:disabled) { background: var(--blue-dark); }
.btn.red { background: var(--red); color: #fff; } .btn.red:hover { background: var(--red-dark); }
.btn.big { height: 44px; min-width: 100px; }
.btn.small { height: 30px; padding: 0 10px; font-weight: 500; }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 0; text-decoration: underline; }

.weektotal { display: flex; justify-content: space-between; margin: 18px 0 6px; color: var(--muted); }
.weektotal b { color: var(--text); }
.manual { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; background: var(--soft);
  border-radius: 8px; margin-top: 10px; }
.manual input, .manual select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; }

/* Day groups */
.day { border: 1px solid var(--line); border-radius: 8px; margin-top: 14px; overflow: hidden; }
.dayhead { display: flex; justify-content: space-between; background: var(--soft); padding: 8px 12px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line); }
.row .desc { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; }
.row .desc:hover, .row .desc:focus { border-color: var(--line); outline: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.proj { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.times input { width: 78px; border: 1px solid transparent; border-radius: 4px; padding: 3px; }
.times input:hover, .times input:focus { border-color: var(--line); outline: 0; }
.dur { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 56px; text-align: right; }
.icon { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 15px; padding: 4px 6px; }
.icon:hover { color: var(--text); }
.running { color: var(--red); font-weight: 600; }

/* Reports */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; position: sticky; top: 0;
  background: #fff; padding: 8px 0; z-index: 5; }
.filters select, .filters input { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; }
.total { font-size: 22px; font-weight: 700; margin: 6px 0 12px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; border-bottom: 1px solid var(--line);
  padding-bottom: 2px; overflow-x: auto; }
.chart .col { flex: 1 0 28px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.chart .barv { width: 70%; background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .lab { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.chart .val { font-size: 11px; margin-bottom: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; table-layout: fixed; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--soft); font-weight: 600; z-index: 2; user-select: none; }
th { position: relative; cursor: grab; }
th.dragover { background: #E4E8F3; }
.rz { position: absolute; right: 0; top: 0; width: 6px; height: 100%; cursor: col-resize; }
.rz:hover { background: rgba(55,68,110,.25); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.reset-cols { font-size: 12px; margin-top: 4px; }
td input, td select { width: 100%; border: 1px solid transparent; padding: 3px 4px; border-radius: 4px; background: transparent; }
td input:hover, td input:focus, td select:hover, td select:focus { border-color: var(--line); outline: 0; background: #fff; }
.form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.form input, .form select { border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 8px; display: none; z-index: 50; max-width: 90vw; }
#toast a { color: #fff; font-weight: 600; }
#toast.on { display: block; }

.noaccess { max-width: 420px; margin: 15vh auto; text-align: center; }

@media (max-width: 720px) {
  body { flex-direction: column; }
  #side { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .brand { padding: 12px 16px; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  #nav a { padding: 12px 10px; border-left: 0; border-bottom: 3px solid transparent; }
  #nav a.on { border-bottom-color: #fff; }
  body.admin .admin-only { display: inline-block !important; }
  #who { display: none; }
  main { padding: 16px; }
  .bar { flex-wrap: wrap; }
  .bar input[type=text] { flex-basis: 100%; }
  .bar select { flex: 1; max-width: none; }
  .row { flex-wrap: wrap; }
  .proj { max-width: 60%; }
  .grid2 { grid-template-columns: 1fr; }
}
.login input { display: block; width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
  font-size: 16px; margin: 0 0 10px; text-align: center; }
.login .btn { width: 100%; }
.login h1 { color: var(--blue); font-size: 26px; }
