:root {
  color-scheme: light;
  --bg: #eef4ff;
  --bg-deep: #07111f;
  --surface: rgba(255, 255, 255, .86);
  --surface-solid: #ffffff;
  --surface-2: #f4f7fb;
  --line: rgba(15, 23, 42, .10);
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #7c3aed;
  --accent: #06b6d4;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --shadow: 0 22px 60px rgba(15, 23, 42, .10);
  --shadow-soft: 0 10px 30px rgba(37, 99, 235, .12);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, .22), transparent 32rem),
    radial-gradient(circle at top right, rgba(124, 58, 237, .18), transparent 36rem),
    linear-gradient(135deg, #f8fbff 0%, var(--bg) 55%, #f5f3ff 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(15, 23, 42, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(15, 23, 42, .035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.app-shell { min-height: 100vh; position: relative; }
.has-sidebar .app-shell { display: grid; grid-template-columns: 292px minmax(0, 1fr); }
.main { width: 100%; max-width: 1360px; margin: 0 auto; padding: 34px; }
.guest .main { max-width: none; padding: 0 24px 48px; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 0%, rgba(34, 211, 238, .22), transparent 18rem),
    linear-gradient(180deg, #08111f 0%, #0f172a 58%, #111827 100%);
  color: #e5e7eb;
  border-right: 1px solid rgba(255,255,255,.08);
  box-shadow: 14px 0 44px rgba(2, 6, 23, .16);
}
.brand, .mobile-brand { display: flex; align-items: center; gap: 12px; min-width: 0; font-weight: 900; letter-spacing: -.02em; }
.brand img, .mobile-brand img, .auth-head img { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 14px; box-shadow: 0 12px 26px rgba(37, 99, 235, .24); }
.brand span, .mobile-brand span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.brand.compact { color: var(--text); }
.nav-list { display: grid; gap: 8px; }
.nav-list a {
  display: flex; align-items: center; min-height: 46px; padding: 11px 14px;
  border: 1px solid transparent; border-radius: 14px; color: #cbd5e1; font-weight: 750;
  transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.nav-list a:hover, .nav-list a.active {
  background: rgba(255, 255, 255, .10); color: #ffffff; border-color: rgba(255,255,255,.10); transform: translateX(3px);
}
.nav-list a.active { box-shadow: inset 3px 0 0 var(--accent); }
.nav-label { margin: 4px 0 -8px; color: #93c5fd; font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, .12); }
.sidebar-footer strong, .sidebar-footer span { display: block; }
.sidebar-footer span { color: #94a3b8; font-size: 13px; }
.sidebar-footer a { color: #67e8f9; font-weight: 850; }
.mobile-bar, .guest-bar { display: none; }
.guest-bar { max-width: 1120px; margin: 0 auto; padding: 28px 24px 0; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.82); display: grid; place-content: center; gap: 4px; box-shadow: var(--shadow-soft); }
.icon-button span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 99px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 26px; }
.page-head h1, .auth-head h1 { margin: 0; font-size: clamp(26px, 3vw, 36px); line-height: 1.08; letter-spacing: -.04em; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }

.panel, .service-item, .quick-link, .stat, .auth-panel {
  background: var(--surface); border: 1px solid rgba(255,255,255,.68); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.panel { padding: 24px; margin-bottom: 22px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-title h2, .service-item h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.muted, .service-item p, .auth-switch, .empty { color: var(--muted); }
.stats-grid, .quick-grid, .service-grid, .split-grid { display: grid; gap: 18px; margin-bottom: 22px; }
.stats-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.service-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.split-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat { padding: 22px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -34px; top: -34px; width: 92px; height: 92px; border-radius: 50%; background: linear-gradient(135deg, rgba(37,99,235,.18), rgba(6,182,212,.12)); }
.stat span { display: block; color: var(--muted); font-size: 13px; font-weight: 800; }
.stat strong { display: block; margin-top: 8px; font-size: 31px; line-height: 1.1; letter-spacing: -.04em; }
.quick-link, .service-item { padding: 20px; transition: transform .18s ease, box-shadow .18s ease; }
.quick-link:hover, .service-item:hover { transform: translateY(-3px); box-shadow: 0 26px 70px rgba(15,23,42,.14); }
.quick-link strong, .quick-link span { display: block; }
.quick-link span { margin-top: 4px; color: var(--muted); }
.service-item { display: flex; min-height: 158px; flex-direction: column; justify-content: space-between; gap: 18px; }
.service-item p { margin: 8px 0 0; }
.service-item strong { color: var(--primary); font-size: 18px; }

.button, button.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 43px; padding: 10px 16px;
  border: 1px solid transparent; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: #ffffff;
  font-weight: 900; cursor: pointer; white-space: nowrap; box-shadow: 0 12px 26px rgba(37,99,235,.24); transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 16px 34px rgba(37,99,235,.30); }
.button.secondary { background: rgba(255,255,255,.82); border-color: var(--line); color: var(--text); box-shadow: none; }
.button.secondary:hover { background: #ffffff; }
.button.danger { background: linear-gradient(135deg, #ef4444, #dc2626); }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 13px; border-radius: 11px; }
.button.block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.text-link, .auth-switch a { color: var(--primary); font-weight: 900; }
.copy-line, .api-line { display: flex; gap: 10px; align-items: center; }
.copy-line code { min-width: 0; flex: 1; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.9); overflow: auto; }
.table-wrap { width: 100%; overflow-x: auto; }
.order-summary { margin-bottom: 22px; }
.order-summary .stat strong { color: var(--text); }
.order-summary .status-count-done strong { color: var(--success); }
.order-summary .status-count-pending strong { color: var(--warning); }
.order-summary .status-count-rejected strong { color: var(--danger); }
.order-toolbar { align-items: center; justify-content: space-between; gap: 14px; }
.order-toolbar-title { display: grid; gap: 2px; }
.order-toolbar-title strong { font-size: 15px; font-weight: 900; }
.order-toolbar-title span { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
td code { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orders-table { min-width: 920px; }
.admin-orders-table { min-width: 1080px; }
.orders-table .column-result { width: 34%; }
.orders-table .column-action { width: 1%; }
.order-id, .price { font-weight: 900; white-space: nowrap; }
.order-main { display: grid; gap: 3px; min-width: 0; }
.order-main strong, .order-main span { min-width: 0; overflow-wrap: anywhere; }
.order-main span { color: var(--muted); font-size: 13px; }
.result-box { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.86); }
.result-box.is-pending .result-text { color: var(--muted); }
.result-text { min-width: 0; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; line-height: 1.35; }
.copy-result { flex: 0 0 auto; }
tr.is-new td { background: #eff6ff; }
.badge { display: inline-flex; align-items: center; min-height: 28px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.status-1 { background: #fff7ed; color: var(--warning); }
.status-3 { background: #fef2f2; color: var(--danger); }
.status-4, .role-admin { background: #ecfdf5; color: var(--success); }
.role-user { background: #eef2ff; color: var(--secondary); }
.toolbar { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.table-search { width: min(100%, 330px); }

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 850; }
input, select, textarea { width: 100%; min-height: 44px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.88); color: var(--text); outline: none; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
textarea { min-height: 98px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(37, 99, 235, .62); box-shadow: 0 0 0 4px rgba(37, 99, 235, .14); background: #fff; }
.order-entry-panel { display: grid; gap: 18px; }
.order-mode-toggle { display: inline-grid; grid-auto-flow: column; justify-self: start; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.86); }
.mode-button { min-height: 36px; padding: 7px 14px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 900; cursor: pointer; transition: background .18s ease, color .18s ease, box-shadow .18s ease; }
.mode-button.active { background: #ffffff; color: var(--text); box-shadow: 0 7px 18px rgba(15,23,42,.08); }
.order-form, .admin-form { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 14px; align-items: end; }
.batch-order-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.batch-order-form .wide { grid-column: 1 / -1; }
.batch-order-form textarea { min-height: 158px; line-height: 1.55; }
.batch-actions { display: flex; gap: 10px; align-items: center; }
.admin-form { grid-template-columns: 1fr 160px 1.4fr; }
.admin-form .wide { grid-column: span 3; }
.admin-form.inline { margin-bottom: 12px; }
.form-stack { display: grid; gap: 14px; }
.toggle { display: flex; align-items: center; gap: 10px; }
.toggle input { width: 18px; min-height: 18px; }
.credit-form { display: flex; gap: 8px; align-items: center; }
.credit-form input { width: 110px; }
.delete-form { margin-top: 8px; }
.edit-row td { background: #f8fafc; }
.doc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.doc-grid div { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.86); }
.doc-grid span, .doc-grid strong { display: block; }
.doc-grid span { color: var(--muted); font-size: 12px; font-weight: 900; }
pre { margin: 0; padding: 18px; border: 1px solid rgba(255,255,255,.10); border-radius: 16px; background: #07111f; color: #e5e7eb; overflow-x: auto; box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.auth-wrap { min-height: calc(100vh - 96px); display: grid; place-items: center; padding: 44px 0; }
.auth-panel { width: min(100%, 440px); padding: 30px; display: grid; gap: 16px; }
.auth-panel.wide { width: min(100%, 700px); }
.auth-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.auth-switch { margin: 0; text-align: center; }
.flash { margin: 0 0 16px; padding: 13px 15px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.9); font-weight: 800; box-shadow: var(--shadow-soft); }
.flash.success { border-color: #bbf7d0; background: #f0fdf4; color: var(--success); }
.flash.error { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.notice { padding: 14px; border: 1px solid #fecaca; border-radius: 14px; background: #fef2f2; color: var(--danger); }
.batch-results-panel { display: grid; gap: 14px; }
.batch-results-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.batch-results-head strong, .batch-results-head span { display: block; }
.batch-results-head strong { font-size: 15px; font-weight: 900; }
.batch-results-head span { color: var(--muted); font-size: 13px; }
.batch-count { flex: 0 0 auto; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(248,250,252,.9); color: var(--text); font-size: 12px; font-weight: 900; }
.batch-progress { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(15,23,42,.08); }
.batch-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .28s ease; }
.batch-result-list { display: grid; gap: 10px; }
.batch-result-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(0, 2fr); gap: 12px; align-items: start; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.86); transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.batch-result-row.is-loading { border-color: rgba(37, 99, 235, .28); background: #eff6ff; }
.batch-result-row.is-done { border-color: #bbf7d0; background: #f0fdf4; }
.batch-result-row.is-pending { border-color: #fed7aa; background: #fff7ed; }
.batch-result-row.is-error { border-color: #fecaca; background: #fef2f2; }
.batch-result-meta { display: grid; gap: 3px; min-width: 0; }
.batch-result-meta strong, .batch-result-meta span { min-width: 0; overflow-wrap: anywhere; }
.batch-result-meta strong { font-size: 14px; }
.batch-result-meta span { color: var(--muted); font-size: 12px; font-weight: 850; }
.batch-result-text { min-width: 0; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; line-height: 1.4; }
.batch-result-text .copy-result { margin-top: 8px; }
button[disabled] { opacity: .62; cursor: progress; transform: none; box-shadow: none; }
.install-list { margin: 0; color: var(--muted); }
.install-panel { align-content: start; }
.install-section { display: grid; gap: 12px; }
.install-section h2 { margin: 0; font-size: 17px; }
.check-list { display: grid; gap: 10px; }
.check-item { display: grid; grid-template-columns: 48px minmax(110px, 1fr) minmax(0, 2fr); gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.86); }
.check-item span { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.check-item.ok span { background: #dcfce7; color: var(--success); }
.check-item.bad span { background: #fee2e2; color: var(--danger); }
.check-item strong { font-size: 14px; }
.check-item em { min-width: 0; color: var(--muted); font-style: normal; overflow-wrap: anywhere; }
.install-note { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(248,250,252,.86); color: var(--muted); }

@media (max-width: 1100px) {
  .has-sidebar .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; left: 0; top: 0; width: min(84vw, 308px); transform: translateX(-105%); transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: rgba(248, 251, 255, .86); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
  .main { padding: 22px 18px; }
}
@media (max-width: 880px) {
  .stats-grid.three, .stats-grid.four, .quick-grid, .split-grid, .doc-grid { grid-template-columns: 1fr; }
  .order-form, .batch-order-form, .admin-form, .admin-form.inline { grid-template-columns: 1fr; }
  .admin-form .wide { grid-column: auto; }
  .page-head, .copy-line { align-items: stretch; flex-direction: column; }
  .toolbar { justify-content: stretch; }
  .table-search { width: 100%; }
}
@media (max-width: 760px) {
  .order-toolbar { align-items: stretch; flex-direction: column; }
  .table-wrap { overflow-x: visible; }
  .orders-table, .admin-orders-table { min-width: 0; border-collapse: separate; border-spacing: 0 12px; }
  .orders-table thead { display: none; }
  .orders-table tbody, .orders-table tr, .orders-table td { display: block; }
  .orders-table tr { margin-bottom: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-soft); }
  .orders-table td { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 12px; align-items: start; padding: 8px 0; border-bottom: 0; }
  .orders-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
  .orders-table .column-result, .orders-table .column-action { grid-template-columns: 1fr; }
  .orders-table .column-result::before { margin-bottom: 2px; }
  .orders-table .column-action::before { display: none; }
  .result-box { align-items: stretch; flex-direction: column; }
  .copy-result, .column-action .button { width: 100%; }
  .orders-table .empty-row { padding: 0; border: 0; background: transparent; box-shadow: none; }
  .orders-table .empty-row td { display: block; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(248,250,252,.86); }
  .orders-table .empty-row td::before { display: none; }
  .batch-results-head, .batch-actions { align-items: stretch; flex-direction: column; }
  .batch-result-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .guest-bar { display: flex; }
  .guest .main { padding-inline: 16px; }
  .auth-panel { padding: 22px; }
  .page-head h1, .auth-head h1 { font-size: 25px; }
  .stat strong { font-size: 25px; }
  .button-row, .credit-form { align-items: stretch; flex-direction: column; }
  .order-mode-toggle { width: 100%; grid-auto-columns: 1fr; }
  .credit-form input { width: 100%; }
  .check-item { grid-template-columns: 1fr; }
}
