/* ==========================================================================
   Project Selector — single stylesheet
   Tokens → base → layout → components → pages
   ========================================================================== */

/* TOKENS ---------------------------------------------------------------- */

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #14171c;
  --text-muted: #5d6675;

  --accent: #f59f00;
  --accent-strong: #e67700;
  --accent-text: #241600;
  --accent-soft: rgba(245, 159, 0, 0.14);

  --success: #2b8a3e;
  --success-soft: rgba(43, 138, 62, 0.12);
  --danger: #c92a2a;
  --danger-soft: rgba(201, 42, 42, 0.1);
  --info: #1971c2;
  --info-soft: rgba(25, 113, 194, 0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
  --focus: 0 0 0 3px var(--accent-soft);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1d2129;
    --border: #2a2f39;
    --text: #e8eaef;
    --text-muted: #9aa3b2;
    --accent: #fab005;
    --accent-strong: #ffc53d;
    --accent-soft: rgba(250, 176, 5, 0.14);
    --success: #51cf66;
    --success-soft: rgba(81, 207, 102, 0.12);
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, 0.12);
    --info: #4dabf7;
    --info-soft: rgba(77, 171, 247, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --border: #2a2f39;
  --text: #e8eaef;
  --text-muted: #9aa3b2;
  --accent: #fab005;
  --accent-strong: #ffc53d;
  --accent-soft: rgba(250, 176, 5, 0.14);
  --success: #51cf66;
  --success-soft: rgba(81, 207, 102, 0.12);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --info: #4dabf7;
  --info-soft: rgba(77, 171, 247, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* BASE ------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.25;
  letter-spacing: -0.015em;
}

a {
  color: inherit;
}

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

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.muted {
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* LAYOUT ---------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.main {
  flex: 1;
  padding-top: 40px;
  padding-bottom: 64px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-head h1 {
  font-size: 28px;
}

.page-head p {
  color: var(--text-muted);
  margin-top: 4px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

@media (max-width: 860px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* HEADER ---------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.nav__link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}

.nav__link:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav__link[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
}

.header-actions .menu-toggle,
.nav__link--mobile {
  display: none;
}

@media (max-width: 760px) {
  .site-header__inner {
    flex-wrap: wrap;
    row-gap: 4px;
    height: auto;
    min-height: 60px;
    padding-top: 10px;
    padding-bottom: 10px;
    gap: 12px;
  }

  .header-actions .menu-toggle {
    display: inline-flex;
  }

  .header-actions {
    gap: 2px;
  }

  .header-actions .btn--icon {
    width: 36px;
  }

  .header-actions .auth-link {
    display: none;
  }

  .nav__link--mobile {
    display: block;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    display: none;
    padding-bottom: 6px;
  }

  .site-header.is-open .nav {
    display: flex;
  }

  .user-chip span:last-child {
    display: none;
  }

  .user-chip {
    padding: 4px;
  }
}

@media (max-width: 400px) {
  .brand__name {
    display: none;
  }
}

/* BUTTONS --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
}

.btn--danger {
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger-soft);
  border-color: transparent;
}

.btn--success {
  color: var(--success);
}

.btn--success:hover {
  background: var(--success-soft);
  border-color: transparent;
}

.btn--sm {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.btn--icon {
  width: 40px;
  padding: 0;
}

.btn--icon.btn--sm {
  width: 32px;
}

.btn--block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.inline-form {
  display: inline-flex;
}

/* Theme toggle shows the icon of the theme you would switch to */
.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

/* CARDS ----------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card--pad {
  padding: 24px;
}

.card h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.card__subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.project-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.project-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.project-card h3 {
  font-size: 16px;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.project-card p {
  color: var(--text-muted);
  font-size: 14px;
  flex: 1;
  overflow-wrap: anywhere;
}

.project-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 47px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.project-card__actions {
  display: flex;
  gap: 4px;
}

/* BADGES ---------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge--accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

/* FORMS ----------------------------------------------------------------- */

.form {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
}

.field__hint {
  font-size: 12px;
  color: var(--text-muted);
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.input {
  height: auto;
  min-height: 110px;
  padding: 10px 12px;
  resize: vertical;
}

.input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.input:user-invalid {
  border-color: var(--danger);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* AUTH ------------------------------------------------------------------ */

.auth {
  max-width: 420px;
  margin: 24px auto 0;
}

.auth__head {
  text-align: center;
  margin-bottom: 24px;
}

.auth__head h1 {
  font-size: 26px;
}

.auth__head p {
  color: var(--text-muted);
  margin-top: 6px;
}

.auth__foot {
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth__foot a {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}

/* TABLES ---------------------------------------------------------------- */

.table-wrap {
  position: relative;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 10px 16px;
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:hover td {
  background: color-mix(in srgb, var(--surface-2) 50%, transparent);
}

.table .num {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table__person {
  font-weight: 600;
}

.table__sub {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}

/* TABS (profile assignments) -------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 10px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* EMPTY STATE ----------------------------------------------------------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty .icon {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}

.empty strong {
  color: var(--text);
}

/* TOASTS ---------------------------------------------------------------- */

.toasts {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: toast-in 0.25s ease-out;
}

.toast--error {
  border-left-color: var(--danger);
}

.toast > .icon {
  margin-top: 1px;
  color: var(--success);
}

.toast--error > .icon {
  color: var(--danger);
}

.toast p {
  flex: 1;
}

.toast button {
  display: grid;
  place-items: center;
  padding: 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s, transform 0.2s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* HOME ------------------------------------------------------------------ */

.hero {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 18px;
  padding: 48px 0 56px;
}

.hero h1 {
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: -0.03em;
  max-width: 720px;
}

.hero h1 span {
  color: var(--accent-strong);
}

.hero p {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 560px;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.feature {
  padding: 22px;
}

.feature__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-bottom: 14px;
}

.feature h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.feature p {
  color: var(--text-muted);
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.stat__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.stat__icon--success {
  background: var(--success-soft);
  color: var(--success);
}

.stat__icon--info {
  background: var(--info-soft);
  color: var(--info);
}

.stat__value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}

.stat__label {
  font-size: 13px;
  color: var(--text-muted);
}

/* FOOTER ---------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  font-size: 13px;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

a.feature {
  text-decoration: none;
  transition: border-color 0.15s;
}

a.feature:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.auth--wide {
  max-width: 560px;
}
