@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&family=Outfit:wght@300;400;500&family=Sora:wght@400;500;600&display=swap');

:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --ink: #1a2b3c;
  --muted: #6b7c8f;
  --line: #d8e0e8;
  --sidebar: #1e3a5f;
  --sidebar-hover: #254a75;
  --sidebar-active: #2d5a8e;
  --accent: #2ecc71;
  --accent-dark: #27ae60;
  --accent-blue: #3498db;
  --danger: #e74c3c;
  --pill-sim: #fef3c7;
  --pill-live: #d1fae5;
  --country-active: #e8f4fd;
  --country-active-border: #3498db;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ── Shell: sidebar + main ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  min-height: 100vh;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand-icon {
  font-size: 1.35rem;
  color: var(--accent);
}

.nav-ico {
  width: 1.1rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.9;
  flex-shrink: 0;
}

.sidebar-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.sidebar-reset:hover {
  background: rgba(0,0,0,0.2);
  color: #fff;
}

.country-iso {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  background: rgba(0,0,0,0.06);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.country-card.active .country-iso {
  background: rgba(52,152,219,0.15);
  color: var(--accent-blue);
}

.locked-icon {
  font-size: 2.5rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
}

/* Main nav — bright */
.nav-main,
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.92);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-main:hover,
.nav-group-head:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-main.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

/* Group parent */
.nav-group-head {
  justify-content: space-between;
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-group.open .nav-group-head {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.nav-group.open .nav-chevron {
  transform: rotate(0deg);
}

.nav-chevron {
  font-size: 0.65rem;
  opacity: 0.5;
  transform: rotate(-90deg);
  transition: transform 0.2s;
}

.nav-sub {
  display: none;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.2rem 0 0.35rem 0.5rem;
}

.nav-group.open .nav-sub {
  display: flex;
}

/* Sub nav — dimmed */
.nav-sub-btn {
  display: block;
  width: 100%;
  padding: 0.45rem 0.85rem 0.45rem 2rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(255,255,255,0.38);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}

.nav-sub-btn:hover {
  color: rgba(255,255,255,0.65);
  background: rgba(0,0,0,0.12);
}

.nav-sub-btn.active {
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.06);
  font-weight: 500;
}

.nav-sub-dim {
  color: rgba(255,255,255,0.28);
}

.nav-sub-dim:hover {
  color: rgba(255,255,255,0.45);
}

/* Legacy — remove old button styles */
.sidebar-nav button.nav-main,
.sidebar-nav button.nav-group-head,
.sidebar-nav button.nav-sub-btn {
  /* covered above */
}

.sidebar-nav button {
  /* fallback */
}

.sidebar-foot {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.balance-box {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
}

.balance-lbl {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
}

.balance-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
}

/* ── Main area ── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.main-content {
  padding: 2rem 2.5rem;
  flex: 1;
  max-width: 820px;
  width: 100%;
}

.page-head {
  margin-bottom: 1.75rem;
}

.page-head h1 {
  font-family: 'Sora', system-ui, sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.35rem;
  letter-spacing: -0.02em;
}

.page-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-intro { margin-bottom: 1.25rem; }
.section-intro h1 { font-size: 1.5rem; font-family: 'Sora', system-ui, sans-serif; margin-bottom: 0.2rem; }
.lead { color: var(--muted); font-size: 0.9rem; }

/* Stats row — Reports */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem 1.25rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(26,43,60,0.04);
}

.stat-card .stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: #2980b9;
  line-height: 1.2;
  margin-bottom: 0.4rem;
  word-break: break-word;
}

.stat-card .stat-lbl {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card.live .stat-val { color: var(--accent-dark); }

.view { display: none; }
.view.active { display: block; }

.country-section {
  margin-bottom: 1rem;
}

.country-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--ink);
}

.country-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.country-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
  user-select: none;
}

.country-card .flag { font-size: 1.2rem; line-height: 1; }
.country-card .code { font-size: 0.72rem; color: var(--muted); }

.country-card.active {
  border-color: var(--country-active-border);
  background: var(--country-active);
  box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.country-card.foreign {
  opacity: 0.38;
  filter: grayscale(0.6);
  cursor: not-allowed;
  position: relative;
}

.country-card.foreign::after {
  content: 'SMSEdge';
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 0.55rem;
  font-weight: 700;
  background: #95a5a6;
  color: #fff;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.country-card.foreign:hover {
  opacity: 0.5;
}

/* ── Route picker ── */
.route-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.route-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.82rem;
  min-width: 130px;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s;
  user-select: none;
  text-align: left;
}

.route-card .route-name { font-weight: 600; }
.route-card .route-price { font-size: 0.72rem; color: var(--muted); }

.route-card.active {
  border-color: var(--accent-dark);
  background: #edfbf3;
  box-shadow: 0 0 0 3px rgba(39,174,96,0.12);
}

.route-card.foreign {
  opacity: 0.38;
  filter: grayscale(0.5);
  cursor: not-allowed;
}

.route-card.foreign .route-badge {
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  background: #95a5a6;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  align-self: flex-start;
}

.routes-country-block {
  margin-bottom: 1.25rem;
}

.routes-country-block.active {
  opacity: 1;
}

.routes-country-block.foreign {
  opacity: 0.32;
  filter: grayscale(0.7);
  pointer-events: none;
}

.routes-country-block.foreign .route-card {
  cursor: not-allowed;
}

.routes-country-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.routes-country-head .flag { font-size: 1.1rem; }

.routes-country-head .provider-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--accent-dark);
  color: #fff;
}

.routes-country-head .provider-tag.smsedge {
  background: #95a5a6;
}

.foreign-routes { margin-top: 1rem; justify-content: center; }

/* Page tabs (SMSEdge style) */
.page-tabs {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}

.page-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.15rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent-blue);
  cursor: pointer;
  margin-bottom: -1px;
}

.page-tab.active {
  border-bottom-color: var(--accent-blue);
  font-weight: 600;
}

.page-tab.dim {
  color: var(--muted);
  opacity: 0.45;
  cursor: not-allowed;
}

/* Empty state */
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3.5rem 2rem;
  text-align: center;
  max-width: 520px;
}

.empty-icon {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: #eef2ff;
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.empty-state h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.btn-accent {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: #6366f1;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
}

.btn-accent:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.routes-main-block {
  margin-bottom: 1.5rem;
}

.routes-sub-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.5;
  margin: 1.5rem 0 0.75rem;
}

/* ── Send form (SMS Office style) ── */
.send-panel, .panel-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.so-form .form-row {
  margin-bottom: 1.1rem;
}

.so-form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.req { color: var(--danger); }

.so-form input,
.so-form textarea,
.so-form select,
.panel-card input,
.panel-card select {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  background: #fafbfc;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.so-form input:focus,
.so-form textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(52,152,219,0.12);
}

.field-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

.char-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.form-options { margin-bottom: 1rem; }

.check-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.check-opt input { width: auto; margin-top: 0.15rem; }
.opt-hint { color: var(--muted); font-size: 0.75rem; }

.form-actions { padding-top: 0.25rem; }

.btn-send {
  padding: 0.7rem 2rem;
  border: none;
  border-radius: 8px;
  background: var(--accent-dark);
  color: #fff;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-send:hover { background: var(--accent); }
.btn-send:active { transform: scale(0.98); }

.btn-secondary {
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: var(--sidebar);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-secondary:hover { background: var(--sidebar-hover); }

/* Foreign locked panel */
.send-panel-locked {
  text-align: center;
  padding: 3rem 2rem;
}

.locked-overlay h3 { margin-bottom: 0.5rem; }
.locked-overlay p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ── Stats / tables ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.stat .val { font-size: 1.6rem; font-weight: 700; color: var(--accent-blue); }
.stat .lbl { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; text-transform: uppercase; letter-spacing: 0.04em; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

.panel-card h3 { font-size: 0.95rem; margin-bottom: 0.85rem; }
.panel-card label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.75rem; }

.table-wrap { overflow-x: auto; font-size: 0.85rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #e7e5e4;
}
.badge.good { background: #d1fae5; color: #065f46; }

.pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  text-align: center;
}
.pill.sim { background: var(--pill-sim); color: #92400e; }
.pill.live { background: var(--pill-live); color: #065f46; }

.result-pre {
  margin-top: 1rem;
  background: #1a2b3c;
  color: #a8b8c8;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.75rem;
  overflow-x: auto;
  max-height: 240px;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }
.hidden-section { display: none !important; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 200;
}

/* Smarty footer */
.smarty-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.85rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  width: 100%;
}

.smarty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: smartyBlink 4s ease-in-out infinite;
}

.smarty-label {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a8a29e;
}

@keyframes smartyBlink {
  0%, 100% { background: #22c55e; box-shadow: 0 0 6px 1px rgba(34,197,94,0.55); }
  50% { background: #ef4444; box-shadow: 0 0 6px 1px rgba(239,68,68,0.55); }
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }
  .sidebar-foot { display: none; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .main-content { padding: 1rem; }
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1e3a5f 0%, #2d5a8e 45%, #eef2f6 45%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem 2rem 1.75rem;
  box-shadow: 0 18px 50px rgba(26, 43, 60, 0.18);
}

.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: 2rem;
  color: var(--accent);
}

.login-card h1 {
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.login-form input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

.login-btn {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.7rem;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  text-align: center;
}
