/* CapNet Projects — styles. Brand: CapNet Brand Guidelines v1.0 (Inter; orange #F58220 primary;
   spectrum green/amber/blue/red as small accents only; neutrals do the heavy lifting). */
:root {
  --orange: #F58220;
  --orange-strong: #E0700F;
  --orange-tint: #FFF1E2;
  --green: #5BA740;
  --amber: #F5A623;
  --blue: #1976D2;
  --red: #E53935;
  --ink: #0F172A;
  --charcoal: #334155;
  --grey: #64748B;
  --hairline: #E2E8F0;
  --offwhite: #F8FAFC;
  --white: #FFFFFF;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 2px 6px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.28);
  --sidebar-w: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Inter', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--offwhite);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 700; margin: 0; }
h3 { font-size: 14px; font-weight: 700; margin: 0; }
h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--grey); margin: 0 0 10px; }
p { margin: 0; }

.muted { color: var(--grey); }
.small { font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.spacer { flex: 1; }
.pad { padding: 8px 10px; }
.right { text-align: right; }
.ico { flex: none; vertical-align: -3px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar, .nav-scrim { display: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 12px 12px;
  background: var(--white);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
}
.brand { display: flex; flex-direction: column; gap: 6px; padding: 0 8px 16px; margin-bottom: 8px; border-bottom: 1px solid var(--hairline); }
.brand img { display: block; width: 140px; height: auto; }
.brand-app { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--charcoal); }
.nav a, .nav-projects a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  text-decoration: none; color: var(--charcoal); font-weight: 500;
}
.nav a:hover, .nav-projects a:hover { background: var(--slate-100); }
.nav a.active, .nav-projects a.active { background: var(--orange-tint); color: var(--ink); font-weight: 600; }
.nav a.active .ico { color: var(--orange-strong); }
.nav-heading {
  display: flex; align-items: center; justify-content: space-between;
  margin: 16px 6px 4px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--grey);
}
.nav-projects { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.sidebar-foot { border-top: 1px solid var(--hairline); padding: 12px 6px 2px; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me-name { font-weight: 600; }
.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sync-row .link-btn { white-space: nowrap; }

.page { padding: 28px 32px 48px; width: 100%; max-width: 1440px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin-top: 6px; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--slate-300); border-radius: 8px;
  background: var(--white); font-weight: 600; cursor: pointer;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--slate-100); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.btn.primary:hover { background: var(--orange-strong); border-color: var(--orange-strong); }
.btn.success { background: #EEF7EA; border-color: var(--green); color: #2F6B1E; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--grey); cursor: pointer;
  font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: var(--slate-100); color: var(--ink); }
.icon-btn.small { width: 24px; height: 24px; font-size: 17px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--blue); font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--grey); text-decoration: none; cursor: default; }
.link-btn.danger { color: var(--red); }

.input {
  width: 100%; height: 36px; padding: 0 10px;
  border: 1px solid var(--slate-300); border-radius: 8px;
  background: var(--white);
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select.input { padding-right: 6px; }
.input:focus, .btn:focus-visible, .icon-btn:focus-visible, .inline-edit:focus, .card:focus-visible, .link-btn:focus-visible, .seg button:focus-visible {
  outline: 2px solid var(--orange); outline-offset: 1px;
}
.search { max-width: 300px; }
input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--slate-100); border-radius: 9px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--charcoal); font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--white); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.count {
  display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--slate-200); color: var(--charcoal);
  font-size: 11px; font-weight: 600; text-align: center; line-height: 18px;
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.lg { width: 14px; height: 14px; }
.tag, .pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px;
  background: var(--slate-100); color: var(--charcoal);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pill.green { background: #EEF7EA; color: #2F6B1E; }
.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: var(--ink);
}
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }

/* ---------- banners, empty states, toasts ---------- */
.banner { margin: 16px 32px 0; padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.banner.info { background: #E8F1FB; color: #0D3F75; }
.banner.warn { background: #FEF3DD; color: #6B4600; }
.banner .link-btn { margin-left: 6px; }
.empty {
  padding: 56px 16px; text-align: center; color: var(--grey);
  background: var(--white); border: 1px dashed var(--slate-300); border-radius: 12px;
}
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.loading { padding: 40px 0; color: var(--grey); }
.loading-screen, .fatal { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; }
.fatal p { max-width: 460px; color: var(--charcoal); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  max-width: 380px; padding: 10px 14px; border-radius: 10px;
  background: var(--ink); color: var(--white); font-size: 13px;
  box-shadow: var(--shadow-lg); animation: rise 0.2s;
}
.toast.error { background: #B3261E; }
.toast.warn { background: #8A5A00; }

/* ---------- projects overview ---------- */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card {
  display: flex; flex-direction: column; gap: 10px; padding: 16px;
  background: var(--white); border: 1px solid var(--hairline); border-radius: 12px;
  text-decoration: none; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.project-card:hover { border-color: var(--slate-300); box-shadow: var(--shadow); }
.pc-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pc-top h3 { flex: 1; }
.pc-foot { display: flex; align-items: center; gap: 10px; }
.progress { height: 6px; background: var(--slate-100); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--orange); border-radius: 3px; }
.overdue { color: var(--red); font-weight: 600; }

/* ---------- project page ---------- */
.project-page { max-width: none; padding-bottom: 0; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 6px; color: var(--grey); font-size: 12px; }
.crumbs a { color: var(--grey); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row h1 { flex: 1; min-width: 200px; overflow-wrap: anywhere; }
.status-select { width: auto; }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 26px; margin-top: 14px; }
.meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.meta-label { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--grey); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border: 1px solid var(--hairline); border-radius: 14px; background: var(--white);
  text-decoration: none; font-weight: 500;
}
.chip:hover { border-color: var(--orange); }
.desc { margin-top: 12px; max-width: 80ch; color: var(--charcoal); white-space: pre-wrap; }
.tabs { display: flex; gap: 4px; margin-top: 18px; border-bottom: 1px solid var(--hairline); overflow-x: auto; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; margin-bottom: -1px;
  color: var(--grey); font-weight: 600; text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--orange); }

/* board */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); gap: 14px;
  align-items: start; overflow-x: auto; padding: 16px 0 24px;
}
.col { display: flex; flex-direction: column; min-height: 120px; max-height: calc(100vh - 260px); background: var(--slate-100); border-radius: 12px; }
.col.drop-target { box-shadow: inset 0 0 0 2px var(--orange); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; font-weight: 700; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 24px; padding: 2px 8px 8px; overflow-y: auto; }
.card {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  background: var(--white); border: 1px solid var(--hairline); border-radius: 10px;
  box-shadow: var(--shadow-sm); cursor: grab;
}
.card:hover { border-color: var(--slate-300); }
.card.dragging { opacity: 0.35; }
.card.is-done .card-title { color: var(--grey); text-decoration: line-through; }
.card-title { font-weight: 500; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--grey); }
.drop-marker { height: 3px; border-radius: 2px; background: var(--orange); }
.add-btn {
  margin: 0 8px 10px; padding: 8px 6px; border: 0; border-radius: 8px;
  background: none; color: var(--grey); font-weight: 500; text-align: left; cursor: pointer;
}
.add-btn:hover { background: var(--slate-200); color: var(--ink); }
.quick-add { padding: 0 8px 10px; }
.prio { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.prio.urgent { color: var(--red); }
.prio.high { color: #C25E0A; }
.prio.low { color: var(--grey); }
.due.overdue, .cell-due.overdue, h3.overdue { color: var(--red); font-weight: 600; }
.ticket-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 6px;
  background: #E8F1FB; color: #0D4F94; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.ticket-badge.complete { background: #EEF7EA; color: #2F6B1E; }
.ticket-badge.warn { background: #FEF3DD; color: #8A5A00; }

/* list + tables */
.list-view { display: flex; flex-direction: column; gap: 18px; padding: 16px 0 32px; }
.list-group { margin-bottom: 18px; }
.list-group h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.task-table, .ticket-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--white); border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden;
}
.task-table td, .ticket-table td, .ticket-table th { padding: 9px 12px; border-bottom: 1px solid var(--hairline); text-align: left; vertical-align: middle; }
.task-table tr:last-child td, .ticket-table tr:last-child td { border-bottom: 0; }
.task-table tr { cursor: pointer; }
.task-table tr:hover td { background: var(--offwhite); }
.ticket-table th { background: var(--offwhite); color: var(--grey); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.ticket-table a { color: var(--blue); font-weight: 600; text-decoration: none; }
.cell-check { width: 36px; }
.cell-title { font-weight: 500; overflow-wrap: anywhere; min-width: 220px; }
.cell-ticket { width: 150px; }
.cell-prio { width: 80px; }
.cell-due { width: 110px; white-space: nowrap; }
.cell-person { width: 190px; white-space: nowrap; }
.cell-person .avatar { margin-right: 6px; vertical-align: middle; }
.table-wrap { overflow-x: auto; }
.quick-add-bar { display: flex; gap: 8px; max-width: 640px; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.28); animation: fade 0.15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  display: flex; flex-direction: column; width: min(580px, 100vw);
  background: var(--white); box-shadow: var(--shadow-lg); animation: slide 0.18s ease-out;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--hairline); }
.drawer-body { display: flex; flex-direction: column; gap: 18px; flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.drawer-body > * { flex-shrink: 0; } /* otherwise the title textarea (a scroll container) collapses to ~0px */
.inline-edit { width: calc(100% + 16px); margin: 0 -8px; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; }
.inline-edit:hover { border-color: var(--hairline); }
.drawer-title { font-size: 20px; font-weight: 700; line-height: 1.3; resize: none; }
.fields { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 10px 12px; margin: 0; }
.fields dt { color: var(--grey); font-weight: 500; }
.fields dd { margin: 0; }
.drawer-section { padding-top: 16px; border-top: 1px solid var(--hairline); }
.ticket-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--offwhite); border: 1px solid var(--hairline); border-radius: 10px; }
.ticket-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-number { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-weight: 700; text-decoration: none; }
.note { padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.note.warn { background: #FEF3DD; color: #6B4600; }
.note.ok { background: #EEF7EA; color: #2F6B1E; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }
.or { margin: 14px 0 8px; color: var(--grey); font-size: 12px; }
.help { margin-top: 8px; }
.comments { display: flex; flex-direction: column; gap: 12px; margin: 0 0 12px; padding: 0; list-style: none; }
.comments li { display: flex; gap: 10px; }
.comment-body { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.activity summary { color: var(--grey); font-size: 12px; font-weight: 600; cursor: pointer; }
.activity ul { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--charcoal); font-size: 12px; }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--hairline); }

/* ---------- modal + forms ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, 0.35); animation: fade 0.15s; }
.modal { width: min(540px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--white); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--hairline); }
.modal-body { padding: 18px 20px 20px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.inline-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.inline-label .input { width: 220px; }
.combo { position: relative; font-weight: 400; }
.combo .input { padding-right: 30px; }
.combo-clear { position: absolute; top: 5px; right: 6px; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: var(--grey); font-size: 18px; cursor: pointer; }
.combo-clear:hover { background: var(--slate-100); color: var(--ink); }
.combo-list {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 260px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--white); border: 1px solid var(--slate-300); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.combo-list li.hi { background: var(--orange-tint); }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- laptops: give task titles the room ---------- */
@media (max-width: 1180px) {
  .cell-person { width: 44px; }
  .cell-person .person-name { display: none; }
  .cell-ticket { width: 130px; }
}

/* ---------- phones / small tablets ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 45; top: 0; left: 0; width: 280px; transform: translateX(-100%); transition: transform 0.2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open .nav-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(15, 23, 42, 0.3); }
  .topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--white); border-bottom: 1px solid var(--hairline); }
  .page { padding: 18px 16px 32px; }
  .banner { margin: 12px 16px 0; }
  .board { grid-auto-columns: 82vw; }
  .col { max-height: none; }
  .cell-ticket, .cell-prio, .cell-person .person-name { display: none; }
  .cell-person { width: 40px; }
  .fields { grid-template-columns: 88px minmax(0, 1fr); }
  .row2 { grid-template-columns: 1fr; }
  .search, .inline-label .input { max-width: none; width: 100%; }
  .toasts { left: 16px; right: 16px; }
}
