:root {
  color-scheme: light;
  --ink: #151414;
  --muted: #5d5863;
  --bg: #f7f1ea;
  --card: #ffffff;
  --accent: #f0764f;
  --accent-dark: #d45d38;
  --accent-soft: #ffe1d4;
  --teal: #2a8f8d;
  --teal-soft: #d6f0ee;
  --line: #eadfd4;
  --shadow: 0 20px 40px rgba(25, 19, 20, 0.12);
  --radius: 20px;
  --serif: "DM Serif Display", "Times New Roman", serif;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: radial-gradient(circle at top, #fff6ee, #f0ede9 55%, #e8efe9 100%);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3 {
  font-family: var(--serif);
  margin: 0 0 0.35rem;
}

label span {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-family: var(--sans);
  font-size: 0.95rem;
  background: #fffaf6;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #f6b395;
  border-color: transparent;
}

.link {
  color: var(--accent-dark);
  font-weight: 600;
}

.sidebar .link {
  color: #f1c2af;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.sidebar {
  padding: 36px 28px;
  background: #1b1a1f;
  color: #fff;
  display: grid;
  gap: 32px;
}

.brand h1 {
  font-size: 1.9rem;
}

.brand-pill {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 600;
  font-size: 0.8rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  padding: 10px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
}

.nav-link.active,
.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-card {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 12px;
}

.sidebar-footer {
  margin-top: auto;
}

.main {
  padding: 36px clamp(20px, 4vw, 48px) 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-dark);
}

.topbar-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search input {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  min-width: 200px;
  font-family: var(--sans);
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px rgba(240, 118, 79, 0.3);
}

.btn-outline {
  border-color: rgba(255, 255, 255, 0.35);
  background: transparent;
  color: #fff;
}

.btn-ghost {
  border-color: var(--line);
  background: #f5ede6;
  color: var(--ink);
}

.auth {
  width: min(420px, 100%);
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-help {
  font-size: 0.85rem;
  color: var(--muted);
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.alert-error {
  background: #ffe4e4;
  color: #a43838;
}

.alert-success {
  background: #ddf5e8;
  color: #1d6a4b;
}

.alert-warning {
  background: #fff2d2;
  color: #8f5a1b;
}

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

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: rise 0.6s ease forwards;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  margin-top: 6px;
}

.trend {
  font-size: 0.85rem;
  color: var(--muted);
}

.trend.up {
  color: #1a7f5a;
}

.trend.warn {
  color: #b95b23;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  animation: rise 0.7s ease forwards;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.span-2 {
  grid-column: span 2;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

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

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.table-wrap th,
.table-wrap td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.95rem;
}

.table-wrap tr[data-modal-url] {
  cursor: pointer;
}

.table-wrap tr[data-modal-url]:hover {
  background: #f8f1ea;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.tag.ok {
  background: #d7f0e4;
  color: #1f6a4e;
}

.tag.warn {
  background: #ffe3cd;
  color: #a85225;
}

.tag.progress {
  background: #d7e6ff;
  color: #2c4e99;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 16px;
}

.task-list li {
  display: flex;
  gap: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
}

.dot.high { background: #f05f4f; }
.dot.mid { background: #f0b44f; }
.dot.low { background: #33a06f; }

.flow {
  display: grid;
  gap: 12px;
}

.flow div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f6efe8;
}

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

.activity div {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
}

.activity span {
  font-size: 0.8rem;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 18px;
}

.table-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #f1ece5;
  color: var(--muted);
}

.todo-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.todo-form input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: var(--sans);
}

.todo-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.todo-item label {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.95rem;
}

.todo-item[data-modal-url] {
  cursor: pointer;
}

.todo-item input {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
}

.todo-item input:checked + span {
  text-decoration: line-through;
  color: var(--muted);
}

.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: var(--sans);
  background: #fffaf6;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1000;
}

.modal[hidden] {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 12, 20, 0.45);
}

.modal-card {
  position: relative;
  background: #fff;
  width: min(920px, 94vw);
  max-height: 90vh;
  overflow: auto;
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 24px;
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-header {
  margin-bottom: 16px;
}

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

.modal-tabs button {
  border: 1px solid var(--line);
  background: #f5ede6;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.modal-tabs button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.modal-message {
  margin-bottom: 12px;
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .main {
    padding-top: 20px;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .span-2 {
    grid-column: span 1;
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .search input {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions .btn {
    flex: 1;
  }
}
