:root {
  --blue: #1c64b8;
  --blue-dark: #0e3f78;
  --green: #23a026;
  --green-dark: #1b7f1e;
  --red: #c62828;
  --amber: #b26a00;
  --ink: #24292f;
  --muted: #6a737d;
  --line: #e2e6ea;
  --bg: #f4f6f8;
  --card: #ffffff;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--blue-dark); }
h3 .muted { font-weight: normal; }
code { background: #eef1f4; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

/* nav */
.topnav { background: #fff; border-bottom: 1px solid var(--line); }
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 52px; }
.brand { font-weight: 700; font-size: 17px; color: var(--blue-dark); }
.brand span { color: var(--green); }
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-links a { padding: 15px 10px; color: var(--ink); border-bottom: 3px solid transparent; }
.nav-links a:hover { text-decoration: none; color: var(--blue); }
.nav-links a.on { border-bottom-color: var(--blue); color: var(--blue); font-weight: 600; }
.nav-user { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.dropdown { position: relative; }
.dropdown .menu { display: none; position: absolute; top: 100%; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.12); min-width: 180px; z-index: 50; }
.dropdown:hover .menu { display: block; }
.dropdown .menu a { display: block; padding: 9px 14px; border-bottom: none; }
.dropdown .menu a:hover { background: #f0f5fb; }

.container { max-width: 1200px; margin: 22px auto; padding: 0 16px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.actions { display: flex; gap: 8px; align-items: center; }

/* cards, stats */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card.slim { padding: 10px 16px; }
.card.narrow { max-width: 680px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.two-col.wide-left { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) { .two-col, .two-col.wide-left { grid-template-columns: 1fr; } }
.stats { display: flex; gap: 16px; justify-content: center; margin: 10px 0 22px; }
.stat { text-align: center; padding: 8px 30px; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--blue); }
.stat .num.red { color: var(--red); }
.stat .num.muted { color: var(--muted); }
.stat .lbl { color: var(--muted); }
.red { color: var(--red); }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tfoot td { border-bottom: none; border-top: 2px solid var(--line); }
.table-hover tbody tr:hover { background: #f6f9fc; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.indent { padding-left: 26px !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 18px; }
.mb { margin-bottom: 12px; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.badge-draft { background: #eceff1; color: #546e7a; }
.badge-sent { background: #e3f0fb; color: var(--blue-dark); }
.badge-partial { background: #fff3e0; color: var(--amber); }
.badge-overdue { background: #fdecea; color: var(--red); }
.badge-paid { background: #e6f4e6; color: var(--green-dark); }
.badge-manual { background: #eceff1; color: #546e7a; }
.badge-invoice, .badge-payment { background: #e3f0fb; color: var(--blue-dark); }

/* forms */
label { display: block; margin-bottom: 10px; font-weight: 600; font-size: 13px; }
label.check { font-weight: normal; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
input:not([type]), select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid #c8cfd6; border-radius: 5px;
  font: inherit; font-weight: normal; margin-top: 3px; background: #fff;
}
label.check input, label.inline input[type=date], td input[type=checkbox], td input[type=radio] { width: auto; margin-top: 0; }
label.inline input, label.inline select { width: auto; margin-top: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd7f2; border-color: var(--blue); }
.num-input { max-width: 100px; }
.small-input { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 700px) { .row3, .row4 { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; align-items: center; margin: 14px 0; }
.form-actions .right { margin-left: auto; }
.inline-form { display: inline; }
td .inline-form { display: inline-block; }
table label { font-weight: normal; }
td input:not([type=checkbox]):not([type=radio]), td select { margin-top: 0; }

/* buttons */
.btn { display: inline-block; padding: 8px 14px; border: 1px solid #c8cfd6; border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { background: #f1f4f7; text-decoration: none; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { color: var(--red); border-color: #e5b5b2; }
.btn-danger:hover { background: #fdecea; }
.btn-warn { color: var(--amber); border-color: #e8cfa5; }
.btn-warn:hover { background: #fff5e6; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash-ok { background: #e6f4e6; color: var(--green-dark); border: 1px solid #bfe3bf; }
.flash-error { background: #fdecea; color: var(--red); border: 1px solid #f2c4c0; }

/* login */
.login-box { max-width: 360px; margin: 80px auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login-box h1 { text-align: center; color: var(--blue-dark); }
.login-box h1 .accent { color: var(--green); }
.login-box p { text-align: center; }

/* time tracking */
.time-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.tabs { display: inline-flex; border: 1px solid #c8cfd6; border-radius: 20px; overflow: hidden; background: #fff; }
.tab { padding: 7px 18px; color: var(--ink); }
.tab:hover { text-decoration: none; background: #f1f4f7; }
.tab.on { background: var(--blue); color: #fff; font-weight: 600; }
.datenav { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.weekstrip { display: grid; grid-template-columns: repeat(8, 1fr); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.wday { padding: 8px 10px; border-right: 1px solid var(--line); color: var(--ink); background: #fafbfc; }
.wday:hover { text-decoration: none; background: #eef4fa; }
.wday.on { background: #dde9f6; }
.wday.total { background: #f1f4f7; }
.wd-name { font-size: 12px; color: var(--muted); }
.wd-total { font-weight: 600; }
.entry-grid { display: grid; grid-template-columns: 2fr 1.5fr 0.8fr 1fr 1fr; gap: 10px; align-items: end; }
.entry-grid .wide { grid-column: span 3; }
.entry-grid label { margin-bottom: 0; }
.entry-grid .btn { height: 34px; }
@media (max-width: 900px) { .entry-grid { grid-template-columns: 1fr 1fr; } .entry-grid .wide { grid-column: span 2; } }

/* invoice */
.invoice-summary { display: flex; gap: 40px; flex-wrap: wrap; }

/* week timesheet grid */
.timesheet .cell { width: 62px; text-align: center; padding: 6px 4px; }
.timesheet td { vertical-align: middle; }
.timesheet tfoot td { border-top: 2px solid var(--line); }

/* month calendar */
.calendar td.cal-day { height: 64px; width: 12%; padding: 4px 6px; vertical-align: top; }
.calendar td.cal-out { background: #f4f6f8; }
.calendar td.cal-sel { outline: 2px solid var(--blue); outline-offset: -2px; border-radius: 4px; }
.calendar .cal-day a { display: block; height: 100%; color: inherit; }
.calendar .cal-day a:hover { text-decoration: none; background: #eef4fa; }
.calendar .cal-num { font-size: 12px; color: var(--muted); }
.calendar .cal-total { font-weight: 700; text-align: center; margin-top: 6px; }

/* dashboard charts */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.chart-hero .num { font-size: 22px; font-weight: 700; color: var(--blue); }
.plchart { display: flex; gap: 6px; align-items: stretch; margin: 14px 0 6px; }
.plcol { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.plhalf { height: 72px; display: flex; align-items: flex-end; justify-content: center; }
.plhalf.top { border-bottom: 1px solid var(--ink); }
.plhalf.bottom { align-items: flex-start; }
.plbar { width: 60%; max-width: 34px; min-height: 0; }
.plbar.in { background: var(--blue); border-radius: 4px 4px 0 0; }
.plbar.out { background: var(--red); border-radius: 0 0 4px 4px; }
.pllabel { text-align: center; color: var(--muted); font-size: 11px; margin-top: 4px; }
.legend { display: flex; gap: 16px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .swatch.in { background: var(--blue); }
.legend .swatch.out { background: var(--red); }
.hbar-row { display: grid; grid-template-columns: 200px 1fr 150px; gap: 10px; align-items: center; padding: 5px 0; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.hbar-track { background: #eef1f4; border-radius: 4px; height: 14px; }
.hbar { height: 14px; border-radius: 4px; min-width: 3px; }
.hbar.in { background: var(--blue); }
.hbar.out { background: var(--red); }
.hbar-val { text-align: right; font-size: 12px; white-space: nowrap; }
@media (max-width: 700px) { .hbar-row { grid-template-columns: 110px 1fr 110px; } }
.menu-soon { display: block; padding: 9px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.dropdown .menu-right { left: auto; right: 0; }

/* searchable combobox */
.combo { position: relative; }
.combo-list { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid #c8cfd6; border-radius: 6px; max-height: 260px; overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.combo-item { padding: 8px 10px; cursor: pointer; }
.combo-item:hover { background: #eef4fa; }

/* sortable tables */
table.sortable thead th.th-sort { cursor: pointer; user-select: none; }
table.sortable thead th.th-sort:hover { text-decoration: underline; }
table.sortable thead th.sorted[data-dir="asc"]::after { content: " ▲"; font-size: .7em; }
table.sortable thead th.sorted[data-dir="desc"]::after { content: " ▼"; font-size: .7em; }

/* printing reports: hide chrome, keep the data */
@media print {
  .topnav, .no-print, .flash { display: none !important; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; }
}
