:root {
  --background: #e7f0f2;
  --panel: #fdfefe;
  --card: #eef4f5;
  --primary: #0f3545;
  --primary-strong: #0c2b39;
  --accent: #cddc00;
  --text: #0c1f26;
  --muted: #335057;
  --border: #c7d4d6;
  --danger: #dc2626;
  --shadow: 0 12px 30px rgba(12, 31, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Assistant", "Heebo", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(12, 43, 57, 0.08), transparent 25%),
    radial-gradient(circle at 80% 0%, rgba(205, 220, 0, 0.12), transparent 25%),
    var(--background);
  color: var(--text);
  min-height: 100vh;
}

#appShell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

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

.hidden {
  display: none !important;
}

.topbar {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  width: 100%;
}

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

.brand h1 {
  margin: 2px 0 6px;
  letter-spacing: 0.5px;
}

.brand .pill {
  background: rgba(205, 220, 0, 0.16);
  color: var(--primary);
  display: inline-block;
  padding: 6px 12px;
  border-radius: 0;
  font-weight: 700;
  margin: 0 0 6px;
}

.brand p {
  margin: 0;
  color: var(--muted);
}

.brand-logo {
  height: 56px;
  width: auto;
  border-radius: 0;
  box-shadow: 0 6px 18px rgba(12, 31, 38, 0.12);
  display: none;
}

.emphasize {
  color: var(--primary-strong);
  font-weight: 700;
}

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

.unassigned-widget {
  background: rgba(205, 220, 0, 0.12);
  border: 1px solid rgba(12, 43, 57, 0.2);
  border-radius: 0;
  padding: 10px 12px;
  text-align: center;
  min-width: 180px;
}

.unassigned-widget .meta-value {
  margin: 4px 0 0;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 0;
  background: #edf3f4;
  border: 1px solid var(--border);
}

.user-name {
  margin: 0;
  font-weight: 700;
}

.user-email {
  color: var(--muted);
  font-size: 14px;
}

.layout {
  grid-column: 2;
  grid-row: 2;
  display: block;
  padding: 0;
}

.sidebar {
  position: fixed;
  inset: 0 0 0 auto;
  width: 260px;
  background: #14645b;
  color: #ffffff;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: none;
  box-shadow: var(--shadow);
  z-index: 3;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-logo {
  width: 160px;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.sidebar-title {
  font-weight: 900;
  letter-spacing: 0.5px;
  font-size: 20px;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.nav-link {
  width: 100%;
  text-align: right;
  padding: 10px 4px;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 18px;
  border-radius: 0;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.15s ease;
}

.nav-link.active,
.nav-link:hover {
  background: transparent;
  color: #cddc00;
  font-weight: 800;
  transform: translateX(-2px);
}

.content {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 18px;
  box-shadow: var(--shadow);
  display: none;
}

.section.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.section-header h2 {
  margin: 0 0 4px;
}

.section-header p {
  margin: 0;
  color: var(--muted);
}

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

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card.wide {
  grid-column: span 2;
  min-height: 180px;
}

.card-label {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card-value {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 800;
}

.card-subvalue {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  background: rgba(205, 220, 0, 0.18);
  color: var(--primary);
  padding: 8px 12px;
  border-radius: 0;
  border: 1px solid rgba(12, 43, 57, 0.25);
  font-weight: 700;
}

.budget-progress {
  display: grid;
  gap: 12px;
}

.progress-row {
  display: grid;
  gap: 8px;
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-bar {
  height: 10px;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar.small {
  height: 8px;
}

.progress-fill {
  background: linear-gradient(90deg, var(--primary-strong), var(--accent));
  height: 100%;
  width: 0;
  transition: width 0.3s ease;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

th {
  background: rgba(12, 43, 57, 0.06);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: none;
}

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

.positive {
  color: var(--primary);
}

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 0;
  padding: 10px 14px;
  font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: #ffffff;
  border: 1px solid rgba(12, 43, 57, 0.4);
}

.secondary {
  background: rgba(12, 43, 57, 0.08);
  color: var(--primary-strong);
  border: 1px solid rgba(12, 43, 57, 0.35);
}

.ghost {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}

.danger {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.35);
}

.small {
  padding: 8px 10px;
  font-size: 14px;
}

.auth-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at 80% 20%, rgba(205, 220, 0, 0.12), transparent 35%), var(--background);
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 24px;
  width: min(420px, 100%);
  box-shadow: var(--shadow);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.auth-actions {
  margin-top: 16px;
}

.auth-form label {
  font-weight: 700;
  font-size: 14px;
}

.auth-form input {
  width: 100%;
  padding: 10px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #ffffff;
  color: #111827;
  font-weight: 700;
  border-radius: 0;
  padding: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.google-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.3);
}

.google-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: #4285f4;
  color: #fff;
  border-radius: 0;
  font-weight: 900;
}

.full {
  width: 100%;
}

.modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 5;
}

.modal-card {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
}

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

.stacked-form {
  grid-template-columns: 1fr;
}

.account-form {
  grid-template-columns: 1fr;
  gap: 16px;
}

.account-form input,
.account-form select {
  padding: 12px 14px;
  font-size: 16px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--text);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 10px;
  color: var(--text);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.type-toggle {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.type-toggle button.active {
  background: rgba(205, 220, 0, 0.2);
  color: var(--primary-strong);
  border-color: rgba(12, 43, 57, 0.45);
}

.switch-field {
  border: 1px solid var(--border);
  padding: 12px 14px;
  background: #f8fafc;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--muted);
}

.switch-label {
  font-size: 14px;
}

.switch-toggle {
  position: relative;
  width: 72px;
  height: 32px;
  background: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-toggle .switch-knob {
  width: 24px;
  height: 24px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease;
}

.switch-toggle.active {
  background: rgba(205, 220, 0, 0.25);
  border-color: rgba(12, 43, 57, 0.3);
}

.switch-toggle.active .switch-knob {
  transform: translateX(36px);
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.envelope-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: flex-start;
  direction: ltr;
}

.chip {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  border-radius: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
}

.meta-value {
  font-size: 20px;
  font-weight: 800;
}

.envelope-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  direction: rtl;
  grid-column: 2;
}

.envelope-card {
  display: grid;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.envelope-list {
  display: grid;
  gap: 8px;
}

.envelope-list-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: #fff;
}

.envelope-card-header {
  align-items: center;
  gap: 12px;
}

.group-summary {
  margin-top: 4px;
}

.group-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.group-actions .add-envelope-btn {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.group-row:hover .group-actions .add-envelope-btn {
  opacity: 1;
}

.group-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
}

.group-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-title {
  margin: 0;
}

.group-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-totals {
  display: flex;
  gap: 12px;
  color: var(--muted);
}

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

.envelope-row {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 8px 12px;
  min-height: 40px;
  border-bottom: 1px solid #cfd6e4;
}

.envelope-row.add-row {
  grid-template-columns: 1fr;
  justify-items: center;
}

.envelope-row.heading {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 800;
}
.envelope-row.data:last-of-type {
  border-bottom: none;
}

.envelope-row.add-row {
  border-bottom: none;
}

.envelope-row.data:hover {
  background: #f1f6f7;
  cursor: pointer;
}

.envelope-row.selected {
  background: rgba(205, 220, 0, 0.2);
}

.envelope-name {
  margin: 0 0 4px;
}

.envelope-primary {
  display: grid;
  gap: 4px;
}

.envelope-metric {
  font-weight: 700;
  color: var(--text);
}

.envelope-metric.strong {
  font-size: 18px;
}

.envelope-actions {
  display: none;
}

.ghost.circle {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}

.envelope-list.hidden {
  display: none;
}

.envelope-list-table.hidden {
  display: none;
}

.envelope-drawer {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--shadow);
  padding: 14px;
  position: sticky;
  top: 110px;
  min-height: 260px;
  direction: rtl;
  grid-column: 1;
}

.drawer-empty {
  text-align: center;
  padding: 24px 12px;
}

.drawer-content {
  display: grid;
  gap: 14px;
}

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

.drawer-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.drawer-summary .metric {
  background: rgba(148, 163, 184, 0.12);
  padding: 10px;
  border-radius: 0;
}

.drawer-summary .metric strong {
  display: block;
  margin-bottom: 6px;
}

.drawer-history {
  display: grid;
  gap: 8px;
}

.drawer-history-heading h4 {
  margin: 0;
}

.history-list {
  display: grid;
  gap: 6px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 0;
}

.drawer-actions {
  display: grid;
  gap: 8px;
}

.drawer-actions .full {
  width: 100%;
  text-align: center;
}

@media (max-width: 1100px) {
  .envelope-layout {
    grid-template-columns: 1fr;
  }

  .envelope-drawer {
    position: relative;
    top: auto;
  }

  .envelope-grid {
    grid-column: 1;
  }
}

.subtle {
  background: rgba(255, 255, 255, 0.02);
}

.icon {
  margin-left: 6px;
  font-weight: 900;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}

.badge {
  display: inline-block;
  background: rgba(205, 220, 0, 0.2);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 0;
  font-size: 12px;
  margin-right: 4px;
}

.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 0;
  border: 1px solid rgba(12, 43, 57, 0.25);
  background: rgba(205, 220, 0, 0.12);
  margin-bottom: 14px;
}

.banner-title {
  margin: 0 0 6px;
  font-weight: 800;
}

.banner-list {
  margin: 0;
  padding-left: 18px;
}

.banner-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.checkbox-inline {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.checkbox-inline input {
  margin-top: 6px;
}

.admin-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  background: var(--background);
}

.admin-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  margin: 0;
}

.admin-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 18px 24px 24px;
}

.admin-menu {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow);
}

.admin-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-user-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-list li {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.admin-user-list li.active {
  border-color: var(--primary);
  background: #e9f0f1;
}

.admin-user-list .user-role {
  font-size: 13px;
  color: var(--muted);
}

.admin-user-list .user-status {
  font-size: 13px;
  color: var(--primary-strong);
}

.admin-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-activity-panel {
  padding: 18px;
}

.admin-meta {
  text-align: right;
}

@media (max-width: 960px) {
  #appShell {
    grid-template-columns: 1fr;
  }

  .topbar,
  .layout {
    grid-column: 1;
  }

  .layout {
    padding: 0;
  }

  .sidebar {
    position: static;
    width: 100%;
    inset: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }

  .sidebar ul {
    margin: 0;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .card.wide {
    grid-column: span 1;
  }
}
