:root {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #101827;
  --surface-strong: #111827;
  --surface-raised: #172033;
  --ink: #e5edf7;
  --muted: #9aa8ba;
  --quiet: #7f8da2;
  --line: #334155;
  --line-soft: #26364d;
  --accent: #24a77a;
  --accent-strong: #5eead4;
  --accent-soft: #12372d;
  --warn: #f59e0b;
  --steel: #d8dee8;
  --blue: #60a5fa;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(36, 167, 122, 0.75);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand-block,
.topbar-actions,
.project-meta,
.project-footer,
.detail-header,
.summary-row,
.row-actions,
.section-heading {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid #1f8f6c;
  background: var(--accent-soft);
  color: #bcf7df;
  font-weight: 700;
  font-size: 13px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 800;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-block span,
.section-heading span,
.project-main span,
.project-meta,
.project-footer,
.detail-header p,
.summary-row span,
.package-body span,
.package-body small,
.empty-state span,
.settings-strip span {
  color: var(--muted);
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-box {
  width: min(360px, 44vw);
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--muted);
}

.search-box input,
.settings-strip input,
.upload-grid input,
.upload-grid select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.upload-grid select {
  color-scheme: dark;
}

.search-box input::placeholder,
.upload-grid input::placeholder,
.settings-strip input::placeholder {
  color: var(--quiet);
}

.command-button,
.icon-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  color: #d8dee8;
  white-space: nowrap;
}

.command-button {
  padding: 0 11px;
  font-size: 13px;
  font-weight: 700;
}

.command-button:hover,
.icon-button:hover {
  border-color: #3d516e;
  background: #1c2840;
}

.command-button.primary {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #bcf7df;
}

.command-button.primary:hover {
  background: #164a3d;
}

.command-button.danger-solid {
  border-color: #b91c1c;
  background: #7f1d1d;
  color: #fee2e2;
}

.command-button.danger-solid:hover {
  border-color: #ef4444;
  background: #991b1b;
}

.icon-button.danger {
  color: #f3a6a6;
}

.icon-button.danger:hover {
  border-color: #7f2d2d;
  background: rgba(127, 29, 29, 0.35);
  color: #fecaca;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 8px minmax(360px, var(--detail-width, 520px));
  gap: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.layout-splitter {
  width: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  background:
    linear-gradient(90deg, transparent 0 2px, rgba(96, 165, 250, 0.24) 2px 3px, transparent 3px 5px, rgba(96, 165, 250, 0.24) 5px 6px, transparent 6px),
    #0d1524;
  cursor: col-resize;
  touch-action: none;
}

.layout-splitter:hover,
.layout-splitter:focus-visible {
  border-color: #3d516e;
  background:
    linear-gradient(90deg, transparent 0 2px, var(--accent) 2px 3px, transparent 3px 5px, var(--accent) 5px 6px, transparent 6px),
    #122033;
}

.is-resizing-layout,
.is-resizing-layout * {
  cursor: col-resize !important;
  user-select: none;
}

.projects-region,
.detail-region,
.settings-strip {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-strong);
}

.projects-region,
.detail-region {
  min-height: 0;
  padding: 10px;
  overflow: auto;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 28px;
}

.section-heading.compact {
  margin-bottom: 10px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}

.project-tile {
  min-height: 206px;
  display: grid;
  grid-template-rows: auto 58px auto auto auto;
  gap: 8px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
  color: var(--ink);
}

.project-tile:hover,
.project-tile.selected {
  border-color: var(--accent);
  background: var(--surface-raised);
  box-shadow: none;
}

.project-status,
.state-pill,
.eyebrow {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1;
}

.project-status,
.state-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.state-pill.subtle {
  background: #202b42;
  color: var(--steel);
}

.eyebrow {
  margin-bottom: 6px;
  display: inline-block;
  background: #202b42;
  color: var(--quiet);
}

.project-visual {
  display: grid;
  align-content: end;
  gap: 8px;
  padding: 10px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.12) 1px, transparent 1px),
    linear-gradient(0deg, rgba(148, 163, 184, 0.1) 1px, transparent 1px),
    #0f172a;
  background-size: 24px 24px;
}

.project-visual span {
  height: 8px;
  width: var(--bar);
  border-radius: 99px;
  background: var(--blue);
}

.project-visual span:nth-child(2) {
  background: var(--accent);
}

.project-visual span:nth-child(3) {
  background: var(--warn);
}

.project-main {
  display: grid;
  gap: 4px;
}

.project-main strong {
  font-size: 16px;
}

.project-meta,
.project-footer {
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.detail-region {
  display: grid;
  align-content: start;
  gap: 16px;
}

.detail-header {
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.summary-row div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
}

.summary-row strong {
  font-size: 17px;
}

.project-file-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
}

.project-file-summary div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.project-file-summary strong,
.project-file-summary span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-file-summary span {
  color: var(--muted);
  font-size: 13px;
}

.upload-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.edit-panel {
  display: grid;
  gap: 16px;
}

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

.upload-grid label,
.settings-strip label {
  display: grid;
  gap: 6px;
}

.upload-grid label {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--surface-raised);
}

.upload-grid label span {
  color: var(--muted);
  font-size: 12px;
}

.upload-grid input[type="file"] {
  color: var(--muted);
}

.upload-grid input[type="file"]::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202b42;
  color: #d8dee8;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.upload-progress {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f172a;
}

.upload-progress-head,
.upload-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upload-progress-head strong {
  font-size: 13px;
}

.upload-progress-head span,
.upload-progress-meta {
  color: var(--muted);
  font-size: 12px;
}

.upload-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #0b1220;
  border: 1px solid var(--line-soft);
}

.upload-progress-track span {
  height: 100%;
  min-width: 8px;
  display: block;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(94, 234, 212, 0.2), rgba(36, 167, 122, 0.95)),
    var(--accent);
  transition: width 180ms ease;
}

.upload-progress-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-input {
  grid-column: 1 / -1;
}

.package-list {
  display: grid;
  gap: 10px;
}

.package-row {
  min-height: 78px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.package-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid #1f8f6c;
  background: var(--accent-soft);
  color: #bcf7df;
  font-size: 12px;
  font-weight: 700;
}

.package-body {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.package-body span,
.package-body small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-storage {
  color: #7dd3bc;
}

.row-actions {
  gap: 6px;
}

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

.empty-state {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 104px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  background: rgba(15, 23, 42, 0.35);
}

.empty-state.large {
  min-height: 300px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(4px);
}

.confirm-dialog {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.confirm-header {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.confirm-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #7f2d2d;
  border-radius: 6px;
  background: rgba(127, 29, 29, 0.35);
  color: #fecaca;
  font-weight: 800;
}

.confirm-dialog h2 {
  margin-bottom: 6px;
}

.confirm-dialog p {
  color: var(--muted);
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-strip {
  margin: 0;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
  border-width: 1px 0 0;
}

.settings-strip label {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
}

@media (max-width: 980px) {
  .topbar,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .search-box {
    width: 100%;
  }

  .dashboard-layout {
    display: grid;
    overflow: auto;
  }

  .layout-splitter {
    display: none;
  }

  .package-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .package-row .state-pill,
  .row-actions {
    grid-column: 2;
  }

  .row-actions {
    justify-content: start;
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .dashboard-layout,
  .settings-strip {
    margin: 0;
    padding: 10px;
  }

  .dashboard-layout {
    gap: 10px;
  }

  .summary-row,
  .upload-grid,
  .settings-strip {
    grid-template-columns: 1fr;
  }

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

  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }
}
