:root {
  --navy-950: #062833;
  --navy-900: #003647;
  --navy-800: #06495c;
  --red-700: #a90031;
  --red-600: #c40038;
  --red-100: #fde8ee;
  --surface: #ffffff;
  --surface-muted: #f2f6f8;
  --surface-hover: #e8f0f3;
  --line: #d4e0e4;
  --ink: #17323c;
  --muted: #63777f;
  --success: #17633a;
  --warning: #765600;
  --danger: #842029;
  --sidebar-width: 248px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 4px 14px rgb(15 47 57 / 8%);
  --shadow-md: 0 10px 30px rgb(15 47 57 / 12%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color: var(--ink);
  background: var(--surface-muted);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  margin: 0;
}

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

a {
  color: var(--navy-800);
}

a:hover {
  color: var(--red-700);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid rgb(196 0 56 / 35%);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--red-600);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  color: #fff;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  box-shadow: 4px 0 20px rgb(0 24 32 / 15%);
}

.sidebar-brand {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid rgb(255 255 255 / 10%);
}

.brand {
  display: flex;
  align-items: center;
}

.brand img {
  display: block;
  width: 126px;
  max-height: 36px;
  object-fit: contain;
}

.sidebar-product {
  padding-left: 10px;
  border-left: 1px solid rgb(255 255 255 / 25%);
  color: rgb(255 255 255 / 72%);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  overflow-y: auto;
}

.nav-section {
  margin: 18px 10px 5px;
  color: rgb(255 255 255 / 55%);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-section:first-child {
  margin-top: 0;
}

.sidebar-nav a {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgb(255 255 255 / 78%);
  font-weight: 650;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease;
}

.sidebar-nav a:hover {
  color: #fff;
  background: rgb(255 255 255 / 9%);
}

.sidebar-nav a.active {
  color: #fff;
  background: var(--red-600);
  box-shadow: 0 5px 14px rgb(113 0 32 / 30%);
}

.nav-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  font-size: 17px;
}

.app-main {
  display: flex;
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  flex-direction: column;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.topbar-title {
  color: var(--navy-900);
  font-size: 17px;
  font-weight: 800;
}

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

.topbar-actions a,
.nav-button {
  min-height: 40px;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--navy-900);
  background: transparent;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.topbar-actions a:hover,
.topbar-actions a[aria-current="page"],
.nav-button:hover {
  color: var(--navy-900);
  background: var(--surface-hover);
}

.topbar-actions form {
  margin: 0;
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--navy-900);
  background: var(--surface);
  font-size: 22px;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
}

.container {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 30px 28px 46px;
  flex: 1;
}

.guest-container {
  width: min(460px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 16px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

h1,
h2,
h3 {
  margin-top: 0;
  color: var(--navy-900);
  line-height: 1.25;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(25px, 3vw, 34px);
}

h2 {
  margin-bottom: 14px;
  font-size: 21px;
}

p {
  margin-top: 0;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.card {
  display: block;
  margin: 16px 0;
  padding: 22px;
  border: 1px solid rgb(212 224 228 / 75%);
  border-radius: var(--radius-lg);
  color: inherit;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.narrow {
  max-width: 560px;
}

.login-card {
  margin: 6vh auto;
  box-shadow: var(--shadow-md);
}

.login-card > img {
  display: block;
  width: 220px;
  max-width: 100%;
  margin: 0 auto 24px;
}

.qr {
  width: 220px;
  max-width: 100%;
}

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

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

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

label {
  display: block;
  color: var(--navy-900);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid #bdcdd3;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--navy-800);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(6 73 92 / 15%);
}

input:disabled,
input:read-only,
textarea:disabled,
textarea:read-only,
select:disabled {
  color: var(--muted);
  background: var(--surface-muted);
}

textarea {
  resize: vertical;
}

.check {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
}

.check input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--navy-900);
  background: #e5edf0;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, box-shadow .15s ease, transform .1s ease;
}

.btn:hover {
  color: var(--navy-900);
  background: #d6e3e7;
}

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

.btn-primary {
  color: #fff;
  background: var(--red-600);
}

.btn-primary:hover {
  color: #fff;
  background: var(--red-700);
}

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

.btn-danger:hover {
  color: #fff;
  background: #681825;
}

.full {
  width: 100%;
  margin-top: 12px;
}

.muted {
  color: var(--muted);
  font-weight: 400;
}

.alert {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #b9dfc8;
  border-radius: var(--radius-sm);
  color: var(--success);
  background: #e4f5ea;
}

.alert-danger,
.alert-error {
  border-color: #efb8bd;
  color: var(--danger);
  background: #fbe5e7;
}

.alert-warning {
  border-color: #ead48c;
  color: var(--warning);
  background: #fff6d8;
}

.alert-success {
  border-color: #b9dfc8;
  color: var(--success);
  background: #e4f5ea;
}

.table-wrap {
  max-width: 100%;
  padding: 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 15px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #fff;
  background: var(--navy-900);
  font-size: 13px;
  letter-spacing: .01em;
  white-space: nowrap;
}

th:first-child {
  border-top-left-radius: var(--radius-md);
}

th:last-child {
  border-top-right-radius: var(--radius-md);
}

td {
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f7fafb;
}

.search {
  display: flex;
  gap: 10px;
  max-width: 680px;
  margin-bottom: 18px;
}

.search input {
  margin: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
  max-width: none;
  align-items: end;
}

.filter-grid input,
.filter-grid select {
  margin-top: 6px;
}

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

.filter-actions {
  display: flex;
  gap: 10px;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dfe3ea);
  border-radius: 12px;
  padding: 18px;
}

.stat-card span,
.plain-list span {
  color: var(--muted, #667085);
  display: block;
  font-size: .875rem;
}

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

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

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li {
  border-bottom: 1px solid var(--border, #dfe3ea);
  padding: 10px 0;
}

.plain-list li:last-child {
  border-bottom: 0;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.grand-total {
  margin-top: 16px;
  color: var(--red-600);
  font-size: 20px;
  font-weight: 800;
  text-align: right;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}

.project-card {
  margin: 0;
  transition: box-shadow .15s ease, transform .15s ease;
}

.project-card:hover {
  color: inherit;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--navy-900);
  background: var(--surface-hover);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.scene {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.scene .row input {
  flex: 1;
}

.scene-add {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.inline {
  display: inline-block;
  margin-top: 8px;
}

video {
  width: 100%;
  max-height: 580px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: #000;
}

.export-scenes {
  display: grid;
  gap: 0.8rem;
  padding-left: 1.5rem;
}

.export-scenes > li {
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.clip-preview video {
  max-height: 260px;
  margin-top: 0.65rem;
}

.export-stage {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
}

progress {
  width: min(180px, 100%);
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--navy-900);
  background: var(--surface-hover);
}

.preserve {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

details > summary {
  margin-bottom: 14px;
  color: var(--navy-900);
  font-weight: 750;
  cursor: pointer;
}

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

@media (max-width: 959px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .sidebar {
    transform: translateX(-105%);
    transition: transform .2s ease;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 25;
    inset: 0;
    display: block;
    border: 0;
    background: rgb(0 24 32 / 55%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }

  .sidebar-open {
    overflow: hidden;
  }

  .sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main {
    width: 100%;
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .topbar-title {
    margin-right: auto;
  }
}

@media (max-width: 639px) {
  .stats-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    min-height: 58px;
    gap: 10px;
    padding: 8px 14px;
  }

  .topbar-title {
    display: none;
  }

  .topbar-actions {
    gap: 0;
    margin-left: auto;
  }

  .topbar-actions a,
  .nav-button {
    min-height: 38px;
    padding: 8px;
    font-size: 13px;
  }

  .topbar-actions a:first-child {
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .container {
    padding: 22px 14px 34px;
  }

  .app-footer {
    flex-direction: column;
    gap: 2px;
    padding: 16px 14px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 18px;
  }

  .page-head > .btn,
  .page-head > .actions {
    width: 100%;
  }

  .page-head > .actions .btn {
    flex: 1;
  }

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

  .span {
    grid-column: auto;
  }

  .card {
    padding: 17px;
    border-radius: var(--radius-md);
  }

  .table-wrap.card,
  .card.table-wrap {
    padding: 0;
  }

  table {
    min-width: 640px;
  }

  .search {
    flex-direction: column;
  }

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

  .filter-wide {
    grid-column: auto;
  }

  .search .btn {
    width: 100%;
  }

  .actions,
  .row,
  .pagination {
    flex-wrap: wrap;
  }

  .pagination span {
    width: 100%;
    order: -1;
    text-align: center;
  }

  .scene {
    grid-template-columns: 30px minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
