:root {
  --blue: #2979FF;
  --orange: #FF6D00;
  --ink: #1c2333;
  --ink-2: #5a6478;
  --ink-3: #8a93a6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e4e8f0;
  --danger: #d32f2f;
  --good: #00C853;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(28, 35, 51, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand {
  color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem;
  display: flex; align-items: baseline; gap: 6px;
}
.brand small { font-weight: 500; opacity: .85; font-size: .8rem; }
#topbar nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
#topbar nav a {
  color: #fff; text-decoration: none; font-weight: 600; padding: 7px 14px;
  border-radius: 999px;
}
#topbar nav a.active, #topbar nav a:hover { background: rgba(255,255,255,.18); }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 80px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 1.5rem; }
.page-head .spacer { flex: 1; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: 0; cursor: pointer; font: inherit; font-weight: 700;
  padding: 10px 18px; border-radius: 999px;
  background: var(--blue); color: #fff;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }
.btn-orange { background: var(--orange); }
.btn-ghost { background: rgba(255,255,255,.16); color: #fff; }
.btn-light { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn:disabled { opacity: .6; cursor: default; }

label.field { display: block; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
label.field > span { display: block; margin-bottom: 5px; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="file"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  padding: 0; flex: none;
}
.color-swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-tile {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 18px;
}
.stat-tile .stat-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.stat-tile .stat-value { font-size: 1.7rem; font-weight: 800; margin-top: 2px; }
.stat-tile .stat-sub { font-size: .8rem; color: var(--ink-2); }

.job-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer; text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
  transition: transform .12s, box-shadow .12s;
}
.job-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(28,35,51,.14); }
.job-card .job-band { height: 12px; }
.job-card .job-body { padding: 14px 16px 16px; }
.job-card h3 { margin: 0 0 4px; font-size: 1.1rem; }

.meter { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.meter > div { height: 100%; border-radius: 4px; }
.meter-caption { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-2); }
.over-budget { color: var(--danger); font-weight: 700; }

/* ---------- task cards ---------- */
.task-card {
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  box-shadow: var(--shadow); border: 0; text-align: left; font: inherit; width: 100%;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .12s, box-shadow .12s;
}
.task-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(28,35,51,.18); }
.task-card h4 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.task-card.done { opacity: .55; }
.task-card.done h4 { text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.85); color: var(--ink);
  display: inline-flex; align-items: center; gap: 4px;
}
.chip.on-light { background: rgba(0,0,0,.14); color: inherit; }
.chip-overdue { background: var(--danger); color: #fff; }

.section-tabs { display: flex; gap: 6px; margin: 18px 0 14px; flex-wrap: wrap; }
.section-tabs button {
  font: inherit; font-weight: 700; border: 0; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; background: #fff; color: var(--ink-2);
  box-shadow: var(--shadow);
}
.section-tabs button.active { background: var(--ink); color: #fff; }

/* ---------- tables ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 480px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- files & photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo-item {
  border-radius: 14px; overflow: hidden; background: var(--card); box-shadow: var(--shadow);
  text-decoration: none; color: inherit; display: block;
}
.photo-item img { width: 100%; height: 110px; object-fit: cover; display: block; }
.photo-item .photo-caption { padding: 6px 9px; font-size: .78rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 10px 14px; margin-bottom: 8px;
}
.file-row .file-icon { font-size: 1.4rem; }
.file-row .file-name { font-weight: 700; overflow-wrap: anywhere; }
.file-row .file-sub { font-size: .78rem; color: var(--ink-2); }
.file-row .spacer { flex: 1; }

/* ---------- modal ---------- */
#modal-root:not(:empty) {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 26, 40, .55);
  display: flex; align-items: flex-end; justify-content: center;
  overflow-y: auto; padding: 0;
}
.modal {
  background: var(--bg); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; padding: 20px 18px 30px;
  max-height: 92dvh; overflow-y: auto;
  animation: slide-up .18s ease-out;
}
@keyframes slide-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 1.25rem; flex: 1; }
.modal-close { border: 0; background: var(--line); border-radius: 50%; width: 34px; height: 34px; font-size: 1.1rem; cursor: pointer; flex: none; }
.modal .card-section {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 14px;
}
.modal .card-section h3 { font-size: .95rem; margin-bottom: 10px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; min-width: 0; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.modal-actions .spacer { flex: 1; }

@media (min-width: 640px) {
  #modal-root:not(:empty) { align-items: center; padding: 24px; }
  .modal { border-radius: 22px; }
}

/* ---------- auth ---------- */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: 30px 26px; width: 100%; max-width: 400px; text-align: center;
}
.auth-card .logo { font-size: 3rem; }
.auth-card h1 { font-size: 1.4rem; }
.auth-card form { text-align: left; margin-top: 18px; }
.auth-card .btn { width: 100%; margin-top: 6px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 18px; left: 0; right: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; font-weight: 600; font-size: .9rem;
  padding: 11px 20px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  animation: slide-up .18s ease-out;
}
.toast.error { background: var(--danger); }

.empty-state {
  text-align: center; color: var(--ink-2); padding: 34px 16px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty-state .big { font-size: 2.2rem; }

@media (max-width: 480px) {
  .brand small { display: none; }
  main { padding: 14px 12px 80px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; gap: 0; }
}
@media (max-width: 360px) {
  .grid { grid-template-columns: 1fr; }
}
