:root {
  --bg: #f4f2ea;
  --surface: rgba(255, 253, 248, 0.94);
  --line: #d8d2c4;
  --text: #0c3b33;
  --muted: #61756f;
  --accent: #0f5a46;
  --accent-2: #14795f;
  --success: #0a7f55;
  --warning: #b45309;
  --pending: #fef3c7;
  --paid: #dbeafe;
  --done: #dcfce7;
  --shadow: 0 20px 40px rgba(23, 41, 32, 0.06);
  font-family: "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(15, 90, 70, 0.08), transparent 30%),
    linear-gradient(180deg, #f7f4ec 0%, #efe8d7 100%);
}
.hidden { display: none !important; }
.main-shell h1,
.main-shell h2,
.main-shell h3,
.login-panel h2,
.login-hero h1 {
  letter-spacing: -0.02em;
}
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.login-hero {
  background: linear-gradient(180deg, #0f5a46 0%, #1b6d59 100%);
  color: white;
  padding: 72px;
  display: grid;
  align-content: center;
  gap: 24px;
}
.login-hero img { width: 64px; border-radius: 8px; }
.login-hero h1 { margin: 0; font-size: clamp(2.2rem, 4vw, 4rem); line-height: 1.1; max-width: 580px; }
.login-hero p { margin: 0; max-width: 520px; color: #d7efe5; font-size: 1.15rem; }
.login-panel {
  padding: 72px min(7vw, 88px);
  display: grid;
  align-content: center;
  gap: 18px;
  background: linear-gradient(180deg, #fffdfa 0%, #f8f4eb 100%);
}
.panel-card, .card {
  background: var(--surface);
  border: 1px solid rgba(117, 96, 64, 0.16);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}
label { display: grid; gap: 8px; font-weight: 700; }
input, select, button {
  font: inherit;
  border-radius: 12px;
}
input, select {
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: white;
}
button {
  min-height: 46px;
  border: 0;
  cursor: pointer;
}
.solid-button { background: var(--accent); color: white; }
.solid-button:hover { background: #0b4c3b; }
.ghost-button { background: white; color: var(--text); border: 1px solid var(--line); }
.ghost-button:hover { background: #f7f4ec; }
.link-button { background: transparent; color: var(--accent); padding: 0; min-height: auto; text-align: left; font-weight: 700; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar {
  background: linear-gradient(180deg, #0f5a46 0%, #0c4a3b 100%);
  color: white;
  padding: 28px;
  border-right: 1px solid rgba(255,255,255,.08);
}
.brand { display: grid; gap: 14px; }
.brand img { width: 36px; height: 24px; border-radius: 4px; object-fit: cover; }
.brand-title { margin: 0 0 14px; color: #d2f0e4; line-height: 1.4; }
.pill {
  background: rgba(16, 185, 129, 0.18);
  color: white;
  padding: 6px 12px;
  border-radius: 999px;
  display: inline-block;
  font-size: .8rem;
  font-weight: 700;
}
.nav-list { margin-top: 36px; display: grid; gap: 8px; }
.nav-item {
  padding: 12px 14px;
  border-radius: 14px;
  background: transparent;
  color: white;
  text-align: left;
  font-weight: 600;
}
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,.1); }
.main-shell { padding-bottom: 32px; }
.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar h1 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}
.profile-strip {
  display: flex;
  align-items: center;
  gap: 18px;
}
.profile-copy {
  display: grid;
  justify-items: end;
  gap: 2px;
}
.profile-copy strong {
  font-size: 1.05rem;
}
.role-switcher, .content-grid { padding: 26px 28px 0; }
.role-switcher { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; color: var(--success); }
.hero-grid, .stats-grid, .dual-grid { display: grid; gap: 16px; }
.page-intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.page-intro h2 {
  margin: 0 0 6px;
  font-size: 2.25rem;
}
.split-intro {
  align-items: center;
}
.page-intro .muted {
  font-size: 1.05rem;
}
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.justice-stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.dual-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.intro-card {
  background: linear-gradient(135deg, rgba(15, 90, 70, 0.08), rgba(255, 255, 255, 0.92));
}
.intro-card h3 {
  margin: 0 0 8px;
  font-size: 2rem;
}
.stat-card strong { display: block; margin-top: 12px; font-size: 2rem; }
.stat-card {
  min-height: 110px;
  display: grid;
  align-content: center;
}
.chart-card { min-height: 360px; }
.chart-card h3,
.card h3 {
  margin-top: 0;
}
.donut-wrap {
  display: flex;
  justify-content: center;
  padding: 34px 0 18px;
}
.donut-ring {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(#0f5a46 0 12%, #f59e0b 12% 82%, #1d4ed8 82% 100%);
  position: relative;
}
.donut-ring::after {
  content: "";
  position: absolute;
  inset: 22px;
  background: white;
  border-radius: 50%;
}
.legend-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.legend-row span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.legend-paid { background: #0f5a46; }
.legend-completed { background: #f59e0b; }
.legend-pending { background: #1d4ed8; }
.bars { display: grid; gap: 16px; margin-top: 20px; }
.government-bars .bar-track,
.region-bars .bar-track {
  height: 16px;
}
.bar-row { display: grid; gap: 10px; }
.bar-track { background: #e9e2d4; height: 14px; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.list-stack, .application-list { display: grid; gap: 14px; }
.list-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.section-head h3 {
  margin-bottom: 0;
}
.item-row, .transaction-row, .application-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #ece5d8;
}
.transaction-row strong,
.application-row strong {
  font-size: 1rem;
}
.status-chip {
  border-radius: 999px;
  padding: 6px 10px;
  text-transform: uppercase;
  font-size: .75rem;
  font-weight: 700;
}
.status-chip.completed, .status-chip.active { background: var(--done); color: var(--success); }
.status-chip.paid { background: var(--paid); color: #1d4ed8; }
.status-chip.pending { background: var(--pending); color: var(--warning); }
.status-chip.returned, .status-chip.rejected { background: #fee2e2; color: #b91c1c; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1000px; }
th, td { padding: 12px; border-bottom: 1px solid #ece5d8; text-align: left; white-space: nowrap; }
.muted { color: var(--muted); }
.inline-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.error { color: #b91c1c; }
.success-text { color: var(--success); font-weight: 700; }
.creds-card p { margin: 6px 0; }
.small-line { font-size: .92rem; }
.credentials-panel {
  border: 1px solid rgba(15, 90, 70, 0.2);
  background: linear-gradient(180deg, rgba(223,240,231,.55), rgba(255,253,248,.98));
}
.credentials-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.credentials-grid p { margin: 6px 0 0; }
.filters-card h3 { margin-top: 0; }
.filters-card {
  padding-bottom: 14px;
  background: linear-gradient(180deg, rgba(255,253,248,.98), rgba(250,247,239,.98));
}
.filters-inline select {
  min-width: 190px;
}
.compact-actions .solid-button,
.compact-actions .ghost-button {
  min-height: 38px;
  padding: 8px 12px;
}
.filter-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}
.placeholder-card {
  min-height: 220px;
  display: grid;
  align-content: start;
}
.finance-stats {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.search-box {
  min-width: 280px;
}
.note-line {
  margin-top: 10px;
}
.tax-groups {
  display: grid;
  gap: 22px;
}
.tax-group-card h3 {
  margin-top: 0;
}
.tax-group-card table {
  min-width: 0;
}
.region-bars {
  margin-top: 34px;
}
.page-intro + .stats-grid,
.page-intro + .justice-stats,
.page-intro + .card,
.page-intro + .filters-card {
  margin-top: 2px;
}
.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.full-width { grid-column: 1 / -1; }
textarea {
  min-height: 120px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  font: inherit;
  resize: vertical;
}
tbody tr:hover {
  background: rgba(15, 90, 70, 0.04);
}
thead th {
  color: #56766b;
  font-weight: 700;
}

/* Accordion Specifics for Notaries List */
details.application-row {
  transition: all 0.25s ease;
}
details.application-row[open] {
  background: var(--surface);
  border-left: 3px solid var(--accent);
}
details.application-row summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none; /* Hide default triangle */
  cursor: pointer;
  padding-right: 12px; /* Space for custom icon */
  position: relative;
}
details.application-row summary::-webkit-details-marker {
  display: none;
}
details.application-row summary::after {
  content: "▼";
  font-size: 0.85rem;
  color: var(--primary);
  transition: transform 0.25s ease;
}
details.application-row[open] summary::after {
  transform: rotate(180deg);
}
.accordion-content {
  padding-top: 15px;
  margin-top: 15px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

/* Audit Log Badges */
.badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--line);
  color: #444;
}
.badge.login { background: #e3f2fd; color: #1976d2; }
.badge.approve_application { background: #e8f5e9; color: #2e7d32; }
.badge.renew_license { background: #fff3e0; color: #ef6c00; }
.badge.reset_notary_password, .badge.reset_staff_password { background: #fce4ec; color: #c2185b; }
.badge.delete_staff { background: #ffebee; color: #c62828; }

.user-cell {
  display: flex;
  flex-direction: column;
}
.user-cell strong { font-size: 0.95rem; }
.small { font-size: 0.8rem; }

@media (max-width: 960px) {
  .login-shell, .app-shell { grid-template-columns: 1fr; }
  .login-hero, .login-panel { padding: 32px 20px; }
  .topbar, .role-switcher, .item-row, .transaction-row, .application-row, .page-intro, .section-head { flex-direction: column; align-items: flex-start; }
  .profile-copy { justify-items: start; }
  .search-box { min-width: 100%; }
}

.notification-toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: white;
  border-left: 5px solid var(--accent);
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 10000;
  transform: translateX(120%);
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  min-width: 320px;
  max-width: 400px;
}
.notification-toast.show { transform: translateX(0); }
.toast-icon { font-size: 1.8rem; }
.toast-content strong { display: block; font-size: 0.95rem; color: var(--text); }
.toast-content p { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
