:root {
  --brand: #2E6C5F; --brand-dark: #23564B; --brand-soft: #E7F1EE;
  --accent: #F5C25C; --accent-dark: #E9B13F; --on-accent: #1B3B34;
  --bg: #F5F6FA; --surface: #fff; --subtle: #F1F3F8; --border: #E5E7EF;
  --text: #0F172A; --muted: #64748B;
  --red: #DC2626; --red-soft: #FEE2E2; --amber: #B45309; --amber-soft: #FEF3C7;
  --green: #15803D; --green-soft: #DCFCE7; --gray: #475569; --gray-soft: #EEF1F5;
  --purple: #7C3AED; --purple-soft: #F1EAFE;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }

/* Layout */
.layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 240px; max-width: 100%; background: var(--brand); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }
.brand img { width: 44px; height: 44px; border-radius: 10px; }
.brand b { display: block; font-size: 16px; }
.brand span { font-size: 12px; color: var(--accent); }
.nav { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: rgba(255,255,255,.85); text-decoration: none; font-weight: 500; }
.nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav.on { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.nav.on svg { color: var(--accent); }
.nav .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 600; }
.side .spacer { flex: 1 1 auto; min-height: 20px; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.18); color: #fff; text-decoration: none; }
.me:hover { color: #fff; }
.me .av { background: var(--accent); color: var(--on-accent); }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 820px) {
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .brand { padding: 0 8px 0 0; } .brand div { display: none; }
  .side .spacer, .me div { display: none; } .me { border: 0; padding: 0; }
  .nav { padding: 8px 10px; } .nav span.lbl { display: none; }
  .main { padding: 18px 14px; }
}

/* Elements */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--subtle); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.green { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.green:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { border: 0; background: none; color: var(--brand); font-weight: 600; padding: 4px 0; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-btn:hover { background: var(--subtle); color: var(--text); }
.inp, select.inp, textarea.inp { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.inp:focus, .ed:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
textarea.inp { min-height: 80px; resize: vertical; line-height: 1.5; }
label.lbl, .lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.av { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.av.sm { width: 24px; height: 24px; font-size: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.s-new { color: var(--gray); background: var(--gray-soft); }
.s-progress { color: var(--brand); background: var(--brand-soft); }
.s-review { color: var(--amber); background: var(--amber-soft); }
.s-done { color: var(--green); background: var(--green-soft); }
.s-late { color: var(--red); background: var(--red-soft); }
.p-high { color: var(--red); background: var(--red-soft); }
.p-medium { color: var(--amber); background: var(--amber-soft); }
.p-low { color: var(--gray); background: var(--gray-soft); }
.l-office { color: var(--green); background: var(--green-soft); }
.l-meeting { color: var(--purple); background: var(--purple-soft); }
.l-trip { color: var(--amber); background: var(--amber-soft); }
.l-leave { color: var(--gray); background: var(--gray-soft); }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--subtle); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-weight: 500; color: var(--muted); }
.seg button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 8px 8px 0; }
.tbl td { border-top: 1px solid var(--border); padding: 10px 8px 10px 0; vertical-align: middle; }
.scroll-x { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi .v { font-size: 30px; font-weight: 700; margin: 6px 0; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.col-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.col-side { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { font-weight: 600; display: block; }
.list { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }

/* Kanban */
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 16px; align-items: start; }
.lane { background: var(--subtle); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; }
.lane.drop { outline: 2px dashed var(--brand); }
.lane-h { display: flex; align-items: center; gap: 8px; padding: 4px; }
.tcard { display: block; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-decoration: none; color: inherit; }
.tcard:hover { border-color: #C9D2DF; color: inherit; box-shadow: 0 2px 8px rgba(15,23,42,.06); }
.tcard.late { border-color: var(--red); }
.tcard .t { font-weight: 600; line-height: 1.35; margin: 8px 0; }
.joint { font-size: 12px; font-weight: 500; color: var(--brand); background: var(--brand-soft); padding: 6px 8px; border-radius: 6px; margin-bottom: 8px; }

/* Task card */
.stage { display: flex; gap: 14px; padding: 14px; border-radius: 10px; border: 1px solid var(--border); }
.stage.active { border-color: var(--brand); background: #FAFCFB; }
.stage .num { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; background: var(--gray-soft); color: var(--gray); }
.stage.active .num { background: var(--brand); color: #fff; }
.stage.done .num { background: var(--green); color: #fff; }
.progress { height: 6px; border-radius: 3px; background: var(--gray-soft); margin-bottom: 16px; }
.progress > div { height: 6px; border-radius: 3px; background: var(--brand); }
.desc { line-height: 1.6; word-wrap: break-word; }
.desc ul, .desc ol, .ed ul, .ed ol { padding-left: 22px; }
.desc code, .ed code { background: var(--subtle); border-radius: 4px; padding: 1px 4px; font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 8px 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--brand); }
.comment-body { white-space: pre-wrap; line-height: 1.5; margin-top: 4px; word-wrap: break-word; }
.mention { color: var(--brand); font-weight: 600; }

/* Editor */
.editor { border: 1px solid var(--border); border-radius: 10px; position: relative; background: #fff; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.tb { width: 30px; height: 30px; border: 0; border-radius: 6px; background: none; color: #334155; display: inline-flex; align-items: center; justify-content: center; }
.tb:hover, .tb.on { background: var(--subtle); }
.ed { min-height: 110px; max-height: 420px; overflow: auto; padding: 12px 14px; line-height: 1.6; border-radius: 0 0 10px 10px; }
.ed:empty::before { content: attr(data-placeholder); color: var(--muted); }
.palette { position: absolute; z-index: 20; top: 44px; left: 100px; width: 336px; max-width: calc(100% - 16px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.14); padding: 14px; }
.swatches { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 6px; }
.sw { aspect-ratio: 1; border: 1px solid rgba(0,0,0,.1); border-radius: 6px; padding: 0; font-weight: 600; font-size: 12px; }
.sw:hover { outline: 2px solid var(--text); outline-offset: 1px; }

/* Meetings */
.week { display: grid; grid-template-columns: 220px repeat(5, minmax(150px, 1fr)); min-width: 980px; }
.week > div { border-bottom: 1px solid var(--border); padding: 8px; }
.week .h { background: var(--subtle); font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 8px; }
.week .d { border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.week .today { background: #FAFCFB; }
.ev { text-align: left; width: 100%; padding: 6px 8px 6px 10px; border-radius: 6px; border: 0; border-left: 3px solid currentColor; font-size: 12px; }
.ev b { display: block; font-weight: 600; }
.ev span { color: var(--muted); font-size: 11px; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-row .who { width: 170px; flex: none; display: flex; align-items: center; gap: 8px; }
.bar { height: 8px; border-radius: 4px; }

/* Modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(20,48,42,.55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal { width: 680px; max-width: 100%; background: #fff; border-radius: 16px; box-shadow: 0 16px 48px rgba(0,0,0,.2); }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.modal-b { padding: 20px 24px; }
.modal-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
.stage-row { display: grid; grid-template-columns: 26px minmax(160px, 1.2fr) minmax(150px, 1.5fr) 140px 32px; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); }
@media (max-width: 700px) { .stage-row { grid-template-columns: 26px 1fr 32px; } .stage-row .what, .stage-row .sdl { grid-column: 2 / 3; } }
.stage-no { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--subtle); font-size: 13px; }
.chip button { border: 0; background: none; color: var(--muted); padding: 0 4px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand); padding: 20px; }
.login form { width: 380px; max-width: 100%; background: #fff; border-radius: 16px; padding: 32px; }
.login img { width: 72px; height: 72px; border-radius: 14px; display: block; margin: 0 auto 16px; }

@media print {
  .side, .no-print, #toast { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { break-inside: avoid; }
}
