:root {
  --bg: #09091a;
  --bg-2: #06060f;
  --surface: #101022;
  --surface-2: #17172e;
  --line: rgba(139, 147, 255, 0.14);
  --text: #eef0ff;
  --muted: #8f93b8;
  --blue: #2563eb;
  --violet: #7c3aed;
  --lilac: #a78bfa;
  --grad: linear-gradient(120deg, #2563eb, #7c3aed);
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand span { font-size: 11.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }
#nav { display: grid; gap: 4px; }
#nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  font-size: 15.5px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 500;
}
#nav a i { font-style: normal; width: 22px; text-align: center; font-size: 18px; opacity: 0.95; }
#nav a svg { width: 19px; height: 19px; flex: none; opacity: 0.9; }
#nav a:hover { color: var(--text); background: rgba(139,147,255,0.07); }
#nav a.active {
  color: #fff;
  background: linear-gradient(120deg, rgba(37,99,235,0.28), rgba(124,58,237,0.28));
  box-shadow: inset 0 0 0 1px rgba(139,147,255,0.25);
}
.sidebar-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); padding: 10px 8px 0; }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 5px; }

/* ---------- Main view ---------- */
.view { padding: 26px 30px 60px; max-width: 1180px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 27px; font-weight: 800; letter-spacing: -0.01em; }
.page-head .sub { color: var(--muted); font-size: 15px; margin-top: 2px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: none; cursor: pointer;
  background: var(--grad);
  color: #fff; font-weight: 700; font-size: 15px;
  padding: 13px 20px; border-radius: 10px;
  transition: filter .15s ease, transform .1s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { background: rgba(239,68,68,0.15); color: #fda4af; box-shadow: inset 0 0 0 1px rgba(239,68,68,0.3); }

/* ---------- Cards & grids ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card.stat b { font-size: 31px; font-weight: 800; display: block; margin-top: 2px; }
.card.stat .label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
.card.stat .hint { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.card.stat.good b { color: var(--green); }
.card.stat.warn b { color: var(--amber); }
.card.stat.bad b { color: var(--red); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel h2 { font-size: 17.5px; font-weight: 700; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.panel h2 .more { font-size: 12.5px; color: var(--lilac); font-weight: 600; cursor: pointer; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Lists / tables ---------- */
.rowlist { display: grid; gap: 8px; }
.rowitem {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color .12s ease;
}
.rowitem:hover { border-color: rgba(139,147,255,0.3); }
.rowitem .grow { flex: 1; min-width: 0; }
.rowitem b { font-size: 15.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rowitem .meta { color: var(--muted); font-size: 13.5px; }
.empty { color: var(--muted); font-size: 13.5px; padding: 14px 4px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 14px 10px; border-bottom: 1px solid rgba(139,147,255,0.07); }
.tbl tr:hover td { background: rgba(139,147,255,0.04); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700;
  padding: 4px 11px; border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.chip .cdot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.blue { background: rgba(37,99,235,0.16); color: #93b4f8; }
.chip.violet { background: rgba(124,58,237,0.18); color: #c4b5fd; }
.chip.green { background: rgba(34,197,94,0.14); color: #86efac; }
.chip.amber { background: rgba(245,158,11,0.15); color: #fcd34d; }
.chip.red { background: rgba(239,68,68,0.15); color: #fda4af; }
.chip.gray { background: rgba(143,147,184,0.13); color: var(--muted); }
.client-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--grad);
  color: #fff; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}

/* ---------- Client grid ---------- */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.client-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: transform .13s ease, border-color .13s ease;
}
.client-card:hover { transform: translateY(-3px); border-color: rgba(139,147,255,0.4); }
.client-card .top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.client-card .logo {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; color: #fff;
}
.client-card b { font-size: 15px; }
.client-card .ind { font-size: 12px; color: var(--muted); }
.client-card .stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.client-card .stats b { display: block; font-size: 15px; color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 15px;
  padding: 11px 16px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--violet); }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-head b { font-size: 16px; min-width: 150px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 4px 0; }
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  min-height: 92px;
  padding: 6px;
  font-size: 12px;
}
.cal-cell.other { opacity: 0.35; }
.cal-cell.today { border-color: var(--violet); box-shadow: inset 0 0 0 1px var(--violet); }
.cal-cell .d { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.cal-cell.today .d { color: var(--lilac); font-weight: 700; }
.cal-evt {
  border-radius: 6px;
  padding: 3px 6px;
  margin-bottom: 3px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(215px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.kcol { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 300px; }
.kcol.dragover { border-color: var(--lilac); background: rgba(124,58,237,0.06); }
.kcol h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; }
.kcard {
  background: var(--surface-2);
  border: 1px solid rgba(139,147,255,0.1);
  border-radius: 9px;
  padding: 13px 14px;
  margin-bottom: 9px;
  cursor: grab;
  font-size: 14px;
}
.kcard:hover { border-color: rgba(139,147,255,0.35); }
.kcard b { display: block; font-size: 14.5px; margin-bottom: 5px; }
.kcard .krow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kcard.dragging { opacity: 0.4; }

/* ---------- Forms / modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4,4,12,0.72);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid rgba(139,147,255,0.25);
  border-radius: 14px;
  width: min(520px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
}
.modal h2 { font-size: 17px; margin-bottom: 18px; }
.modal form { display: grid; gap: 13px; }
.f-row { display: grid; gap: 5px; }
.f-row label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.f-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 12px 14px;
  font-size: 15.5px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--violet); }
textarea { min-height: 80px; resize: vertical; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.crew-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.crew-checks label {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text); text-transform: none; letter-spacing: 0;
}
.crew-checks input { width: auto; }

/* ---------- Comments ---------- */
.comments { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.comment { display: flex; gap: 9px; margin-bottom: 10px; font-size: 13px; }
.comment .body { background: var(--surface-2); border-radius: 9px; padding: 8px 11px; flex: 1; }
.comment .who { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.comment-form { display: flex; gap: 8px; }
.comment-form input { flex: 1; }

/* ---------- Charts ---------- */
.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend .key { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: grid; gap: 8px; }
.toast {
  background: var(--surface-2);
  border: 1px solid rgba(139,147,255,0.3);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13.5px;
  animation: pop .18s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- Attendance ---------- */
.att-btns { display: flex; gap: 6px; }
.att-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  font-weight: 800; font-size: 13px;
  cursor: pointer;
  transition: transform .1s ease;
}
.att-btn:hover { transform: scale(1.08); color: var(--text); }
.att-btn.on.present { background: rgba(34,197,94,0.2); color: #86efac; border-color: #22c55e; }
.att-btn.on.half { background: rgba(245,158,11,0.2); color: #fcd34d; border-color: #f59e0b; }
.att-btn.on.leave { background: rgba(37,99,235,0.2); color: #93b4f8; border-color: #2563eb; }
.att-btn.on.absent { background: rgba(239,68,68,0.2); color: #fda4af; border-color: #ef4444; }

/* ---------- Messages thread ---------- */
.thread {
  max-height: 380px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 4px 2px 14px;
  margin-bottom: 12px;
}
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 13px;
  font-size: 13.5px;
}
.bubble.mine {
  background: linear-gradient(120deg, rgba(37,99,235,0.32), rgba(124,58,237,0.32));
  border-radius: 14px 14px 4px 14px;
}
.bubble .who { font-size: 11px; font-weight: 700; color: var(--lilac); margin-bottom: 3px; }
.bubble .when { font-size: 10.5px; color: var(--muted); margin-top: 4px; text-align: right; }

/* ---------- Client portal ---------- */
body.portal-mode .sidebar { display: none; }
body.portal-mode .layout { grid-template-columns: 1fr; }
body.portal-mode .view { max-width: 860px; margin: 0 auto; }
.portal-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.portal-brand { display: flex; align-items: center; gap: 14px; }
.portal-brand img {
  width: 74px; height: 74px;
  object-fit: cover;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}
.portal-brand h1 { font-size: 24px; }
.p-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--lilac); }
.portal-hero { background: linear-gradient(130deg, rgba(37,99,235,0.16), rgba(124,58,237,0.16)); }
.portal-work { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.portal-work h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }
.portal-work .rowitem { margin-bottom: 8px; }
.portal-foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 10px 0 30px; }

.navbadge {
  margin-left: auto;
  background: var(--grad);
  color: #fff;
  font-size: 11px; font-weight: 800;
  min-width: 20px; height: 20px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 80vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; text-align: center;
}
.login-logo {
  width: 110px; height: 110px;
  object-fit: cover;
  border-radius: 22px;
  background: #fff;
  border: 1px solid var(--line);
}
.login-wrap h1 { font-size: 26px; }
.login-box {
  display: grid; gap: 10px;
  width: min(340px, 90vw);
  margin-top: 8px;
}
.login-box input { text-align: center; font-size: 17px; }

/* ---------- Media drafts & approvals ---------- */
.media-el {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.media-preview { margin-top: 8px; display: grid; gap: 6px; }
.media-preview .media-el { max-height: 200px; }
.p-content-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  display: grid;
  gap: 8px;
}
.p-content-card .rowitem { background: transparent; padding: 4px 6px; }
.approve-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 6px 4px; }
@media (max-width: 700px) { .portal-work { grid-template-columns: 1fr; } }
.filters select { width: auto; min-width: 150px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; gap: 8px; }
  #nav { display: flex; }
  .brand div, .sidebar-foot { display: none; }
  .view { padding: 18px 14px 50px; }
}
