:root {
  --bg-color: #0f172a;
  --bg-elevated: #111827;
  --bg-elevated-soft: #1f2937;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.1);
  --accent-strong: #2563eb;
  --text-primary: #f9fafb;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --border-subtle: #1f2937;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.8);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-pill: 999px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, #1e293b 0, #020617 55%, #000 100%);
  color: var(--text-primary);
}

body {
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: linear-gradient(to right, rgba(15, 23, 42, 0.9), rgba(17, 24, 39, 0.9));
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: radial-gradient(circle at 20% 20%, #60a5fa, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 35px rgba(37, 99, 235, 0.6);
  color: white;
  font-weight: 700;
}

.app-title {
  display: flex;
  flex-direction: column;
}

.app-title-main {
  font-size: 18px;
  font-weight: 600;
}

.app-title-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.app-nav a {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.app-nav a.active {
  background: radial-gradient(circle at top left, #3b82f6, #1d4ed8);
  color: #eff6ff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.7);
}

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

.badge-role {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-muted);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: radial-gradient(circle at 10% 0, #38bdf8, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.user-name {
  font-size: 13px;
}

.btn-ghost,
.btn-primary,
.btn-danger {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  font-weight: 500;
}

.btn-ghost {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.btn-ghost:hover {
  background: rgba(31, 41, 55, 0.95);
}

.btn-primary {
  background: linear-gradient(to right, #3b82f6, #2563eb);
  color: #eff6ff;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.7);
}

.btn-primary:hover {
  background: linear-gradient(to right, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(to right, #f97373, #ef4444);
  color: #fef2f2;
}

.btn-danger:hover {
  background: linear-gradient(to right, #ef4444, #b91c1c);
}

.lang-select {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  padding: 6px 10px;
  font-size: 12px;
}

.app-main {
  flex: 1;
  padding: 24px 32px 40px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

.auth-layout {
  display: flex;
  flex: 1;
  padding: 40px 16px;
  align-items: center;
  justify-content: center;
}

.auth-card {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  max-width: 980px;
  width: 100%;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.98));
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow: hidden;
}

.auth-hero {
  padding: 32px 32px 32px 32px;
  border-right: 1px solid rgba(148, 163, 184, 0.15);
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(circle at bottom right, rgba(59, 130, 246, 0.25), transparent 55%);
}

.auth-hero-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 12px;
}

.auth-hero-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 320px;
}

.auth-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.auth-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
}

.auth-hero-metrics {
  display: flex;
  gap: 16px;
  margin-top: 26px;
}

.metric-pill {
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.4);
  min-width: 130px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-value {
  font-size: 18px;
  margin-top: 4px;
}

.auth-form-panel {
  padding: 30px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.98));
}

.auth-switch {
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  font-weight: 500;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.input,
.select {
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font-size: 13px;
}

.input:focus,
.select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.6);
}

textarea.input {
  min-height: 72px;
  resize: vertical;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

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

.error-text {
  font-size: 12px;
  color: var(--danger);
}

.success-text {
  font-size: 12px;
  color: var(--success);
}

.dashboard-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.dashboard-title {
  font-size: 22px;
  font-weight: 600;
}

.dashboard-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 14px 12px;
  border-radius: var(--radius-md);
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.96));
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.75);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.stat-value {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 600;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  margin-top: 6px;
}

.stat-pill.waiting {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

.stat-pill.repairing {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.stat-pill.ready {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
}

.stat-pill.delivered {
  background: rgba(96, 165, 250, 0.1);
  color: #93c5fd;
}

.stat-pill.unpaid {
  background: rgba(239, 68, 68, 0.18);
  color: #fecaca;
}

.layout-two-column {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: flex-start;
}

.panel {
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.96));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  padding: 14px 14px 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-title {
  font-size: 15px;
  font-weight: 500;
}

.panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.input-compact {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font-size: 12px;
}

.select-compact {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--text-muted);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.badge-success {
  border-color: rgba(34, 197, 94, 0.7);
  color: #bbf7d0;
}

.badge-danger {
  border-color: rgba(239, 68, 68, 0.7);
  color: #fecaca;
}

.table-wrapper {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead {
  background: linear-gradient(to bottom, rgba(15, 23, 42, 1), rgba(15, 23, 42, 0.96));
}

th,
td {
  padding: 8px 10px;
  text-align: left;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(30, 41, 59, 1);
  background: rgba(15, 23, 42, 0.98);
}

tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.96);
}

tbody tr:nth-child(odd) {
  background: rgba(15, 23, 42, 0.99);
}

tbody tr:hover {
  background: rgba(30, 64, 175, 0.5);
}

.status-select {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
}

.status-waiting {
  background: rgba(245, 158, 11, 0.1);
  color: #facc15;
}

.status-repairing {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
}

.status-ready {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
}

.status-delivered {
  background: rgba(96, 165, 250, 0.12);
  color: #bfdbfe;
}

.tag-paid {
  color: #bbf7d0;
}

.tag-unpaid {
  color: #fecaca;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.chip-dot.green {
  background: #22c55e;
}

.chip-dot.red {
  background: #ef4444;
}

.chip-dot.amber {
  background: #f59e0b;
}

.inline-actions {
  display: flex;
  gap: 6px;
}

.btn-xs {
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}

.btn-xs.primary {
  border-color: rgba(59, 130, 246, 0.7);
  color: #bfdbfe;
}

.btn-xs.danger {
  border-color: rgba(239, 68, 68, 0.7);
  color: #fecaca;
}

.scrollable {
  max-height: 500px;
  overflow: auto;
}

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

.form-grid-full {
  grid-column: 1 / -1;
}

.pill-note {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--text-muted);
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow: auto;
  margin-top: 8px;
}

.note-item {
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(30, 64, 175, 0.7);
}

.note-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.note-text {
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 520px;
  background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.99), rgba(15, 23, 42, 0.97));
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 18px 18px 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 15px;
  font-weight: 500;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr);
  gap: 16px;
}

.badge-role-admin {
  color: #fed7aa;
}

.badge-role-owner {
  color: #bfdbfe;
}

.badge-role-tech {
  color: #a7f3d0;
}

.table-small td,
.table-small th {
  padding: 7px 8px;
}

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

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout-two-column {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-hero {
    display: none;
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .app-main {
    padding: 18px 16px 24px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .auth-card {
    margin-top: 24px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  .panel {
    padding: 12px 10px;
  }
}


canvas#revenue-chart{max-width:100%;background:rgba(15,23,42,0.4);border-radius:12px;padding:8px;}


.analytics-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; margin-top:12px; }
.metric-list { display:flex; flex-direction:column; gap:8px; }
.metric-item, .result-card { background: rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:12px; padding:10px 12px; display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.metric-button { width:100%; color:inherit; cursor:pointer; }
.stack-results { display:flex; flex-direction:column; gap:10px; margin-top:12px; }
.mini-title { font-size: 0.95rem; margin: 0 0 8px; }
.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,0.6); display:flex; align-items:center; justify-content:center; padding:20px; z-index:999; }
.modal-card { width:min(760px,100%); background:#101828; border:1px solid rgba(255,255,255,0.08); border-radius:20px; padding:20px; }

.ai-report { display:flex; flex-direction:column; gap:12px; margin-top:12px; }
.ai-summary { background:rgba(59,130,246,0.12); border:1px solid rgba(59,130,246,0.35); border-radius:14px; padding:12px; }
.ai-summary h3 { margin:0 0 8px; font-size:15px; }
.ai-summary-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; margin-top:10px; }
.ai-summary-grid div { background:rgba(15,23,42,0.55); border:1px solid rgba(148,163,184,0.25); border-radius:10px; padding:8px; display:flex; flex-direction:column; gap:4px; }
.ai-summary-grid span { color:var(--text-muted); font-size:11px; text-transform:uppercase; letter-spacing:0.06em; }
.ai-summary-grid strong { font-size:13px; }
.ai-section { background:rgba(15,23,42,0.7); border:1px solid rgba(148,163,184,0.2); border-radius:12px; padding:10px 12px; }
.ai-section h4 { margin:0 0 8px; font-size:13px; }
.ai-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:10px; }
.ai-card { background:rgba(15,23,42,0.82); border:1px solid rgba(148,163,184,0.28); border-radius:12px; padding:10px 12px; display:flex; flex-direction:column; gap:8px; }
.ai-card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.ai-card-head h4 { margin:0; font-size:13px; line-height:1.35; }
.ai-badge { padding:2px 8px; border-radius:999px; border:1px solid rgba(148,163,184,0.35); font-size:11px; color:#dbeafe; white-space:nowrap; }
.ai-meta-row { display:flex; flex-wrap:wrap; gap:10px; font-size:12px; color:var(--text-muted); }
.ai-list { margin:0 0 0 18px; padding:0; display:flex; flex-direction:column; gap:4px; font-size:12px; color:#e5e7eb; }
.ai-chip-list { display:flex; flex-wrap:wrap; gap:6px; }
.ai-chip { padding:2px 8px; border-radius:999px; border:1px solid rgba(148,163,184,0.28); background:rgba(15,23,42,0.8); font-size:11px; color:#bfdbfe; }
.ai-history-insight { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px; font-size:12px; color:var(--text-muted); }
.ai-history-card { background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:10px; padding:8px 10px; display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.ai-history-meta { display:flex; flex-direction:column; gap:4px; align-items:flex-end; font-size:11px; color:var(--text-muted); }
