:root {
  --brand: #0f5c4d;
  --brand-dark: #0b4a3e;
  --brand-tint: #e6f2ef;
  --bg: #ffffff;
  --canvas: #f6f7f9;
  --border: #e1e4e8;
  --border-strong: #c8ccd2;
  --text: #1c1f24;
  --text-2: #4b5059;
  --muted: #7b808a;
  --row-hover: #f5f8f7;
  --accent: #0f7a64;
  --danger: #c4314b;
  --danger-tint: #fdecef;
  --warn: #a15c00;
  --warn-tint: #fff4e0;
  --ok: #1e7f45;
  --ok-tint: #e5f5eb;
  --info: #2160c4;
  --info-tint: #e8f0fc;
  --grey-tint: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .10);
  --radius: 8px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--canvas);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ---------- top bar + tabs ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px;
  background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20;
}
.topbar img { width: 28px; height: 28px; }
.topbar .title { font-weight: 700; font-size: 16px; }
.user-btn {
  display: flex; align-items: center; gap: 8px; border: 0; background: rgba(255,255,255,.14);
  color: #fff; padding: 4px 12px 4px 4px; border-radius: 999px;
}
.user-btn:hover { background: rgba(255,255,255,.22); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  background: #ffd166; color: #3d2c00; font-weight: 700; font-size: 11px; flex: none;
}
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.tabs {
  display: flex; gap: 2px; padding: 0 12px; background: var(--brand-dark); overflow-x: auto;
  position: sticky; top: 52px; z-index: 19;
}
.tabs button {
  border: 0; background: transparent; color: rgba(255,255,255,.82); padding: 9px 14px;
  border-radius: 8px 8px 0 0; white-space: nowrap; font-weight: 500; margin-top: 4px;
}
.tabs button:hover { color: #fff; background: rgba(255,255,255,.1); }
.tabs button.active { background: var(--canvas); color: var(--text); font-weight: 650; }
.tabs .badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 5px; }

.page { padding: 18px 20px 40px; max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-head .back { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 600; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--border-strong); background: #fff; border-radius: 6px; padding: 6px 12px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--grey-tint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--brand); }
.btn.danger { color: var(--danger); border-color: #e9b3bd; }
.btn.danger:hover { background: var(--danger-tint); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=url], select, textarea {
  border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 9px; background: #fff; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fd4c7; border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 11px; }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button.on { background: var(--brand-tint); color: var(--brand); font-weight: 650; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; }

/* ---------- cards / stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
.stat.red .n { color: var(--danger); }
.stat.amber .n { color: var(--warn); }
.stat.green .n { color: var(--ok); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card h3 { margin: 0; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.card .flags { display: flex; gap: 6px; flex-wrap: wrap; }
.bar { height: 8px; background: var(--grey-tint); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.empty {
  background: #fff; border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted);
}
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.panel > h2 { font-size: 14px; margin: 0; padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.panel .desc { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); white-space: pre-wrap; }
.info-row { display: flex; gap: 22px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.info-row div span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--danger-tint); color: var(--danger); }
.pill.amber { background: var(--warn-tint); color: var(--warn); }
.pill.green { background: var(--ok-tint); color: var(--ok); }
.pill.blue { background: var(--info-tint); color: var(--info); }
.pill.grey { background: var(--grey-tint); color: var(--text-2); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; background: #fff; }
.grid th, .grid td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover { background: var(--row-hover); }
.grid tr.done td.t-title { color: var(--muted); text-decoration: line-through; }
.grid td.t-title { font-weight: 550; min-width: 220px; }
.grid select.status { width: auto; padding: 3px 6px; font-size: 13px; }
.grid .deps { font-size: 12px; color: var(--text-2); max-width: 260px; }
.grid .group-row td { background: var(--canvas); font-weight: 650; cursor: default; font-size: 13px; }
.who { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50; display: grid; place-items: start center; padding: 6vh 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 560px; }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal header h2 { margin: 0; font-size: 16px; flex: 1; }
.modal header .x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); }
.modal .body { padding: 16px 18px; display: grid; gap: 12px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checklist { border: 1px solid var(--border-strong); border-radius: 6px; max-height: 180px; overflow-y: auto; padding: 4px 0; }
.checklist label { display: flex; align-items: center; gap: 8px; padding: 4px 10px; font-weight: 400; font-size: 13px; color: var(--text); margin: 0; cursor: pointer; }
.checklist label:hover { background: var(--row-hover); }
.checklist .none { padding: 6px 10px; color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--brand); }
.auth form { background: #fff; padding: 26px; border-radius: 12px; width: 100%; max-width: 360px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.auth h1 { margin: 0; font-size: 20px; display: flex; gap: 10px; align-items: center; }
.auth h1 img { width: 32px; }

/* ---------- menu / toast ---------- */
.menu { position: absolute; right: 12px; top: 50px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); z-index: 40; min-width: 200px; padding: 6px 0; color: var(--text); }
.menu .who-line { padding: 6px 14px 8px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.menu button { display: block; width: 100%; border: 0; background: none; text-align: left; padding: 8px 14px; }
.menu button:hover { background: var(--row-hover); }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; }
.toast { background: #1f2937; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }

/* ---------- gantt ---------- */
.gantt { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 210px); position: relative; }
.g-inner { position: relative; }
.g-head { position: sticky; top: 0; z-index: 6; display: flex; background: #fafbfc; border-bottom: 1px solid var(--border); }
.g-label { position: sticky; left: 0; z-index: 5; width: 260px; flex: none; background: #fff; border-right: 1px solid var(--border); padding: 0 10px; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.g-head .g-label { background: #fafbfc; z-index: 7; font-size: 12px; color: var(--muted); font-weight: 600; }
.g-scale { position: relative; height: 44px; flex: none; }
.g-scale .mo { position: absolute; top: 0; height: 22px; border-left: 1px solid var(--border); padding: 3px 6px; font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; }
.g-scale .tick { position: absolute; top: 22px; height: 22px; border-left: 1px solid var(--border); font-size: 11px; color: var(--muted); padding: 3px 0 0 3px; white-space: nowrap; }
.g-row { display: flex; height: 34px; border-bottom: 1px solid #f0f1f3; }
.g-row.proj { background: var(--canvas); }
.g-row.proj .g-label { background: var(--canvas); font-weight: 700; }
.g-row .g-label { font-size: 13px; cursor: pointer; }
.g-row .g-label .sub { color: var(--muted); font-size: 11px; }
.g-track { position: relative; flex: none; }
.g-bar {
  position: absolute; top: 8px; height: 18px; border-radius: 5px; cursor: pointer; font-size: 11px; color: #fff; z-index: 2;
  padding: 0 6px; line-height: 18px; white-space: nowrap; overflow: visible; min-width: 6px;
}
.g-bar span { position: absolute; left: calc(100% + 6px); color: var(--text-2); }
.g-bar.s-ns { background: #9aa3ae; }
.g-bar.s-ip { background: var(--info); }
.g-bar.s-done { background: #3d9a63; }
.g-bar.late { background: var(--danger); }
.g-bar.blocked { background: repeating-linear-gradient(45deg, #c99a3f, #c99a3f 5px, #ddb565 5px, #ddb565 10px); }
.g-bar.proj { background: var(--brand); opacity: .35; height: 10px; top: 12px; }
.g-bar.milestone { width: 14px !important; height: 14px; top: 10px; transform: rotate(45deg); border-radius: 2px; padding: 0; min-width: 0; }
.g-bar.milestone span { transform: rotate(-45deg); left: 18px; top: -2px; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.g-target { position: absolute; top: 4px; bottom: 4px; width: 0; border-left: 2px dashed var(--brand); z-index: 1; }
.g-wkend { position: absolute; top: 0; bottom: 0; background: #f7f8fa; z-index: 0; }
.g-arrows { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; overflow: visible; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin: 10px 2px; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- calendar ---------- */
.cal { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 7px 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--border); }
.cal-day { min-height: 112px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px 5px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: #fafbfc; }
.cal-day.other .d { color: #b4b8bf; }
.cal-day .d { font-size: 12px; font-weight: 600; color: var(--text-2); }
.cal-day.today .d { background: var(--accent); color: #fff; border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; }
.chip { font-size: 12px; padding: 2px 6px; border-radius: 4px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.chip.ns { background: var(--grey-tint); border-color: #9aa3ae; }
.chip.ip { background: var(--info-tint); border-color: var(--info); }
.chip.done { background: var(--ok-tint); border-color: var(--ok); color: var(--text-2); text-decoration: line-through; }
.chip.late { background: var(--danger-tint); border-color: var(--danger); }
.chip.blocked { background: var(--warn-tint); border-color: var(--warn); }
.chip.target { background: var(--brand-tint); border-color: var(--brand); font-weight: 650; }

@media (max-width: 720px) {
  .page { padding: 14px 16px 40px; }
  .row2 { grid-template-columns: 1fr; }
  .g-label { width: 150px; }
  .cal-day { min-height: 70px; padding: 3px; }
  .chip { font-size: 10px; padding: 1px 3px; border-left-width: 2px; }
  .topbar .title { font-size: 15px; }
  .filters select, .filters input { min-width: 0; flex: 1; }
}
