:root {
  --bg: #0b1220;
  --card: #101a2f;
  --text: #e8edf7;
  --muted: #a6b2c7;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #4f8cff;
  --danger: #ff5a6b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1200px 600px at 20% 0%, rgba(79,140,255,0.25), transparent 50%),
              radial-gradient(900px 500px at 90% 10%, rgba(255,90,107,0.18), transparent 55%),
              var(--bg);
  color: var(--text);
}
.container { max-width: 980px; margin: 48px auto; padding: 0 16px; }
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 270px;
  padding: 18px 16px;
  border-right: 1px solid var(--border);
  background: rgba(8, 14, 26, 0.78);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { margin-bottom: 18px; display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  border: 1px solid rgba(79,140,255,0.35);
  background: rgba(79,140,255,0.12);
}
.brand-title { font-weight: 900; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.nav-item {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  background: rgba(255,255,255,0.03);
}
.nav-item:hover { border-color: rgba(255,255,255,0.10); }
.nav-item.active {
  border-color: rgba(79,140,255,0.35);
  background: rgba(79,140,255,0.12);
}
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.55);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title { font-weight: 800; font-size: 18px; }
.topbar-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.topbar-left { display: flex; flex-direction: column; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.content { padding: 22px 20px 32px; }
.card {
  background: rgba(16, 26, 47, 0.85);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  backdrop-filter: blur(10px);
}
.header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.kpi { padding: 18px; }
.kpi-label { color: var(--muted); font-size: 14px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.03);
}
.kpi-sub { margin-top: 8px; font-size: 13px; color: var(--muted); }
.kpi-sub.pos { color: rgba(125,255,181,0.9); }
.kpi-sub.neg { color: rgba(255,90,107,0.95); }
.kpi-total { background: linear-gradient(135deg, rgba(79,140,255,0.12), rgba(16,26,47,0.85)); }
.kpi-today { background: linear-gradient(135deg, rgba(125,255,181,0.10), rgba(16,26,47,0.85)); }
.kpi-yesterday { background: linear-gradient(135deg, rgba(255,201,91,0.08), rgba(16,26,47,0.85)); }
.kpi-month { background: linear-gradient(135deg, rgba(162,123,255,0.10), rgba(16,26,47,0.85)); }
.dash-title { font-weight: 800; font-size: 18px; }
.dash-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  white-space: nowrap;
}
.status-pill.ok { border-color: rgba(125,255,181,0.25); color: #7dffb5; background: rgba(125,255,181,0.08); }
.dash-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); margin: 6px 0 0; }
.metric { font-size: 34px; font-weight: 700; margin-top: 8px; }
.metric.ok { color: #7dffb5; }
.actions .link { color: var(--accent); text-decoration: none; }
.actions .link:hover { text-decoration: underline; }
.link.danger { color: var(--danger); background: transparent; border: none; padding: 0; }
.btn-link {
  color: var(--accent);
  text-decoration: none;
  padding: 10px 12px;
  border: 1px solid rgba(79,140,255,0.35);
  border-radius: 12px;
  background: rgba(79,140,255,0.10);
}
.btn-link:hover { background: rgba(79,140,255,0.18); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.actions { white-space: nowrap; }

/* Page head */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

label { display: block; margin-top: 12px; margin-bottom: 6px; color: var(--muted); }
input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
}
button {
  margin-top: 16px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(79,140,255,0.35);
  background: rgba(79,140,255,0.18);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: rgba(79,140,255,0.28); }
.btn-primary {
  margin-top: 16px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(79,140,255,0.35);
  background: rgba(79,140,255,0.18);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.btn-primary:hover { background: rgba(79,140,255,0.28); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  text-decoration: none;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  font-weight: 650;
  width: auto;
  margin-top: 0;
}
.btn:hover { background: rgba(255,255,255,0.06); }
.btn.btn-secondary { border-color: rgba(255,90,107,0.20); background: rgba(255,90,107,0.10); }
.btn.btn-secondary:hover { background: rgba(255,90,107,0.16); }
.btn.btn-sm { padding: 7px 10px; border-radius: 10px; font-weight: 700; }
.btn-plus { font-weight: 950; display: inline-block; margin-right: 6px; }
.btn-primary-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(79,140,255,0.35);
  background: rgba(79,140,255,0.18);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-weight: 750;
  width: auto;
  margin-top: 0;
}
.btn-primary-inline:hover { background: rgba(79,140,255,0.28); }

/* Auth */
.auth-body {
  min-height: 100vh;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.auth-left {
  padding: 42px 44px;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(900px 400px at 30% 10%, rgba(79,140,255,0.20), transparent 55%),
    rgba(8, 14, 26, 0.55);
  backdrop-filter: blur(10px);
}
.auth-right {
  display: grid;
  place-items: center;
  padding: 40px 18px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-hero { margin-top: 34px; max-width: 520px; }
.auth-hero h1 { margin: 0; font-size: 40px; letter-spacing: -0.3px; }
.auth-hero p { margin-top: 10px; }
.auth-bullets { margin-top: 26px; display: grid; gap: 10px; color: var(--muted); }
.auth-bullet { display: flex; align-items: center; gap: 10px; }
.auth-bullet .dot { width: 10px; height: 10px; border-radius: 999px; background: rgba(125,255,181,0.55); }

.auth-card {
  width: min(420px, 92vw);
  background: rgba(16, 26, 47, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  backdrop-filter: blur(10px);
}
.auth-card-head h2 { margin: 0; font-size: 22px; }
.auth-card-head p { margin: 8px 0 0; }
.auth-password { display: flex; align-items: center; gap: 10px; }
.auth-password input { flex: 1; min-width: 0; height: 42px; }
.icon-btn {
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  width: 42px;
  margin-top: 0;
}
.icon-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.icon-btn .eye { display: none; }
.icon-btn .eye-open { display: inline-flex; }
.icon-btn.shown .eye-open { display: none; }
.icon-btn.shown .eye-closed { display: inline-flex; }
.icon-btn svg, .icon-btn i { display: block; }
.alert {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,90,107,0.35);
  background: rgba(255,90,107,0.12);
  color: var(--text);
}

table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
code { color: #b9c7e6; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
.dash-table { margin-top: 0; }
.dash-table thead th {
  position: sticky;
  top: 0;
  background: rgba(16, 26, 47, 0.96);
  backdrop-filter: blur(8px);
  z-index: 1;
}
.dash-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}
.status-badge.delivered_to_device { border-color: rgba(125,255,181,0.25); color: #7dffb5; background: rgba(125,255,181,0.10); }
.status-badge.processed,
.status-badge.inserted_for_processing,
.status-badge.sent_to_carrier,
.status-badge.valid { border-color: rgba(79,140,255,0.30); color: rgba(169,198,255,0.95); background: rgba(79,140,255,0.10); }
.status-badge.failed,
.status-badge.provider_unreachable,
.status-badge.not_delivered_to_device,
.status-badge.not_sent_to_carrier,
.status-badge.invalid,
.status-badge.cancelled { border-color: rgba(255,90,107,0.35); color: rgba(255,151,162,0.95); background: rgba(255,90,107,0.10); }
.status-badge.blacklisted,
.status-badge.blocked { border-color: rgba(255,201,91,0.30); color: rgba(255,225,168,0.95); background: rgba(255,201,91,0.10); }
.status-badge.unknown { opacity: 0.85; }
.mono, .input-mono, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.mono { letter-spacing: 0.1px; }
.pill {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.field { margin-bottom: 12px; }

.dt-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 12px 0;
}
.card-toolbar { margin: 0 0 10px; }
.dt-left, .dt-right { display: flex; align-items: center; gap: 10px; }
.dt-label { color: var(--muted); font-size: 14px; }
.dt-input, .dt-select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.20);
  color: var(--text);
}
.dt-search {
  position: relative;
  display: flex;
  align-items: center;
}
.dt-search i {
  position: absolute;
  left: 10px;
  color: rgba(255,255,255,0.55);
  pointer-events: none;
}
.dt-search .dt-input { padding-left: 34px; min-width: min(520px, 56vw); }
.dt-clear {
  position: absolute;
  right: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
  color: rgba(255,255,255,0.75);
  border-radius: 10px;
  height: 28px;
  width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-top: 0;
}
.dt-clear:hover { background: rgba(255,255,255,0.06); }
.th-right { text-align: right; }
.th-center { text-align: center; }
.th-link.active { color: var(--text); }
.sort-ind { font-size: 11px; opacity: 0.75; }
.dt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}
.dt-info { color: var(--muted); font-size: 13px; }
.dt-pagination { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.dt-page {
  text-decoration: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.dt-page.active { border-color: rgba(79,140,255,0.35); background: rgba(79,140,255,0.12); }
.dt-page.disabled { opacity: 0.45; pointer-events: none; }
.th-link { color: var(--muted); text-decoration: none; }
.th-link:hover { text-decoration: underline; }
.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
  margin-top: 0;
}
.icon-action:hover { background: rgba(255,255,255,0.06); }
.input-action { width: 42px; height: 42px; border-radius: 12px; }
.icon-action.danger, .icon-action-sm.danger { border-color: rgba(255,90,107,0.25); color: #ff98a3; }
.icon-action.danger:hover, .icon-action-sm.danger:hover { background: rgba(255,90,107,0.10); }

/* Supplier form */
.supplier-form .card { overflow: hidden; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span2 { grid-column: span 2; }
.help { color: var(--muted); font-size: 12px; margin-top: 6px; }
.password-row { display: flex; align-items: center; gap: 10px; }
.password-row input { flex: 1; min-width: 0; }
.input-row { display: flex; align-items: center; gap: 10px; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { height: 42px; }

/* Compact meta cell */
.meta { display: grid; gap: 4px; }
.meta-title { font-weight: 800; }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }

/* Sends table */
.sends-table td, .sends-table th { vertical-align: top; }
.sends-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.td-supplier { font-weight: 650; }
.td-number .mono { color: #cfe0ff; }
.td-status { white-space: nowrap; }
.td-created { white-space: nowrap; }
.td-type { font-weight: 750; }
.td-money { white-space: nowrap; text-align: right; }
.sends-table .actions { text-align: center; }
.sends-table .td-type { white-space: nowrap; }
.input-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.1px;
}

.switch { display: inline-flex; align-items: center; gap: 10px; user-select: none; cursor: pointer; color: var(--text); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  position: relative;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.10);
  transition: left 180ms ease, background 180ms ease, border-color 180ms ease;
}
.switch input:checked + .switch-ui { border-color: rgba(125,255,181,0.25); background: rgba(125,255,181,0.10); }
.switch input:checked + .switch-ui::after { left: 21px; background: rgba(125,255,181,0.35); border-color: rgba(125,255,181,0.25); }

.price-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 44px;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.price-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 44px;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.price-row input { height: 42px; }
.footer-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.profit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.profit-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.profit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.profit-label { font-weight: 850; }
.profit-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.profit-pos { color: #7dffb5; font-weight: 700; }
.profit-neg { color: var(--danger); font-weight: 700; }
.mini-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  color: rgba(255,255,255,0.85);
  font-size: 12px;
  white-space: nowrap;
}
.hint { font-size: 12px; margin-top: 10px; }
.card-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 16px; }
.card-section-head h3 { margin: 0; font-size: 14px; letter-spacing: 0.2px; }

.modal { display: none; }
.modal.open { display: block; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.danger-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,90,107,0.35);
  background: rgba(255,90,107,0.12);
}
button[disabled], .btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 50;
}
.modal-card {
  position: fixed;
  z-index: 60;
  inset: 0;
  margin: auto;
  width: min(920px, 94vw);
  max-height: min(86vh, 860px);
  overflow: hidden;
  background: rgba(16, 26, 47, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 850; font-size: 16px; }
.modal-body { padding: 14px 16px 18px; overflow: auto; height: calc(100% - 64px); }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.modal-grid .span2 { grid-column: span 2; }
.modal-grid .k { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.modal-grid .v { font-weight: 600; word-break: break-word; }
.pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.18);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: #cfe0ff;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .dash-grid-2 { grid-template-columns: 1fr; }
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .topbar { position: relative; }
  .dt-toolbar, .dt-footer { flex-direction: column; align-items: flex-start; }
  .dt-pagination { justify-content: flex-start; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-left { display: none; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .price-head { display: none; }
  .price-row { grid-template-columns: 1fr; }
  .price-row .icon-action { justify-self: flex-end; }
  .footer-actions { justify-content: flex-start; width: 100%; flex-wrap: wrap; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-grid .span2 { grid-column: span 1; }
  .profit-grid { grid-template-columns: 1fr; }
}
