:root {
  --bg: #000;
  --panel: rgba(255, 255, 255, 0.03);
  --panel-strong: #0d0d0d;
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-2: rgba(255, 255, 255, 0.14);
  --text: #ededed;
  --muted: #8a8a8a;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.22, .61, .36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: Onest, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: rgba(255, 255, 255, 0.25); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.logo { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; color: #fff; white-space: nowrap; }
.logo i { font-style: normal; font-weight: 500; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0; }
.error { min-height: 18px; font-size: 13px; color: #fff; opacity: .85; }
.error:empty { min-height: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--stroke-2);
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.24); }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(180deg, #fff, #dedede); border-color: transparent; color: #0a0a0a; box-shadow: inset 0 1px 0 #fff, 0 8px 20px rgba(0, 0, 0, 0.45); }
.btn-primary:hover { background: #fff; }
.btn-small { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: #fff; }

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke-2);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  transition: border-color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}
textarea.input { height: auto; padding: 12px 14px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #aaa 50%), linear-gradient(135deg, #aaa 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
select.input option { background: #111; }
.input:focus { border-color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.06); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05); }
.input-small { height: 32px; border-radius: 9px; font-size: 13px; padding-left: 10px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(50% 40% at 50% 0%, rgba(255, 255, 255, 0.07), transparent 70%); }
.login-card { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 360px; padding: 32px 28px; border-radius: 22px; border: 1px solid var(--stroke-2); background: linear-gradient(160deg, #161616, #080808); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: rise .5s var(--ease-out); }
.login-card h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.025em; margin: 12px 0 6px; }
.login-card .btn { height: 46px; }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 24px 16px; border-right: 1px solid var(--stroke); background: #050505; }
.sidebar .logo { padding: 0 10px; }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tab { position: relative; height: 40px; padding: 0 12px; border: none; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; font-size: 14.5px; font-weight: 600; cursor: pointer; transition: background .18s var(--ease), color .18s var(--ease); }
.tab:hover { background: rgba(255, 255, 255, 0.05); color: #ddd; }
.tab.is-active { background: rgba(255, 255, 255, 0.09); color: #fff; }
.tab.is-active::before { content: ""; position: absolute; left: 3px; top: 50%; width: 3px; height: 18px; margin-top: -9px; border-radius: 3px; background: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.7); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side-link { height: 34px; padding: 0 12px; display: flex; align-items: center; border: none; border-radius: 9px; background: none; color: var(--muted); font-size: 13.5px; text-decoration: none; cursor: pointer; }
.side-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }

.main { min-width: 0; padding: 32px 36px 60px; }
.view { animation: rise .35s var(--ease-out); }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.view-head h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.view-head p { margin-top: 4px; font-size: 14px; }

.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; border: 1px solid var(--stroke); background: var(--panel); }
.segmented button { height: 32px; padding: 0 12px; border: none; border-radius: 9px; background: none; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: background .16s var(--ease), color .16s var(--ease); }
.segmented button:hover { color: #ddd; }
.segmented button.is-active { background: rgba(255, 255, 255, 0.12); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 16px; border: 1px solid var(--stroke); background: var(--panel); animation: rise .45s var(--ease-out) backwards; animation-delay: calc(var(--i) * 40ms); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; color: #fff; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 12px; color: #5f5f5f; }

.panel { position: relative; padding: 20px; border-radius: 18px; border: 1px solid var(--stroke); background: var(--panel); min-width: 0; }
.panel h3 { margin-bottom: 14px; font-size: 14.5px; font-weight: 700; color: #e6e6e6; }
.panel .sub-h { margin-top: 22px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.chart { position: relative; height: 220px; }
.chart svg { display: block; overflow: visible; }
.grid-line { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; }
.axis-line { stroke: rgba(255, 255, 255, 0.16); stroke-width: 1; }
.axis-label { fill: #6d6d6d; font-size: 11px; font-variant-numeric: tabular-nums; }
.series-line { fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-marker { fill: #fff; stroke: #000; stroke-width: 2; }
.crosshair { stroke: rgba(255, 255, 255, 0.3); stroke-width: 1; stroke-dasharray: 3 3; }
.series-bar { fill: #e6e6e6; transition: opacity .15s var(--ease); animation: barGrow .6s var(--ease-out) backwards; }
.series-bar.is-dim { opacity: .3; }
@keyframes barGrow { from { transform: scaleY(0); } }
.chart-tip { position: absolute; z-index: 2; display: flex; flex-direction: column; gap: 2px; padding: 8px 11px; border-radius: 10px; border: 1px solid var(--stroke-2); background: rgba(14, 14, 14, 0.96); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); font-size: 12.5px; color: #cfcfcf; white-space: nowrap; pointer-events: none; }
.chart-tip b { color: #fff; font-size: 13px; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-item { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 9px; overflow: hidden; font-size: 13.5px; animation: rise .4s var(--ease-out) backwards; animation-delay: calc(var(--i) * 40ms); }
.bar-item::before { content: ""; position: absolute; inset: 0; width: var(--w); border-radius: 9px; background: rgba(255, 255, 255, 0.09); transform-origin: left; animation: barFill .7s var(--ease-out) backwards; animation-delay: calc(var(--i) * 40ms + 100ms); }
@keyframes barFill { from { transform: scaleX(0); } }
.bar-name, .bar-value { position: relative; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e0e0e0; }
.bar-value { flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { padding: 14px 0; font-size: 13.5px; }

.table-wrap { padding: 6px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--stroke); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
.table tbody tr { transition: background .15s var(--ease); animation: rise .35s var(--ease-out) backwards; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table tr.is-off td { opacity: .45; }
.table tr.is-off td:last-child, .table tr.is-off td:nth-last-child(2) { opacity: 1; }
.table tr.status-paid td:nth-child(7) { color: #fff; font-weight: 700; }
.table tr.status-cancelled td { opacity: .45; }
.table tr.status-cancelled td:last-child { opacity: 1; }
.tag { display: inline-flex; align-items: center; height: 20px; margin-left: 8px; padding: 0 8px; border-radius: 99px; border: 1px solid rgba(255, 255, 255, 0.25); font-size: 11px; font-weight: 700; color: #ddd; vertical-align: 2px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.12); transition: background .2s var(--ease); }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #777; transition: transform .25s cubic-bezier(.32, .72, 0, 1), background .2s var(--ease); }
.switch input:checked + span { background: rgba(255, 255, 255, 0.85); }
.switch input:checked + span::after { transform: translateX(18px); background: #000; }
.switch input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(6px); opacity: 0; transition: opacity .2s var(--ease); }
.modal.is-open { opacity: 1; }
.modal-card { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 28px; border-radius: 22px; border: 1px solid var(--stroke-2); background: linear-gradient(160deg, #171717, #090909); box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7); transform: translateY(12px) scale(.98); transition: transform .3s cubic-bezier(.32, .72, 0, 1); }
.modal.is-open .modal-card { transform: none; }
.modal-card h3 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--stroke); background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-close:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field-label { font-size: 12.5px; font-weight: 600; color: #cfcfcf; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 10px; margin-top: 36px; font-size: 14px; cursor: pointer; }
.field.check input { width: 18px; height: 18px; accent-color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
#editor-error { margin-top: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; padding: 11px 18px; border-radius: 99px; border: 1px solid var(--stroke-2); background: rgba(16, 16, 16, 0.95); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); font-size: 14px; font-weight: 600; opacity: 0; transform: translate(-50%, 16px); transition: opacity .2s var(--ease), transform .3s cubic-bezier(.32, .72, 0, 1); pointer-events: none; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.delivery-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.delivery { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 99px; border: 1px solid var(--stroke-2); font-size: 12px; font-weight: 700; white-space: nowrap; color: #bdbdbd; }
.delivery-delivered { background: #fff; border-color: #fff; color: #000; }
.delivery-failed { border-color: rgba(255, 255, 255, 0.7); color: #fff; border-style: dashed; }
.delivery-waiting_player, .delivery-pending { color: #e0e0e0; }
.delivery-log summary { cursor: pointer; font-size: 12px; color: var(--muted); list-style: none; }
.delivery-log summary::-webkit-details-marker { display: none; }
.delivery-log summary:hover { color: #fff; }
.delivery-log[open] { flex-basis: 100%; }
.delivery-log pre { max-width: 420px; margin-top: 6px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--stroke-2); background: #0e0e0e; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6); font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap; color: #cfcfcf; }
.table td s { font-size: 12.5px; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px; border-right: none; border-bottom: 1px solid var(--stroke); overflow-x: auto; }
  .tabs { flex-direction: row; }
  .tab { height: 36px; white-space: nowrap; }
  .tab.is-active::before { display: none; }
  .sidebar-foot { flex-direction: row; margin: 0 0 0 auto; }
  .main { padding: 22px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .field.check { margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
