:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #e8ecf4;
  --text: #1f2735;
  --muted: #6f7b90;
  --primary: #0b3b82;
  --accent: #ff8c3a;
  --accent-2: #f25c4a;
  --shadow: 0 14px 40px rgba(28, 42, 64, 0.08);
  --shadow-soft: 0 10px 30px rgba(28, 42, 64, 0.05);
}

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

body {
  margin: 0;
  font-family: "Manrope", "Poppins", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 18px;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 26, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.16);
  border: 1px solid var(--line);
}

.modal-box h3 {
  margin: 0 0 8px 0;
}

.modal-box p {
  margin: 0 0 16px 0;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.plan-edit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: auto;
  padding: 8px 10px;
  background: #0b3b82;
  color: #fff;
  border: 1px solid #0b3b82;
  box-shadow: 0 10px 20px rgba(11, 59, 130, 0.14);
  font-size: 12px;
}

.plan-edit-btn:hover {
  box-shadow: 0 10px 26px rgba(11, 59, 130, 0.18);
}

#plan-edit-modal .modal-box {
  max-width: 560px;
  width: 100%;
}

.plan-edit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plan-edit-head .close-plan-edit {
  width: auto;
  min-width: 44px;
  padding: 10px 12px;
}

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

.plan-edit-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.plan-edit-form input,
.plan-edit-form textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 14px;
  font-family: inherit;
}

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

.plan-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.plan-edit-actions button {
  width: auto;
}

.btn-secondary {
  background: #fff;
  color: #1f2735;
  border: 1px solid var(--line);
  box-shadow: none;
}

.logged-out .nav-list .nav-item:not(.plan-link),
.logged-out .nav-accordion summary {
  pointer-events: none;
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(1);
}

.nav-accordion {
  margin-top: 8px;
}

.nav-accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 14px;
  border-radius: 10px;
  color: #4a5160;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.nav-accordion summary::-webkit-details-marker {
  display: none;
}

.nav-accordion[open] summary {
  background: #eef2f9;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.nav-accordion .chevron {
  margin-left: auto;
  transition: transform 0.2s ease;
}

.nav-accordion[open] .chevron {
  transform: rotate(180deg);
}

.nav-accordion ul {
  list-style: none;
  margin: 0;
  padding: 6px 0 10px 8px;
  display: grid;
  gap: 6px;
}

.nav-accordion ul a {
  display: block;
  padding: 10px 12px 10px 40px;
  border-radius: 10px;
  color: #6a7486;
  font-weight: 700;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-accordion ul a:hover {
  background: #f3f5fa;
  color: #273245;
}

.app-main {
  padding: 18px 18px 40px;
  background: var(--bg);
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  background: #fff;
  color: #1f2735;
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 30px;
}

.topbar-header .topbar-brand {
  display: none;
}

.topbar-header .topbar-brand.desktop {
  display: inline-flex;
}

.topbar-header .topbar-brand.mobile-only {
  display: none;
}

.topbar-brand {
  padding: 8px 10px;
  width: auto;
  box-shadow: none;
  border: 1px solid var(--line);
}

.topbar-toggle {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  display: none;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  position: absolute;
  right: 30px;
}

.topbar-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 140, 58, 0.4);
}

.topbar-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  letter-spacing: 1px;
  font-size: 24px;
  font-weight: 800;
}

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

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

.profile {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--accent-2);
  font-weight: 800;
}

.profile-menu {
  position: relative;
  display: inline-block;
}

.profile-actions {
  position: absolute;
  right: 0;
  top: 48px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  padding: 8px;
  display: none;
  min-width: 160px;
  z-index: 10;
}

.profile-actions a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.profile-actions a:hover {
  background: #f3f5fa;
}

.profile-menu.open .profile-actions {
  display: block;
}
.shell {
  max-width: none;
  margin: 0;
  padding: 20px 18px 48px;
}

.header {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 16px 40px rgba(242, 92, 74, 0.26);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #fff;
  color: var(--accent-2);
  display: grid;
  place-items: center;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 700;
}

.intro {
  margin: 18px 0;
  font-size: 16px;
  color: var(--muted);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 12px;
}

.plan-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.plan-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 140, 58, 0.25);
  box-shadow: 0 16px 40px rgba(28, 42, 64, 0.12);
  background: linear-gradient(135deg, rgba(255, 140, 58, 0.04), #fff);
}

.plan-card h3 {
  margin: 0 0 6px 0;
}

.plan-price {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  background: #f1f3f8;
  color: #6b7383;
}

button {
  border: none;
  cursor: pointer;
  font-weight: 700;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  background: #fff;
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--line);
  width: 100%;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 140, 58, 0.35);
}

.plan-card.popular {
  border: 2px solid var(--accent);
  box-shadow: 0 12px 30px rgba(242, 92, 74, 0.22);
  background: linear-gradient(135deg, rgba(255, 140, 58, 0.06), #fff);
}

.plan-card.popular button {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  box-shadow: 0 10px 24px rgba(242, 92, 74, 0.25);
}

.plan-card.popular button:hover {
  box-shadow: 0 12px 30px rgba(242, 92, 74, 0.3);
}

.selected-plan-btn {
  background: #0b3b82;
  color: #fff;
  border: 1px solid #0b3b82;
  box-shadow: 0 10px 24px rgba(11, 59, 130, 0.2);
}

.plan-card.current-plan .selected-plan-btn:hover {
  transform: none;
}

.plan-card.current-plan {
  border: 2px solid var(--accent-2);
  box-shadow: 0 18px 42px rgba(242, 92, 74, 0.2);
}

.current-plan-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--accent-2);
  color: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(242, 92, 74, 0.22);
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.current-plan-credit {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
}

.table-wrap {
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  overflow-x: auto;
  padding-bottom: 4px;
  max-width: 100%;
  display: block;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  background: linear-gradient(120deg, #f1f4fa, #e6ebf5);
  color: #4a5160;
  font-size: 15px;
}

tr:nth-child(even) td {
  background: #f9fbff;
}

.green {
  color: #33a852;
  font-weight: 800;
}

.summary {
  padding: 16px 14px 18px;
  font-weight: 800;
  font-size: 16px;
}

.subtext {
  padding: 0 14px 16px;
  color: var(--muted);
}

.footer-links {
  margin-top: 10px;
  display: flex;
  gap: 12px;
}

@media (max-width: 900px) {
  body {
    font-size: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .nav-item,
  .nav-accordion summary {
    padding: 12px 12px;
    font-size: 15px;
  }

  .nav-accordion ul a {
    padding: 10px 12px 10px 32px;
  }

  .app-main {
    padding: 12px 12px 110px;
  }

  .topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  background: #fff;
  color: #1f2735;
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(28, 42, 64, 0.08);
  position: sticky;
  top: 0;
  z-index: 5;
  }

  .topbar-header .topbar-brand {
    display: inline-flex;
  }

  .topbar-header .topbar-brand.desktop {
    display: none;
  }

  .topbar-header .topbar-brand.mobile-only {
    display: inline-flex;
  }

  .topbar h1 {
    font-size: 20px;
    letter-spacing: 0.5px;
  }

  .topbar-details {
    display: none !important;
  }

  .topbar.open .topbar-details {
    display: none !important;
  }

  .topbar-toggle {
    display: grid;
  }

  .profile {
    padding: 4px 6px;
  }

  .shell {
    padding: 14px;
  }

  .plan-grid {
    grid-template-columns: 1fr;
  }

  .plan-card {
    padding: 14px;
  }

  th,
  td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .footer-links {
    flex-direction: column;
  }

  .app-main {
    padding-bottom: 110px;
  }

  .mobile-nav {
    display: block;
  }
}

@media (max-width: 620px) {
  .table-wrap {
    margin-left: -6px;
    margin-right: -6px;
    padding-left: 6px;
    padding-right: 6px;
  }

  table {
    min-width: 420px;
  }
}

@media (min-width: 901px) {
  .mobile-nav {
    display: none !important;
  }

  .topbar-header .topbar-brand {
    display: none !important;
  }

  .topbar-header .topbar-brand.desktop {
    display: inline-flex !important;
  }

  .topbar-header .topbar-brand.mobile-only {
    display: none !important;
  }

  .topbar-toggle {
    display: none !important;
  }

  .topbar-details {
    display: flex !important;
  }
}

@media (max-width: 1040px) and (min-width: 901px) {
  .plan-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .app-shell {
    grid-template-columns: 200px 1fr;
  }
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
  padding: 8px 10px env(safe-area-inset-bottom);
  z-index: 1200;
}

.mobile-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mobile-nav a {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  font-size: 13px;
}

.mobile-nav .icon {
  font-size: 18px;
}

.mobile-nav a.active {
  border-color: rgba(255, 140, 58, 0.35);
  background: rgba(255, 140, 58, 0.12);
  color: var(--text);
}
