:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.07);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 230px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: 80px minmax(0, 1fr);
  grid-template-areas:
    "header header"
    "sidebar main";
}

.app-header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.inline-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  min-width: 220px;
}

.inline-field select {
  min-width: 220px;
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}

.app-sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
}

.app-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-btn:hover {
  background: var(--surface-muted);
}

.nav-btn.active {
  background: #dbeafe;
  color: var(--primary-dark);
  font-weight: 600;
}

.app-main {
  grid-area: main;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.view-section {
  display: none;
  gap: 14px;
}

.view-section.active {
  display: grid;
}

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

.section-header .actions {
  display: flex;
  gap: 8px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 6px;
}

.summary-card .label {
  font-size: 13px;
  color: var(--muted);
}

.summary-card .value {
  font-size: 28px;
  font-weight: 700;
}

.analytics-kpi-card {
  gap: 10px;
}

.analytics-kpi-change {
  font-size: 13px;
  font-weight: 600;
}

.analytics-kpi-change.positive {
  color: var(--success);
}

.analytics-kpi-change.negative {
  color: var(--danger);
}

.analytics-kpi-change.neutral {
  color: var(--muted);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

label {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  background: #fff;
  font: inherit;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button,
.button-link {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease, background-color 0.15s ease;
  text-decoration: none;
}

button:hover,
.button-link:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

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

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

button.danger:hover {
  background: #dc2626;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #fbfdff;
}

tbody tr:hover {
  background: #f8fbff;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.OPEN,
.badge.PREPARING {
  background: #fef3c7;
  color: #92400e;
}

.badge.READY,
.badge.PAID,
.badge.ACTIVE,
.badge.TRUE {
  background: #dcfce7;
  color: #166534;
}

.badge.CANCELLED,
.badge.FALSE {
  background: #fee2e2;
  color: #991b1b;
}

.badge.COMPLETED {
  background: #dbeafe;
  color: #1e3a8a;
}

.empty-state {
  text-align: center;
  padding: 32px;
}

.hidden {
  display: none !important;
}

.analytics-toolbar {
  align-items: flex-start;
}

.analytics-toolbar-controls {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.analytics-period-tabs,
.analytics-nav-controls,
.analytics-grid {
  display: grid;
  gap: 10px;
}

.analytics-period-tabs {
  grid-template-columns: repeat(3, minmax(90px, 1fr));
}

.analytics-period-btn.active {
  background: #dbeafe;
  color: var(--primary-dark);
  border-color: #93c5fd;
}

.analytics-nav-controls {
  grid-auto-flow: column;
  align-items: center;
}

.analytics-current-label {
  min-width: 180px;
  text-align: center;
  font-weight: 600;
}

.analytics-chart-panel {
  min-height: 380px;
}

.analytics-chart-wrap {
  position: relative;
  min-height: 300px;
}

.analytics-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.analytics-summary-item {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.analytics-summary-label {
  color: var(--muted);
  font-size: 13px;
}

.analytics-summary-value {
  font-size: 20px;
}

.analytics-item-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.analytics-item-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #dbeafe;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
}

#developerResponse {
  margin: 0;
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  min-height: 160px;
  background: #0f172a;
  color: #c7f9cc;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.2);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  width: min(680px, 95vw);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.clickable-row {
  cursor: pointer;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.auth-card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.auth-header {
  display: grid;
  gap: 6px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tab-btn {
  border: 0;
  background: var(--surface-muted);
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "main";
  }

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
  }

  .app-sidebar nav {
    flex-direction: row;
  }

  .nav-btn {
    min-width: 120px;
  }

  .header-right {
    align-items: flex-end;
    flex-direction: column;
  }

  .analytics-toolbar-controls,
  .analytics-nav-controls {
    width: 100%;
    justify-items: stretch;
  }

  .analytics-nav-controls {
    grid-auto-flow: row;
  }

  .analytics-current-label {
    min-width: 0;
  }

  label {
    width: 100%;
    min-width: 100%;
  }

  input,
  select,
  textarea {
    width: 100%;
  }
}

