:root {
  --bg: #0a1210;
  --bg-panel: rgba(8, 18, 15, 0.78);
  --surface: #f7f0e6;
  --surface-strong: #fff8ef;
  --border: rgba(119, 255, 182, 0.18);
  --text: #152117;
  --muted: #5e6f63;
  --accent: #59ff99;
  --accent-soft: rgba(89, 255, 153, 0.18);
  --danger: #ff8474;
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.35);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shell-border: rgba(40, 96, 59, 0.1);
  --shell-shadow: 0 22px 45px rgba(41, 63, 48, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #07110d 0%, #0c1712 100%);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.auth-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: #040907;
}

.matrix-canvas,
.auth-overlay {
  position: absolute;
  inset: 0;
}

.auth-overlay {
  background:
    radial-gradient(circle at top right, rgba(89, 255, 153, 0.12), transparent 30%),
    linear-gradient(135deg, rgba(0, 0, 0, 0.66), rgba(6, 22, 14, 0.8));
  backdrop-filter: blur(2px);
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 32px;
  padding: 40px;
}

.auth-copy {
  color: #d8ffe7;
}

.auth-kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.auth-copy h1 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 1;
}

.auth-text {
  max-width: 36rem;
  margin: 18px 0 0;
  color: rgba(216, 255, 231, 0.82);
  font-size: 1.08rem;
  line-height: 1.9;
}

.auth-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.auth-badges span {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(89, 255, 153, 0.25);
  background: rgba(5, 20, 13, 0.5);
  color: #e3ffef;
}

.auth-card {
  background: rgba(4, 14, 10, 0.88);
  border: 1px solid rgba(89, 255, 153, 0.22);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 26px;
  color: #effff5;
}

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

.otp-form h2,
.otp-form p {
  margin: 0;
}

.otp-helper {
  color: rgba(223, 255, 235, 0.7);
  font-size: 0.95rem;
}

.auth-admin-note {
  margin-top: 18px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(89, 255, 153, 0.18);
  background: rgba(89, 255, 153, 0.06);
  display: grid;
  gap: 6px;
}

.app-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(196, 241, 141, 0.25), transparent 30%),
    linear-gradient(180deg, #eef5ef 0%, #dcebdd 100%);
}

.background-shape {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.45;
}

.shape-a {
  top: 5%;
  left: 5%;
  width: 260px;
  height: 260px;
  background: rgba(55, 144, 99, 0.18);
}

.shape-b {
  bottom: 8%;
  right: 6%;
  width: 320px;
  height: 320px;
  background: rgba(125, 202, 160, 0.22);
}

.hero,
.layout {
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 24px 32px 16px;
}

.hero-copy,
.hero-stats,
.sidebar,
.content {
  background: rgba(255, 252, 248, 0.88);
  backdrop-filter: blur(14px);
  border: 1px solid var(--shell-border);
  box-shadow: var(--shell-shadow);
}

.hero-copy {
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  line-height: 1.1;
}

.hero-text {
  margin: 16px 0 0;
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
}

.session-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.session-strip span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(235, 246, 237, 0.95);
  border: 1px solid rgba(40, 96, 59, 0.1);
  color: var(--text);
  font-size: 0.95rem;
}

.hero-stats {
  border-radius: var(--radius-lg);
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 96, 59, 0.12);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 0 32px 32px;
}

.sidebar,
.content {
  border-radius: var(--radius-lg);
}

.sidebar {
  padding: 18px 20px 20px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.admin-menu {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.menu-btn {
  flex: 0 0 auto;
  text-align: center;
  border: 1px solid rgba(40, 96, 59, 0.12);
  background: rgba(249, 252, 249, 0.94);
  color: var(--text);
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font: inherit;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.menu-btn:hover,
.menu-btn.active {
  background: linear-gradient(135deg, #dff7e8, #eef8f0);
  border-color: rgba(31, 139, 76, 0.28);
  transform: translateY(-1px);
}

.sidebar-header h2,
.sheet-meta h2 {
  margin: 0;
}

.sidebar-header p,
.sheet-subtitle,
.sheet-card .sheet-page {
  color: var(--muted);
}

.catalog-section {
  margin-top: 28px;
}

.panel-card {
  margin-bottom: 22px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 252, 248, 0.9);
  border: 1px solid rgba(40, 96, 59, 0.12);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 14, 10, 0.58);
  backdrop-filter: blur(8px);
}

.modal-window {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 18px;
  border-radius: 28px;
  background: rgba(255, 252, 248, 0.96);
  border: 1px solid rgba(40, 96, 59, 0.12);
  box-shadow: 0 28px 70px rgba(6, 20, 12, 0.25);
}

.modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(40, 96, 59, 0.12);
}

.modal-topbar h2 {
  margin: 0;
}

.modal-content .panel-card {
  margin-bottom: 0;
  border: 0;
  background: transparent;
  padding: 0;
}

.modal-content .table-wrap,
.modal-content .order-form {
  margin-top: 16px;
}

.print-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px;
  border: 1px dashed rgba(40, 96, 59, 0.22);
  border-radius: 18px;
  background: #fff;
}

.print-meta {
  display: grid;
  gap: 8px;
}

.print-meta h3,
.print-meta p {
  margin: 0;
}

#print-qr {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(40, 96, 59, 0.1);
  padding: 8px;
}

.order-form {
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid rgba(40, 96, 59, 0.12);
}

.compact-form {
  padding: 14px;
}

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

.single-column {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

.field span {
  color: var(--muted);
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(40, 96, 59, 0.14);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.field-wide {
  grid-column: 1 / -1;
}

.items-builder {
  display: grid;
  gap: 12px;
}

.items-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.items-builder-head h3 {
  margin: 0;
}

.item-row {
  display: grid;
  grid-template-columns: 1.5fr repeat(5, 1fr) auto auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(40, 96, 59, 0.12);
  border-radius: 14px;
  background: #fffaf2;
}

.field-checkbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(40, 96, 59, 0.14);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
}

.field-checkbox input {
  width: 20px;
  height: 20px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, #1f8b4c, #53f79a);
  color: #03150c;
  font-weight: 700;
}

.small-btn {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.primary-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.secondary-btn {
  background: #d8ecdd;
  color: var(--text);
}

.danger-btn {
  background: #f4d8d1;
  color: #7a2d1f;
  align-self: end;
}

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

.form-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.form-message[data-state="success"] {
  color: #1f6a41;
}

.form-message[data-state="error"] {
  color: #8b2e1b;
}

.permission-block.locked {
  display: none;
}

.sheet-nav {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.sheet-card {
  width: 100%;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 16px;
  display: grid;
  gap: 4px;
  text-align: right;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.sheet-card:hover,
.sheet-card.active {
  transform: translateY(-2px);
  border-color: rgba(40, 96, 59, 0.25);
  background: var(--surface-strong);
}

.sheet-order {
  color: #1f8b4c;
  font-weight: 700;
}

.sheet-name {
  font-size: 1.05rem;
  font-weight: 600;
}

.content {
  padding: 24px;
}

.sheet-meta {
  display: grid;
  gap: 16px;
}

.meta-actions {
  display: flex;
  justify-content: flex-start;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.meta-pill {
  padding: 10px 14px;
  background: #f1faf3;
  border: 1px solid rgba(40, 96, 59, 0.12);
  border-radius: 999px;
  font-size: 0.95rem;
}

.table-wrap {
  margin-top: 22px;
  overflow: auto;
  border: 1px solid rgba(40, 96, 59, 0.12);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.orders-table-wrap {
  margin-top: 8px;
}

.order-row {
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.order-row:hover td {
  background: rgba(225, 244, 231, 0.95);
}

.order-row.active td {
  background: rgba(211, 240, 220, 0.98);
  font-weight: 600;
}

.role-select {
  width: 100%;
  min-width: 130px;
  border: 1px solid rgba(40, 96, 59, 0.14);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
}

.inline-input {
  width: 100%;
  min-width: 90px;
  border: 1px solid rgba(40, 96, 59, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(40, 96, 59, 0.09);
  vertical-align: top;
  text-align: right;
  white-space: nowrap;
}

th {
  background: #e8f4eb;
  color: var(--text);
}

tbody tr:nth-child(even) td {
  background: rgba(245, 250, 245, 0.8);
}

.empty-cell {
  color: #b39e8d;
}

code {
  font-family: Consolas, monospace;
}

@media (max-width: 1100px) {
  .auth-shell,
  .layout {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  .auth-shell,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .auth-shell,
  .hero {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .hero-copy,
  .hero-stats,
  .sidebar,
  .content,
  .auth-card {
    padding: 18px;
  }

  .print-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-copy {
    padding: 18px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .session-strip {
    width: 100%;
  }

  .modal-overlay {
    padding: 10px;
  }

  .modal-window {
    max-height: calc(100vh - 20px);
    padding: 14px;
    border-radius: 20px;
  }

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