:root {
  color-scheme: light;
  --ink: #101815;
  --muted: #66726b;
  --soft: #f5f6f1;
  --surface: #ffffff;
  --surface-2: #f9faf6;
  --line: #dfe4da;
  --line-strong: #cbd4c5;
  --green: #0f6a3c;
  --green-2: #164d32;
  --green-3: #e8f4ea;
  --gold: #c6a65a;
  --gold-2: #f7efd8;
  --danger: #a13a32;
  --blue: #2f5f8f;
  --sidebar: #111713;
  --sidebar-soft: #1a231d;
  --shadow: 0 18px 48px rgba(18, 31, 24, 0.08);
  font-family: Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--soft);
  color: var(--ink);
}

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--green-2);
  border-color: var(--green-2);
}

button:active {
  transform: translateY(1px);
}

button.ghost {
  background: #fff;
  color: var(--green);
}

button.ghost:hover {
  background: var(--green-3);
}

button.warn {
  background: var(--danger);
  border-color: var(--danger);
}

button.warn:hover {
  background: #842d27;
  border-color: #842d27;
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: 0;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(15, 106, 60, 0.12);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  padding: 20px;
  background: var(--sidebar);
  color: #fff;
  overflow: auto;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(198, 166, 90, 0.65);
  border-radius: 8px;
  background: var(--gold);
  color: #111713;
  font-size: 22px;
  font-weight: 900;
}

.brand-lockup strong {
  display: block;
  font-size: 18px;
}

.brand-lockup span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

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

.side-link {
  justify-content: flex-start;
  gap: 10px;
  min-height: 46px;
  border-color: transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
}

.side-link:hover,
.side-link.active {
  background: var(--sidebar-soft);
  border-color: rgba(198, 166, 90, 0.38);
  color: #fff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.module-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.module-list p {
  margin: 0;
  color: rgba(255, 255, 255, 0.48);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.module-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.module-card.active {
  border-color: rgba(198, 166, 90, 0.42);
  background: rgba(198, 166, 90, 0.13);
}

.module-card.soon {
  opacity: 0.72;
}

.module-card strong {
  font-size: 13px;
}

.module-card span {
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
  line-height: 1.35;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--gold);
}

.app-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 25px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-pill {
  min-width: 210px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.status-pill.connected {
  border-color: #94d0aa;
  background: #e9f8ee;
  color: var(--green);
}

.status-pill.disconnected {
  border-color: #e2c7c3;
  background: #fff4f2;
  color: var(--danger);
}

.page-section {
  padding: 28px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.summary-card {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-card strong {
  font-size: 34px;
  line-height: 1;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.pipeline-step {
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pipeline-step.active {
  border-color: rgba(198, 166, 90, 0.75);
  background: var(--gold-2);
}

.pipeline-step strong {
  font-size: 14px;
}

.pipeline-step span {
  color: var(--muted);
  font-size: 12px;
}

.operation-grid {
  display: grid;
  grid-template-columns: minmax(320px, 404px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-stack {
  display: grid;
  gap: 14px;
}

.panel,
.workspace,
.doc-card,
.docs-hero {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  gap: 13px;
  padding: 16px;
}

.accent-panel {
  border-color: rgba(15, 106, 60, 0.25);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.panel h2,
.workspace h2,
.doc-card h3 {
  margin: 0;
}

.panel h2 {
  font-size: 17px;
}

.panel p,
.workspace-head span,
.doc-card p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.qr {
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.groups {
  display: grid;
  gap: 7px;
  max-height: 190px;
  overflow: auto;
  font-size: 13px;
}

.group-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.group-item span {
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  padding: 18px;
}

.workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.workspace-head h2 {
  font-size: 28px;
  line-height: 1;
}

.lots {
  display: grid;
  gap: 14px;
}

.empty-state {
  display: grid;
  gap: 6px;
  min-height: 160px;
  place-content: center;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
}

.empty-state strong {
  font-size: 18px;
}

.empty-state span {
  color: var(--muted);
}

.lot {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  background: #f7f9f3;
}

.lot-title {
  font-weight: 900;
}

.lot-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.media-badge,
.lot-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 99px;
  background: var(--gold-2);
  color: #755b1f;
  font-size: 12px;
  font-weight: 900;
}

.media-badge.ready {
  background: var(--green-3);
  color: var(--green);
}

.lot-status {
  background: #eef3f9;
  color: var(--blue);
}

.lot-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  padding: 16px;
}

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

.field-grid label:nth-child(1),
.field-grid label:nth-child(4),
.caption-label {
  grid-column: 1 / -1;
}

.caption-label {
  margin-top: 10px;
}

.caption-label textarea {
  min-height: 210px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.preview {
  display: grid;
  align-content: start;
  gap: 10px;
}

.preview video,
.preview img {
  width: 100%;
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111;
}

.empty-preview {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 800;
}

.open-media {
  color: var(--green);
  font-weight: 900;
}

.yt-results {
  display: grid;
  gap: 6px;
}

.yt-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 13px;
}

.yt-item a {
  overflow-wrap: anywhere;
  color: var(--green);
  font-weight: 800;
}

.docs-view {
  max-width: 1120px;
}

.docs-hero {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 24px;
}

.docs-hero h2 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
}

.docs-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.doc-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 20px;
}

.doc-card h3 {
  font-size: 18px;
}

.steps,
.checklist {
  margin: 0;
  padding-left: 22px;
  line-height: 1.55;
}

.steps li,
.checklist li {
  margin-bottom: 8px;
}

.doc-table {
  display: grid;
  gap: 8px;
}

.doc-table div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.doc-table div:last-child {
  border-bottom: 0;
}

.doc-table span {
  color: var(--muted);
  line-height: 1.4;
}

.example-message {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: var(--surface-2);
}

.callout {
  padding: 12px;
  border-radius: 6px;
  background: var(--gold-2);
  color: #5d4819 !important;
  font-weight: 900;
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 460px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .operation-grid,
  .lot-body {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: static;
    height: auto;
  }

  .module-list {
    display: none;
  }

  .topbar,
  .workspace-head,
  .lot-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
  }

  .page-section {
    padding: 16px;
  }

  .field-grid,
  .doc-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .summary-grid,
  .pipeline,
  .button-row,
  .doc-table div {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    padding: 16px;
  }

  .topbar {
    padding: 16px;
  }

  .workspace,
  .panel,
  .docs-hero,
  .doc-card {
    padding: 14px;
  }

  .actions button {
    width: 100%;
  }
}
