:root {
  color-scheme: light;
  --bg: #edf3f4;
  --surface: #ffffff;
  --surface-2: #f4f8f8;
  --ink: #1f313b;
  --muted: #71808a;
  --line: #d8e4e3;
  --primary: #22b8aa;
  --primary-dark: #12877d;
  --sidebar: #1fb7a8;
  --sidebar-dark: #128f84;
  --danger: #b42318;
  --warning: #b7791f;
  --info: #2563eb;
  --shadow: 0 12px 28px rgba(25, 47, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

html,
body {
  overflow-x: hidden;
}

.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(34, 184, 170, 0.16), rgba(37, 99, 235, 0.08)),
    var(--bg);
}

.auth-pending .login-screen,
.auth-required .login-screen {
  display: grid;
}

.auth-pending .app-shell,
.auth-required .app-shell {
  display: none;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-brand {
  padding: 18px;
  border-bottom-color: var(--line);
  color: var(--ink);
}

.login-brand .brand-subtitle {
  color: var(--muted);
}

.login-heading {
  display: grid;
  gap: 6px;
  padding: 20px 18px 4px;
}

.login-heading p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.login-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 12px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 20px 14px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-dark) 100%);
  color: #f8ffff;
  box-shadow: 14px 0 28px rgba(13, 95, 89, 0.16);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--sidebar-dark);
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(9, 102, 96, 0.18);
}

.brand > div:last-child {
  min-width: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.brand-subtitle,
.muted,
.panel p,
.topbar p {
  color: var(--muted);
}

.brand-subtitle {
  color: rgba(248, 255, 255, 0.74);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-group-label {
  margin: 12px 8px 2px;
  color: rgba(248, 255, 255, 0.66);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(248, 255, 255, 0.86);
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-weight: 800;
  line-height: 1;
}

.nav-item span:last-child {
  min-width: 0;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.19);
  color: #fff;
}

.nav-item.active .nav-icon {
  background: #ffffff;
  color: var(--sidebar-dark);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  overflow-wrap: anywhere;
}

.sidebar-footer code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.sidebar-footer .muted {
  color: rgba(248, 255, 255, 0.7);
}

.main {
  min-width: 0;
  padding: 20px 24px 24px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar > div:first-child,
.panel-header > div:first-child {
  min-width: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.topbar p,
.panel p {
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-left: 4px solid rgba(34, 184, 170, 0.62);
  min-width: 0;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 14px;
  align-items: start;
}

.directories-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.max-panel {
  max-width: 980px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.detail-panel {
  position: sticky;
  top: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.request-form label:first-child {
  grid-column: 1 / -1;
}

.create-request-form {
  border-bottom: 0;
}

.wide,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

.input,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

.input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 184, 170, 0.16);
  outline: 0;
}

textarea {
  resize: vertical;
}

.compact {
  max-width: 180px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 650;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.button.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(34, 184, 170, 0.2);
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: rgba(34, 184, 170, 0.65);
  color: var(--primary-dark);
}

.button.danger {
  background: #fff1f0;
  border-color: #ffd7d2;
  color: var(--danger);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f7fbfb;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eaf8f6;
}

.cell-title {
  max-width: 320px;
  font-weight: 680;
  overflow-wrap: anywhere;
}

.cell-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
  max-width: 100%;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.muted-pill {
  background: var(--surface-2);
  color: var(--muted);
}

.ok-pill {
  background: #e6f8f4;
  color: #087568;
}

.warn-pill {
  background: #fff4d6;
  color: var(--warning);
}

.info-pill {
  background: #e9f1ff;
  color: var(--info);
}

.danger-pill {
  background: #fff1f0;
  color: var(--danger);
}

.detail-content {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.detail-title > div {
  min-width: 0;
}

.detail-title h2,
.detail-title p {
  overflow-wrap: anywhere;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.meta-item {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f9fcfc;
  min-width: 0;
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.meta-item strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.section {
  display: grid;
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.writeoff-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 8px;
}

.writeoff-form label:first-child,
.writeoff-form label:nth-child(4) {
  grid-column: 1 / -1;
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.cards-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.panel > .form-grid + .form-grid {
  border-top: 1px solid var(--line);
}

.directory-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  min-width: 0;
}

.directory-chips code {
  margin-left: 4px;
  font-size: 11px;
  white-space: normal;
}

.card-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-row:hover,
.card-row.selected {
  border-color: rgba(34, 184, 170, 0.45);
  background: #eaf8f6;
}

.description-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fcfc;
  min-width: 0;
  overflow: hidden;
}

.description-details summary {
  cursor: pointer;
  list-style-position: inside;
  padding: 9px 10px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.description-details p {
  margin: 0;
  padding: 0 10px 10px;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
}

.compact-empty {
  padding: 12px;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.progress-step {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f9fcfc;
  color: var(--muted);
  min-width: 0;
}

.progress-step span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 750;
}

.progress-step strong {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.kanban-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  gap: 14px;
  align-items: start;
}

.kanban-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(238px, 1fr);
  gap: 12px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 2px 10px;
}

.kanban-column {
  min-width: 238px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.kanban-column.drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 184, 170, 0.16), var(--shadow);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7fbfb;
  min-width: 0;
}

.kanban-column-header h2 {
  min-width: 0;
}

.kanban-cards {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 420px;
  padding: 10px;
}

.kanban-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.kanban-card:hover,
.kanban-card.selected {
  border-color: rgba(34, 184, 170, 0.58);
  background: #eaf8f6;
}

.kanban-card.dragging {
  opacity: 0.58;
  border-color: var(--primary);
  box-shadow: 0 12px 22px rgba(34, 184, 170, 0.18);
}

.kanban-card-top,
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.kanban-card-top > *,
.kanban-card-footer > * {
  min-width: 0;
}

.kanban-card-title {
  font-weight: 720;
  line-height: 1.3;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kanban-card-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.kanban-card-actions {
  display: inline-flex;
  gap: 6px;
  flex-shrink: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.icon-button:hover {
  border-color: rgba(34, 184, 170, 0.65);
  color: var(--primary-dark);
}

.kanban-empty {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress-step.done {
  border-color: rgba(34, 184, 170, 0.55);
  background: #eaf8f6;
  color: var(--primary-dark);
}

.progress-step.done span {
  background: var(--primary);
  color: #fff;
}

.code-panel {
  min-height: 240px;
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111820;
  color: #d8e4ee;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17212b;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .split {
    grid-template-columns: 1fr;
  }

  .directories-grid {
    grid-template-columns: 1fr;
  }

  .kanban-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-group-label {
    grid-column: 1 / -1;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    display: grid;
  }

  .topbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .metrics,
  .form-grid,
  .meta-grid,
  .progress-steps,
  .writeoff-form,
  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .sidebar {
    padding: 14px 10px;
  }

  .brand {
    padding-inline: 4px;
  }

  .brand-title {
    font-size: 17px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 12px 10px 16px;
  }

  .topbar {
    padding: 14px;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .topbar-actions .button,
  .topbar-actions .status-pill {
    width: 100%;
  }

  .kanban-board {
    grid-auto-columns: minmax(226px, 78vw);
  }
}
