* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: #333;
  background: #f2f6f8;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: #03a9f4; }
.muted { color: #999; }
.grow { flex: 1; }
.ic { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }

#app {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 200px 1fr;
  height: 100vh;
}
body.collapsed #app { grid-template-columns: 56px 1fr; }
body.collapsed .nav span, body.collapsed .nav .sec { display: none; }

header {
  grid-column: 1 / 3;
  background: #fff;
  border-bottom: 1px solid #c6d2d9;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px 0 10px;
}
.logo { display: flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 500; color: #333; text-decoration: none; letter-spacing: -.3px; }
.logo-mark { width: 26px; height: 26px; border-radius: 6px; background: #03a9f4; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.ws { padding-left: 14px; border-left: 1px solid #e4eaee; color: #666; }
.hdr-timer { font-weight: 500; color: #03a9f4; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 4px; background: #7b3fe4; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; border: 0; padding: 0; cursor: pointer; }
.avatar:hover, .avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(123, 63, 228, .25); }
.avatar[hidden] { display: none; }
.avatar:focus-visible { outline: 2px solid #03a9f4; outline-offset: 2px; }
.user-menu { min-width: 240px; }
.user-head { padding: 14px; border-bottom: 1px solid #e4eaee; display: flex; gap: 10px; align-items: center; }
.user-head .avatar { cursor: default; flex: none; }
.user-head .avatar:hover { box-shadow: none; }
.user-name { font-weight: 500; }
.user-email { color: #999; font-size: 12px; word-break: break-all; }

/* auth */
#auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
#auth[hidden], #app[hidden] { display: none; }
.auth-card { background: #fff; border: 1px solid #c6d2d9; width: 400px; max-width: 100%; padding: 32px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.auth-card .logo { justify-content: center; margin-bottom: 8px; }
.auth-card h1 { font-size: 20px; font-weight: 400; text-align: center; margin: 8px 0 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .inp { width: 100%; }
.auth-card .btn { height: 40px; width: 100%; }
.field .hint { font-size: 12px; color: #999; }
.field.invalid .inp { border-color: #f44336; }
.field .err { font-size: 12px; color: #f44336; }
.auth-error { background: #fdecea; color: #b71c1c; padding: 10px 12px; font-size: 13px; border-radius: 2px; }
.auth-error.ok { background: #e8f5e9; color: #1b5e20; }
.auth-error[hidden] { display: none; }
.auth-done .big { color: #03a9f4; }
.auth-switch { text-align: center; margin-top: 18px; color: #666; }

.sidebar { background: #fff; border-right: 1px solid #c6d2d9; overflow: auto; padding-top: 8px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 0 18px; height: 44px; color: #666; text-decoration: none; text-transform: uppercase; font-size: 13px; white-space: nowrap; }
.nav a:hover { background: #f2f6f8; }
.nav a.active { background: #e4eaee; color: #333; }
.nav a .ic { color: #999; }
.nav .sec { font-size: 11px; color: #999; padding: 18px 18px 6px; text-transform: uppercase; }
.nav a { position: relative; }
.nav a[hidden] { display: none; }
.badge { background: #f44336; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 500; min-width: 20px; height: 20px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
.badge[hidden] { display: none; }
body.collapsed .nav .badge { position: absolute; left: 30px; top: 4px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.tabs .badge { margin-left: 6px; vertical-align: middle; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #e4eaee; color: #666; text-transform: uppercase; }
.pill.admin { background: #ede7f6; color: #5e35b1; }
.pill.pending { background: #fff3e0; color: #e65100; }
.pill.active { background: #e8f5e9; color: #2e7d32; }
.pill.rejected, .pill.disabled { background: #fdecea; color: #b71c1c; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions .btn { height: 30px; padding: 0 12px; margin-left: 6px; }
.auth-done { text-align: center; color: #555; line-height: 1.6; }
.auth-done .big { color: #ff9800; margin-bottom: 6px; }

main { overflow: auto; padding: 20px 24px 60px; }
.page { max-width: 1500px; margin: 0 auto; }
.page-title { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-title h1 { font-size: 24px; font-weight: 400; margin: 0; }

/* buttons */
.btn { border: 1px solid transparent; border-radius: 2px; padding: 0 16px; height: 36px; text-transform: uppercase; font-size: 13px; background: #fff; white-space: nowrap; }
.btn-primary { background: #03a9f4; color: #fff; }
.btn-primary:hover { background: #0398db; }
.btn-stop { background: #f44336; color: #fff; }
.btn-stop:hover { background: #e53935; }
.btn-outline { border-color: #c6d2d9; color: #666; }
.btn-outline:hover { background: #f2f6f8; }
.btn .ic { margin-right: 6px; vertical-align: middle; }
.btn-danger { color: #f44336; border-color: #f44336; }
.btn-plain { background: none; border: 1px solid transparent; border-radius: 2px; padding: 4px 6px; display: inline-flex; align-items: center; gap: 4px; color: #999; }
.btn-plain:hover { border-color: #c6d2d9; }
.icon-btn { background: none; border: 0; padding: 4px; border-radius: 2px; color: #999; display: inline-flex; align-items: center; }
.icon-btn:hover { color: #333; background: #f2f6f8; }
.icon-btn.on { color: #03a9f4; }
.link { background: none; border: 0; color: #03a9f4; padding: 0; display: inline-flex; align-items: center; gap: 4px; }

.inp { height: 36px; border: 1px solid #c6d2d9; border-radius: 2px; padding: 0 10px; background: #fff; outline: none; }
.inp:focus { border-color: #03a9f4; }
select.inp { padding: 0 6px; }

/* tracker bar */
.tracker-bar { display: flex; align-items: center; background: #fff; border: 1px solid #c6d2d9; min-height: 66px; padding: 0 8px 0 16px; gap: 8px; margin-bottom: 26px; flex-wrap: wrap; }
.tb-desc { flex: 1; border: 0; font-size: 15px; outline: none; min-width: 160px; height: 44px; }
.tb-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tb-timer { font-size: 18px; font-weight: 500; min-width: 92px; text-align: center; margin: 0 8px; font-variant-numeric: tabular-nums; }
.tb-right .btn { min-width: 90px; height: 40px; }
.mode-sw { display: flex; flex-direction: column; margin-left: 4px; }
.mode-sw .icon-btn { padding: 2px; }
.proj-btn { color: #03a9f4; max-width: 280px; }
.proj-ph { display: inline-flex; align-items: center; gap: 4px; color: #03a9f4; }
.proj-label { display: inline-flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.proj-client { color: #999; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.tag-btn.on { color: #03a9f4; }
.tag-names { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-btn.on { color: #03a9f4; }
.sep { width: 1px; height: 24px; border-left: 1px dotted #c6d2d9; margin: 0 4px; }
.time-in { width: 56px; height: 32px; text-align: center; border: 1px solid transparent; border-radius: 2px; outline: none; background: transparent; }
.time-in:hover, .time-in:focus { border-color: #c6d2d9; }
.dur-in { width: 90px; height: 32px; text-align: center; font-weight: 500; font-size: 15px; border: 1px solid transparent; border-radius: 2px; outline: none; background: transparent; font-variant-numeric: tabular-nums; }
.dur-in:hover, .dur-in:focus { border-color: #c6d2d9; }
.date-btn { position: relative; }
.date-btn input { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; }
.date-in { height: 32px; border: 1px solid transparent; border-radius: 2px; background: transparent; }
.date-in:hover { border-color: #c6d2d9; }

/* entries */
.week-head { display: flex; justify-content: space-between; align-items: center; color: #666; margin: 22px 0 8px; padding: 0 2px; }
.day-card { background: #fff; border: 1px solid #c6d2d9; margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; align-items: center; background: #e4eaee; padding: 0 16px; height: 44px; color: #666; }
.entry-row { display: flex; align-items: center; min-height: 58px; padding: 4px 8px 4px 16px; border-top: 1px solid #e4eaee; gap: 8px; flex-wrap: wrap; }
.entry-row:hover { background: #fafcfd; }
.er-left { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 260px; }
.er-right { display: flex; align-items: center; gap: 4px; }
.row-desc { border: 1px solid transparent; height: 34px; padding: 0 8px; border-radius: 2px; outline: none; min-width: 120px; flex: 0 1 auto; width: 40%; background: transparent; }
.row-desc:hover, .row-desc:focus { border-color: #c6d2d9; background: #fff; }
.load-more { text-align: center; margin: 20px; }

.empty { background: #fff; border: 1px solid #c6d2d9; max-width: 380px; margin: 120px auto; text-align: center; padding: 30px 20px; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.empty h2 { font-weight: 400; margin: 14px 0 6px; }
.empty .big { color: #03a9f4; }

/* popover */
.popover { position: absolute; z-index: 1000; background: #fff; border: 1px solid #c6d2d9; box-shadow: 0 4px 14px rgba(0,0,0,.15); border-radius: 2px; min-width: 180px; max-height: 380px; display: flex; flex-direction: column; }
.pop-search { margin: 8px; height: 34px; border: 1px solid #c6d2d9; padding: 0 10px; outline: none; border-radius: 2px; }
.pop-search:focus { border-color: #03a9f4; }
.pop-list { overflow: auto; flex: 1; padding: 4px 0; }
.pop-group { font-size: 11px; text-transform: uppercase; color: #999; padding: 8px 14px 4px; }
.pop-item { padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.pop-item:hover, .pop-item.hl { background: #f2f6f8; }
.pop-item.sel { font-weight: 500; }
button.pop-item { width: 100%; border: 0; background: none; text-align: left; font: inherit; color: inherit; }
button.pop-item:focus-visible { background: #f2f6f8; outline: none; }
.pop-item .ic { color: #999; }
.pop-item.sugg { justify-content: space-between; }
.pop-item.danger { color: #f44336; }
.pop-empty { padding: 10px 14px; color: #999; }
.pop-foot { border-top: 1px solid #e4eaee; padding: 10px 14px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 900; display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh; }
.modal { background: #fff; width: 520px; max-width: 95vw; border-radius: 2px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid #e4eaee; }
.modal-head h3 { margin: 0; font-weight: 400; font-size: 18px; }
.modal-head .icon-btn { font-size: 22px; line-height: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid #e4eaee; }
.modal-foot .left { margin-right: auto; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: #999; text-transform: uppercase; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #c6d2d9; cursor: pointer; }
.swatch.sel { box-shadow: 0 0 0 2px #333; }

/* toast */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #333; color: #fff; padding: 12px 18px; border-radius: 3px; display: flex; gap: 18px; align-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast .link { color: #4fc3f7; font-weight: 500; }

/* cards / tables */
.card { background: #fff; border: 1px solid #c6d2d9; margin-bottom: 18px; }
.card-head { padding: 12px 16px; border-bottom: 1px solid #e4eaee; display: flex; align-items: center; gap: 10px; color: #666; }
.card-body { padding: 16px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 400; font-size: 12px; color: #999; text-transform: uppercase; padding: 10px 16px; background: #e4eaee; }
.tbl td { padding: 10px 16px; border-top: 1px solid #e4eaee; vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fafcfd; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.sub td { background: #fafcfd; }
.tbl tr.sub td:first-child { padding-left: 42px; }
.tbl tfoot td { font-weight: 500; background: #f2f6f8; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid #c6d2d9; padding: 16px; }
.stat .lbl { font-size: 12px; color: #999; text-transform: uppercase; }
.stat .val { font-size: 22px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.tabs { display: flex; border-bottom: 1px solid #c6d2d9; margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 10px 18px; text-transform: uppercase; font-size: 13px; color: #666; border-bottom: 2px solid transparent; }
.tabs button.on { color: #03a9f4; border-bottom-color: #03a9f4; }
.totals { display: flex; gap: 24px; align-items: center; padding: 12px 16px; flex-wrap: wrap; }
.totals b { font-size: 16px; }

/* charts */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 240px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-val { font-size: 11px; color: #666; height: 16px; white-space: nowrap; }
.bar-track { flex: 1; width: 70%; max-width: 60px; display: flex; flex-direction: column-reverse; }
.bar-seg { width: 100%; }
.bar-lbl { font-size: 11px; color: #999; height: 30px; padding-top: 6px; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; }
.donut { width: 190px; height: 190px; border-radius: 50%; margin: 10px auto; display: flex; align-items: center; justify-content: center; }
.donut-hole { width: 120px; height: 120px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; }
.legend { list-style: none; padding: 0; margin: 10px 0 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.legend li .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .pct { color: #999; width: 52px; text-align: right; }

/* calendar */
.cal-page { display: flex; flex-direction: column; height: calc(100vh - 100px); }
.cal-wrap { background: #fff; border: 1px solid #c6d2d9; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cal-head { display: flex; border-bottom: 1px solid #c6d2d9; padding-right: 12px; }
.cal-gutter { width: 60px; flex: none; }
.cal-dh { flex: 1; padding: 8px; display: flex; align-items: center; gap: 8px; border-left: 1px solid #e4eaee; min-width: 0; }
.cal-dnum { font-size: 22px; color: #666; }
.cal-dh.today .cal-dnum { color: #03a9f4; }
.cal-dh small { display: block; color: #999; }
.cal-body { flex: 1; overflow-y: scroll; }
.cal-grid { display: flex; position: relative; }
.cal-hour { font-size: 11px; color: #999; text-align: right; padding-right: 8px; transform: translateY(-7px); }
.cal-col { flex: 1; position: relative; border-left: 1px solid #e4eaee; min-width: 0; user-select: none;
  background-image: linear-gradient(#e4eaee 1px, transparent 1px); background-size: 100% 48px; cursor: crosshair; }
.cal-ev { position: absolute; border-left: 3px solid; padding: 2px 6px; font-size: 12px; overflow: hidden; cursor: pointer; border-radius: 2px; }
.cal-ev:hover { filter: brightness(.95); }
.cal-ev.running { border-style: dashed; }
.cal-ev-t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-p, .cal-ev-d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ghost { position: absolute; left: 2px; right: 2px; background: rgba(3,169,244,.25); border: 1px solid #03a9f4; font-size: 12px; padding: 2px 6px; pointer-events: none; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: #f44336; pointer-events: none; }

@media (max-width: 900px) {
  #app { grid-template-columns: 56px 1fr; }
  .nav span, .nav .sec { display: none; }
  .stats, .grid2 { grid-template-columns: 1fr; }
  main { padding: 12px; }
}
