:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --good: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --chip-bg: #e2e8f0;
  --status-todo: #e5e7eb;
  --status-progress: #fef3c7;
  --status-blocked: #fee2e2;
  --status-done: #d1fae5;
  --status-ordered: #dbeafe;
  --status-paid: #d1fae5;
  --status-unassigned: #fee2e2;
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #f1f5f9;
  color: #0f172a;
  min-height: 100vh;
}

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

body.auth-locked {
  display: block;
}

body.auth-locked .sidebar,
body.auth-locked .content {
  display: none;
}

.auth-gate {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

body.auth-locked .auth-gate {
  display: flex;
}

.auth-card {
  width: min(460px, 100%);
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

/* SIDEBAR */
.sidebar {
  background: var(--bg);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand h1 {
  margin: 0;
  font-size: 1.15rem;
}
.brand p {
  margin: 0.25rem 0 1rem;
  font-size: 0.85rem;
  color: #94a3b8;
}
.project-switcher {
  margin-bottom: 0.75rem;
}
.project-switcher label {
  color: #cbd5e1;
}
.project-switcher select {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.nav-btn {
  background: transparent;
  color: #e2e8f0;
  border: none;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}
.nav-btn:hover {
  background: #1e293b;
}
.nav-btn.active {
  background: var(--accent);
  color: white;
}
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.sidebar-footer button,
.import-label {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
}
.import-label:hover,
.sidebar-footer button:hover {
  background: #334155;
}

/* MAIN */
.content {
  padding: 1.25rem 1.5rem;
  max-width: 100%;
  overflow-x: hidden;
}
.view {
  display: none;
}
.view.active {
  display: block;
}
.view-header h2 {
  margin: 0;
  font-size: 1.4rem;
}
.view-header p {
  margin: 0.15rem 0 1rem;
  color: var(--muted);
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 1rem;
  overflow-x: auto;
}
.card h3 {
  margin-top: 0;
}
.card.danger {
  border-color: #fecaca;
}

/* Grids */
.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.grid-wide {
  display: grid;
  gap: 1rem;
  grid-template-columns: 3fr 1fr;
}
.side-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@media (max-width: 1100px) {
  .grid-wide {
    grid-template-columns: 1fr;
  }
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.form-grid .full {
  grid-column: 1 / -1;
}
label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  color: #334155;
}
input,
select,
textarea,
button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
  background: white;
  color: #0f172a;
}
button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  padding: 0.55rem 0.9rem;
}
button:hover {
  background: var(--accent-hover);
}
button.secondary {
  background: #475569;
}
button.secondary:hover {
  background: #334155;
}
.danger-btn,
.delete-btn {
  background: var(--bad);
}
.danger-btn:hover,
.delete-btn:hover {
  background: #b91c1c;
}
.delete-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
}

.inline-form {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.inline-form input {
  flex: 1;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th,
td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
th {
  background: #f8fafc;
  font-weight: 600;
  color: #334155;
}
tr:hover td {
  background: #f8fafc;
}
td input,
td select {
  width: 100%;
  padding: 0.25rem 0.35rem;
  font-size: 0.85rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  align-items: flex-end;
}
.task-panel {
  display: none;
  margin-top: 0.8rem;
}
.task-panel.active {
  display: block;
}
.task-view-btn.active {
  background: #0f766e;
}
.task-view-btn.active:hover {
  background: #115e59;
}
.gantt-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.gantt-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 30px;
  border-bottom: 1px solid var(--border);
}
.gantt-row:last-child {
  border-bottom: none;
}
.gantt-label {
  padding: 0.35rem 0.5rem;
  background: #f8fafc;
  border-right: 1px solid var(--border);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gantt-track {
  position: relative;
  padding: 0.25rem 0.4rem;
}
.gantt-bar {
  position: absolute;
  top: 5px;
  height: 18px;
  border-radius: 999px;
  font-size: 0.72rem;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}
.gantt-bar.not-started { background: #64748b; }
.gantt-bar.in-progress { background: #d97706; }
.gantt-bar.blocked { background: #dc2626; }
.gantt-bar.done { background: #059669; }

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 0.7rem;
}
.board-col {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  min-height: 180px;
}
.board-col h4 {
  margin: 0;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}
.task-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0.5rem;
  padding: 0.45rem;
  font-size: 0.82rem;
}
.task-card strong {
  display: block;
  margin-bottom: 0.2rem;
}
.task-card-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.totals {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-weight: 600;
  color: #0f172a;
  font-size: 0.9rem;
}
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}
.totals span.bad {
  color: var(--bad);
}
.totals span.good {
  color: var(--good);
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.kpi {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.kpi .label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi .value {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

/* Status pills */
.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.pill-paid {
  background: var(--status-paid);
  color: #065f46;
}
.pill-ordered {
  background: var(--status-ordered);
  color: #1e3a8a;
}
.pill-unassigned {
  background: var(--status-unassigned);
  color: #991b1b;
}
.pill-high {
  background: #fee2e2;
  color: #991b1b;
}
.pill-medium {
  background: #fef3c7;
  color: #92400e;
}
.pill-low {
  background: #e0e7ff;
  color: #3730a3;
}
.pill-bonus {
  background: #ede9fe;
  color: #5b21b6;
}
.pill-done {
  background: var(--status-done);
  color: #065f46;
}
.pill-progress {
  background: var(--status-progress);
  color: #92400e;
}
.pill-todo {
  background: var(--status-todo);
  color: #334155;
}
.pill-blocked {
  background: var(--status-blocked);
  color: #991b1b;
}

/* Chip list (areas/types settings) */
.chip-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.chip-list li {
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}
.chip-list li button {
  background: transparent;
  color: #475569;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}
.chip-list li button:hover {
  color: var(--bad);
}

/* Form actions (shared) */
.form-actions {
  display: flex;
  gap: 0.5rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal-backdrop[hidden] {
  display: none;
}
.modal {
  background: white;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  padding: 1rem 1.25rem 1.25rem;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.modal-header h3 {
  margin: 0;
}
.modal-close {
  background: transparent;
  color: #475569;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 0.4rem;
}
.modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.field-label {
  font-size: 0.82rem;
  color: #334155;
  margin-bottom: 0.3rem;
}
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.35rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.skills-grid label {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #0f172a;
}
.skills-grid input[type="checkbox"] {
  margin: 0;
}
.skills-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.skill-chip {
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
}

/* Responsive */
@media (max-width: 800px) {
  body {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    gap: 0.5rem;
  }
  .sidebar nav {
    flex-direction: row;
  }
  .sidebar-footer {
    flex-direction: row;
  }
  .brand {
    min-width: 140px;
  }
}
@media (max-width: 1000px) {
  .board {
    grid-template-columns: 1fr 1fr;
  }
}
