:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #cfd4da;
  --text: #16191d;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 40px rgba(16, 24, 40, .16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101214;
    --surface: #17191c;
    --surface-2: #1d2024;
    --border: #2a2e33;
    --border-strong: #3a3f45;
    --text: #e8eaed;
    --muted: #949ba4;
    --accent: #5b8def;
    --accent-soft: #1b2436;
    --danger: #f87171;
    --danger-soft: #2a1a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=search], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
textarea { resize: vertical; min-height: 84px; }

.row { display: grid; gap: 12px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ------------------------------------------------------------------ login */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

.alert {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.alert:empty { display: none; }

/* ------------------------------------------------------------------ shell */

.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -.01em; margin-right: 4px; }
.brand span { color: var(--muted); font-weight: 400; }

.month-nav { display: flex; align-items: center; gap: 6px; }
.month-label {
  min-width: 158px;
  text-align: center;
  font-weight: 600;
  text-transform: capitalize;
}
.spacer { flex: 1; }

.account { position: relative; }
.account-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}
.account-btn:hover { background: var(--surface-2); }

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}
.avatar-lg { width: 32px; height: 32px; font-size: 13px; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  z-index: 40;
}
.menu[hidden] { display: none; }
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }

.main { flex: 1; display: flex; min-height: 0; }

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  width: 232px;
  flex: none;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}
.side-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 9px;
}
.side-block + .side-block { margin-top: 22px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
}
.legend-item:hover { background: var(--surface-2); }
.legend-item input { margin: 0; accent-color: var(--accent); }
.legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-count { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-item.off .legend-name { color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

.stat { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.stat span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- calendar */

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 16px; gap: 12px; overflow: auto; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 230px; }
.toolbar select { width: auto; min-width: 150px; }

.calendar[hidden] { display: none; }
.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 560px;
}
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.weekdays div {
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(104px, 1fr);
}
.cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 5px 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  position: relative;
}
.cell:nth-child(7n) { border-right: 0; }
.cell.outside { background: var(--surface-2); }
.cell.outside .cell-num { color: var(--muted); opacity: .6; }
.cell.weekend:not(.outside) { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }

.cell-head { display: flex; align-items: center; justify-content: space-between; min-height: 22px; }
.cell-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-variant-numeric: tabular-nums;
}
.cell.today .cell-num { background: var(--accent); color: #fff; }
.cell-add {
  opacity: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 5px;
}
.cell:hover .cell-add { opacity: 1; }
.cell-add:hover { background: var(--accent-soft); color: var(--accent); }
.cell-add:focus-visible { opacity: 1; }

.pill {
  --c: var(--accent);
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--c);
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  padding: 3px 6px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.32;
  overflow: hidden;
}
.pill:hover { background: color-mix(in srgb, var(--c) 22%, transparent); }
.pill strong {
  display: block;
  font-weight: 600;
  color: var(--c);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.is-done span { text-decoration: line-through; opacity: .72; }
.pill.is-blocked strong::after { content: ' ⛔'; }

.more {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  text-align: left;
  padding: 1px 6px;
  border-radius: 4px;
}
.more:hover { background: var(--surface-2); color: var(--text); }

.empty-note { color: var(--muted); font-size: 13px; padding: 4px 2px; }

/* ----------------------------------------------------------------- modals */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.modal-wide { max-width: 680px; }
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 14px 14px;
  flex-wrap: wrap;
}
.modal-foot .left { margin-right: auto; }
.close { margin-left: auto; }

/* ------------------------------------------------------------ detail view */

.detail-title { margin: 0; font-size: 17px; line-height: 1.35; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  font-size: 12px;
  background: var(--surface-2);
}
.chip-user { --c: var(--accent); border-color: color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c); font-weight: 600; }
.badge { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.in_progress { background: #fef3c7; color: #92400e; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.blocked { background: #fee2e2; color: #991b1b; }
@media (prefers-color-scheme: dark) {
  .badge.in_progress { background: #3a2f10; color: #fcd34d; }
  .badge.done { background: #14301f; color: #86efac; }
  .badge.blocked { background: #3a1a1a; color: #fca5a5; }
}

.detail-grid { display: grid; grid-template-columns: 96px 1fr; gap: 7px 14px; font-size: 13px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }
.detail-text {
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 13px;
}

/* ------------------------------------------------------------- users list */

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: 0; }
.user-row .who { flex: 1; min-width: 0; }
.user-row .who b { display: block; font-size: 13px; }
.user-row .who small { color: var(--muted); font-size: 11.5px; }
.tag {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}
.tag.off { background: var(--surface-2); color: var(--muted); }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  outline-offset: 2px;
}
.swatch[aria-pressed="true"] { border-color: var(--text); }

details.section > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 0;
  list-style: none;
}
details.section > summary::before { content: '▸ '; color: var(--muted); }
details.section[open] > summary::before { content: '▾ '; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}
.toast[hidden] { display: none; }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  .sidebar { display: none; }
  .sidebar.open {
    display: block;
    position: fixed;
    inset: 52px 0 0 0;
    width: auto;
    z-index: 30;
    border-right: 0;
  }
  .menu-toggle { display: inline-flex !important; }
  .grid { grid-auto-rows: minmax(84px, auto); }
  .content { padding: 10px; }
  .month-label { min-width: 120px; font-size: 13px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
}
.menu-toggle { display: none; }

.swatch[disabled] { cursor: not-allowed; opacity: .32; }
.swatch[disabled]::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  transform: rotate(-45deg);
  border-radius: 2px;
}

/* ---------------------------------------------------------- vedere de listă */

.segmented { display: flex; }
.segmented .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.segmented .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.segmented .btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  z-index: 1;
}

.agenda {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.agenda[hidden] { display: none; }

.agenda-date {
  padding: 8px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
.agenda-date.is-today { color: var(--accent); }

.agenda-item {
  --c: var(--accent);
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--c);
  background: transparent;
  cursor: pointer;
}
.agenda-item:hover { background: color-mix(in srgb, var(--c) 9%, transparent); }
.agenda-item .body { flex: 1; min-width: 0; }
.agenda-item .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-item.is-done .t { text-decoration: line-through; opacity: .7; }
.agenda-item .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-item .s b { color: var(--c); font-weight: 650; }

/* ------------------------------------------------- overview stadiu proiecte */

.ov-group + .ov-group { margin-top: 14px; }

.ov-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.ov-head .n { color: var(--muted); font-weight: 600; letter-spacing: 0; }
.ov-head.in_progress { color: #b45309; }
.ov-head.blocked { color: #b91c1c; }
.ov-head.done { color: #15803d; }
@media (prefers-color-scheme: dark) {
  .ov-head.in_progress { color: #fcd34d; }
  .ov-head.blocked { color: #fca5a5; }
  .ov-head.done { color: #86efac; }
}

.ov-item {
  --c: var(--accent);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--c);
  border-radius: 4px;
  background: transparent;
  padding: 5px 7px;
  cursor: pointer;
  margin-bottom: 3px;
}
.ov-item:hover { background: color-mix(in srgb, var(--c) 12%, transparent); }
.ov-item[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 18%, transparent); }
.ov-item .body { flex: 1; min-width: 0; }
.ov-item .p {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-item.done .p { opacity: .75; }
.ov-item .s {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ov-item .who { color: var(--c); font-weight: 600; }

/* ----------------------------------------------------------------- setări */

.set-section { display: flex; flex-direction: column; gap: 14px; }
.set-section + .set-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.set-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.set-identity { display: flex; align-items: center; gap: 11px; }

.set-preview {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.set-preview .pill { cursor: default; max-width: 240px; }
.set-preview .pill:hover { background: color-mix(in srgb, var(--c) 12%, transparent); }

.set-actions { display: flex; justify-content: flex-end; }
