:root {
  --bg: #0f1216; --panel: #171c23; --line: #2a323d; --ink: #e6edf3;
  --muted: #8b98a5; --accent: #4c8dff; --danger: #ff6b6b; --ok: #3fb950;
  --warn: #f0ad4e;
}
* { box-sizing: border-box; }
body {
  margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
}
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; }
h3 { font-size: 14px; margin: 12px 0 6px; }
.badge {
  font-size: 11px; font-weight: 600; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px; padding: 2px 8px; margin-left: 8px;
}
main { max-width: 900px; margin: 0 auto; padding: 20px; }
footer { max-width: 900px; margin: 30px auto; padding: 0 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); min-height: 1.2em; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin: 12px 0; display: flex; flex-direction: column; gap: 10px;
}
.card.row { flex-direction: row; flex-wrap: wrap; align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
input, select, textarea {
  background: #0d1117; border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 8px; font: inherit;
}
button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 9px 14px; font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.link { background: none; color: var(--accent); padding: 2px 4px; font-weight: 500; }
.link.danger { color: var(--danger); }
.danger-btn { background: var(--danger); }
.danger-btn:hover { filter: brightness(1.1); }

.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab { background: none; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }

.whoami { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }

table.grid { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.grid th, .grid td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.grid th { color: var(--muted); font-weight: 600; }

/* P2.1: Timer widget */
.timer-widget {
  margin-bottom: 16px;
  padding: 12px 16px;
}
.timer-controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.timer-controls select,
.timer-controls input {
  flex: 1; min-width: 120px;
}
.timer-display {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.timer-label {
  color: var(--muted); font-size: 13px;
}
.timer-info {
  font-size: 14px;
}
.timer-clock {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 22px; font-weight: 700; color: var(--ok);
  min-width: 100px;
}
.timer-btn {
  padding: 8px 16px; font-size: 14px;
}
.timer-btn.start { background: var(--ok); }
.timer-btn.stop { background: var(--danger); }

/* P2.2: Dashboard */
.dashboard-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.dash-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; text-align: center;
}
.dash-card.accent {
  border-color: var(--ok);
}
.dash-value {
  font-size: 28px; font-weight: 700; color: var(--ink);
}
.dash-label {
  font-size: 12px; color: var(--muted); margin-top: 4px;
}
.dash-recent {
  grid-column: 1 / -1;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px;
}

/* P2.9: Pagination */
.pagination {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  margin: 12px 0; padding: 8px 0;
}

/* P3.1: Status badges */
.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.status-badge.open { background: var(--line); color: var(--muted); }
.status-badge.submitted { background: rgba(76, 141, 255, 0.15); color: var(--accent); border: 1px solid var(--accent); }
.status-badge.approved { background: rgba(63, 185, 80, 0.15); color: var(--ok); border: 1px solid var(--ok); }
.status-badge.rejected { background: rgba(255, 107, 107, 0.15); color: var(--danger); border: 1px solid var(--danger); }

/* P3.4: Notification bell */
.notif-bell {
  position: relative; cursor: pointer; color: var(--muted); padding: 4px;
}
.notif-bell:hover { color: var(--ink); }
.notif-count {
  position: absolute; top: -4px; right: -6px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-dropdown {
  position: absolute; top: 32px; right: 0; width: 320px; max-height: 400px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); overflow: hidden; z-index: 100;
}
.notif-header {
  padding: 12px 16px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line);
}
.notif-list {
  max-height: 340px; overflow-y: auto;
}
.notif-item {
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.notif-item:hover { background: rgba(255,255,255,0.03); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item .notif-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.notif-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* P3.2: Admin table */
.admin-table { width: 100%; }
.admin-table td { vertical-align: middle; }
.admin-table select { padding: 4px 8px; font-size: 12px; }
.admin-table .link { font-size: 12px; }
.user-active { color: var(--ok); }
.user-inactive { color: var(--danger); }

/* P3.6: Modal */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-content {
  width: 90%; max-width: 520px; max-height: 80vh; overflow-y: auto;
}
.modal-actions {
  display: flex; gap: 10px; align-items: center; margin-top: 8px;
}

/* P3.6: Edit history */
.edit-history {
  margin-top: 12px;
}
.edit-history h4 { font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.edit-record {
  font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.edit-record .field { color: var(--accent); font-weight: 600; }
.edit-record .old-val { color: var(--danger); text-decoration: line-through; }
.edit-record .new-val { color: var(--ok); }
.edit-record .edit-reason { font-style: italic; }

/* P3.1: Reject reason display */
.reject-reason {
  font-size: 12px; color: var(--danger); font-style: italic;
  padding: 4px 0;
}

/* P4: Invoice status badges */
.status-badge.inv-draft, .status-badge.inv-draft { background: var(--line); color: var(--muted); }
.status-badge.inv-sent { background: rgba(76, 141, 255, 0.15); color: var(--accent); border: 1px solid var(--accent); }
.status-badge.inv-paid { background: rgba(63, 185, 80, 0.15); color: var(--ok); border: 1px solid var(--ok); }
.status-badge.inv-void { background: rgba(255, 107, 107, 0.15); color: var(--danger); border: 1px solid var(--danger); }
.status-badge.inv-partially_paid { background: rgba(240, 173, 78, 0.15); color: var(--warn); border: 1px solid var(--warn); }

/* P5: Client Portal — hours progress bar */
.hours-cap-card {
  padding: 16px;
}
.hours-cap-card h3 {
  margin: 0 0 12px 0;
}
.hours-bar-track {
  width: 100%; height: 20px; background: var(--line); border-radius: 10px;
  overflow: hidden; position: relative;
}
.hours-bar-fill {
  height: 100%; border-radius: 10px; transition: width 0.5s ease;
  min-width: 2px;
}
.hours-bar-labels {
  display: flex; justify-content: space-between; font-size: 12px;
  color: var(--muted); margin-top: 6px;
}
.hours-bar-status {
  font-size: 13px; font-weight: 600; margin-top: 4px; text-align: center;
}

/* P6: Budget table */
.budget-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
.budget-table th, .budget-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.budget-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.budget-table .num { text-align: right; }
.budget-row-green { border-left: 3px solid var(--ok); }
.budget-row-yellow { border-left: 3px solid var(--warn); background: rgba(240, 173, 78, 0.05); }
.budget-row-red { border-left: 3px solid var(--danger); background: rgba(255, 107, 107, 0.08); }
.budget-row-amber { border-left: 3px solid #e6a817; }
.budget-pct { font-weight: 700; font-size: 14px; }
.budget-pct-green { color: var(--ok); }
.budget-pct-yellow { color: var(--warn); }
.budget-pct-red { color: var(--danger); }
.budget-over-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: rgba(255, 107, 107, 0.15); color: var(--danger); border: 1px solid var(--danger);
}
.budget-behind-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: rgba(230, 168, 23, 0.15); color: #e6a817; border: 1px solid #e6a817;
}
.budget-bar-track {
  width: 100%; height: 8px; background: var(--line); border-radius: 4px;
  overflow: hidden; position: relative; min-width: 80px;
}
.budget-bar-fill {
  height: 100%; border-radius: 4px; transition: width 0.3s ease;
}
.budget-detail-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin: 12px 0;
}
.budget-detail-card h3 { margin: 0 0 12px; }
.budget-mini-bar {
  display: flex; align-items: center; gap: 8px;
}
.budget-mini-bar .bar-container {
  flex: 1; height: 8px; background: var(--line); border-radius: 4px;
  overflow: hidden;
}
.budget-mini-bar .bar-fill {
  height: 100%; border-radius: 4px;
}
.budget-mini-bar .bar-label {
  font-size: 12px; color: var(--muted); min-width: 40px; text-align: right;
}

/* P6.6: Client weekly trend */
.weekly-trend-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.weekly-trend-table td, .weekly-trend-table th {
  padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line);
}
.weekly-trend-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.trend-bar-cell { width: 50%; }
.trend-bar-track {
  height: 16px; background: var(--line); border-radius: 4px;
  overflow: hidden; position: relative;
}
.trend-bar-fill {
  height: 100%; border-radius: 4px; background: var(--accent);
  transition: width 0.3s ease; min-width: 2px;
}
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: rgba(255,255,255,0.03); }
