@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --bg: #f5efe3;
  --surface: #fdf8f0;
  --surface-2: #f0e8d8;
  --ink: #1c2520;
  --muted: #5a6158;
  --line: #d8cabb;
  --primary: #0d5750;
  --primary-2: #094540;
  --primary-light: #e8f3f1;
  --accent: #b84d26;
  --accent-2: #952f10;
  --danger: #992020;
  --shadow: 0 2px 6px rgba(28, 22, 14, 0.06), 0 8px 24px rgba(28, 22, 14, 0.10);
  --shadow-sm: 0 1px 3px rgba(28, 22, 14, 0.07), 0 4px 12px rgba(28, 22, 14, 0.08);
  --shadow-lg: 0 4px 12px rgba(28, 22, 14, 0.08), 0 16px 40px rgba(28, 22, 14, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
  --container-max-width: 1160px;
  --container-padding-x: 1.25rem;
  --font-sans: 'DM Sans', 'Gill Sans', 'Segoe UI', sans-serif;
  --font-serif: 'DM Serif Display', 'Palatino Linotype', 'Book Antiqua', serif;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0 !important;
  padding: 0 !important;
  min-height: 100%;
}

html {
  background: #ede6d8;
}

body {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  background: linear-gradient(160deg, #f9f4ea 0%, var(--bg) 60%, #e8dece 100%);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  font-weight: 600;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-2);
}

/* ─── ambient orbs ─── */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.28;
}

.orb-1 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #8ab9b3, transparent 70%);
  top: -160px;
  right: -100px;
  animation: drift-1 18s ease-in-out infinite alternate;
}

.orb-2 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #e8a882, transparent 70%);
  bottom: -180px;
  left: -100px;
  animation: drift-2 22s ease-in-out infinite alternate;
}

.orb-3 {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, #e8d898, transparent 70%);
  top: 40%;
  left: 52%;
  animation: drift-3 28s ease-in-out infinite alternate;
}

@keyframes drift-1 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.06); }
}
@keyframes drift-2 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-20px, -30px) scale(1.04); }
}
@keyframes drift-3 {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(15px, -20px) scale(0.96); }
}

/* ─── sidebar ─── */
:root {
  --sidebar-w: 232px;
}

.auth-shell .ambient {
  display: none;
}

/* App shell: sidebar + content side by side */
body:not(.auth-shell) {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0b4840 0%, #0d5750 55%, #0e6158 100%);
  border-right: 1px solid rgba(255,255,255,0.07);
  box-shadow: 2px 0 20px rgba(8, 28, 24, 0.22);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar inside sidebar */
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 99px; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.2rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffcb6a;
  box-shadow: 0 0 0 3px rgba(255,200,100,0.22), 0 0 10px rgba(255,200,100,0.5);
  animation: pulse-dot 3s ease-in-out infinite;
}

/* The auth topbar also uses .dot — keep it working */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffcb6a;
  box-shadow: 0 0 0 4px rgba(255,200,100,0.25), 0 0 12px rgba(255,200,100,0.5);
  animation: pulse-dot 3s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255,200,100,0.25), 0 0 12px rgba(255,200,100,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(255,200,100,0.15), 0 0 18px rgba(255,200,100,0.6); }
}

.sidebar-brand-name {
  color: #eef4f2;
  font-family: var(--font-serif);
  font-size: 1rem;
  letter-spacing: 0.2px;
  line-height: 1.2;
  white-space: nowrap;
}

/* Nav sections */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.75rem 0.65rem;
  flex-shrink: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 9px;
  color: rgba(220, 240, 236, 0.72);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.1px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.sidebar-link.is-active {
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-weight: 600;
}

.sidebar-link.is-active .sidebar-icon {
  opacity: 1;
}

.sidebar-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity var(--transition);
}

.sidebar-link:hover .sidebar-icon {
  opacity: 0.9;
}

/* Divider */
.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0 0.65rem;
  flex-shrink: 0;
}

/* Footer */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 0.7rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eef4f2;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-username {
  color: #eef4f2;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: rgba(220,240,236,0.55);
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-form {
  margin: 0;
  flex-shrink: 0;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 7px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(220,240,236,0.65);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  box-shadow: none;
}

.sidebar-logout-btn svg {
  width: 15px;
  height: 15px;
}

.sidebar-logout-btn:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  transform: none;
  filter: none;
  box-shadow: none;
}

/* Mobile topbar */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 35;
  height: 52px;
  background: linear-gradient(100deg, #0b4840, var(--primary));
  border-bottom: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 2px 12px rgba(8,28,24,0.2);
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: #eef4f2;
  font-family: var(--font-serif);
  font-size: 0.98rem;
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.1);
  color: #eef4f2;
  cursor: pointer;
  box-shadow: none;
  flex-shrink: 0;
}

.mobile-menu-btn svg { width: 18px; height: 18px; }
.mobile-menu-btn:hover { background: rgba(255,255,255,0.2); transform: none; filter: none; box-shadow: none; }

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(8,28,24,0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sidebar-overlay.is-visible {
  opacity: 1;
}

/* Auth topbar (logged-out state) */
.auth-topbar {
  background: rgba(253,248,240,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 0;
}

.auth-topbar-inner {
  width: min(var(--container-max-width), calc(100% - (var(--container-padding-x) * 2)));
  margin: 0 auto;
  display: flex;
  align-items: center;
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  color: var(--ink);
}

/* App shell wrapper */
.app-shell {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.auth-shell .app-shell {
  margin-left: 0;
}

/* ─── layout ─── */
.layout {
  width: 100%;
  padding: 1.6rem 1.75rem 3rem;
}

.layout > * {
  animation: rise-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.layout > *:nth-child(2) { animation-delay: 0.05s; }
.layout > *:nth-child(3) { animation-delay: 0.10s; }
.layout > *:nth-child(4) { animation-delay: 0.14s; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── hero ─── */
.hero {
  margin-bottom: 1rem;
  padding: 1.25rem 1.4rem;
  border-radius: var(--radius);
  border: 1px solid rgba(215, 200, 175, 0.8);
  background: linear-gradient(145deg, #fffbf2, #f7edd8);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  top: -80px;
  right: -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 87, 80, 0.08), transparent 70%);
}

.hero-kicker {
  margin: 0;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 0.7rem;
  font-weight: 700;
}

.hero h1 {
  margin: 0.2rem 0 0;
  font-family: var(--font-serif);
  font-size: clamp(1.55rem, 2.6vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.hero-actions a {
  text-decoration: none;
}

/* ─── grid / cards ─── */
.grid {
  display: grid;
  gap: 1rem;
}

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

.two-cols {
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .two-cols {
    grid-template-columns: 1fr 1fr;
  }
}

/* ─── panel / card ─── */
.card,
.panel {
  border: 1px solid rgba(215, 200, 175, 0.75);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  padding: 1.1rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, transparent 60%);
  pointer-events: none;
}

.card::after {
  content: '';
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 999px;
  right: -50px;
  top: -50px;
  background: radial-gradient(circle, rgba(13, 87, 80, 0.10), transparent 70%);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card h2 {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 2.1rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.panel {
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

.summary-only {
  padding-top: 0.9rem;
}

/* ─── panel head ─── */
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(215, 200, 175, 0.6);
}

.panel-head h1,
.panel-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  letter-spacing: -0.02em;
}

.panel-head h1 {
  font-size: clamp(1.3rem, 2.2vw, 1.65rem);
  line-height: 1.15;
}

.panel-head h3 {
  font-size: 1.05rem;
}

.head-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ─── tables ─── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(215, 200, 175, 0.5);
}

.table th {
  background: linear-gradient(135deg, #f2e8d6, #ede0ca);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  white-space: nowrap;
}

.table th,
.table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid rgba(215, 200, 175, 0.4);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover {
  background: rgba(255, 242, 214, 0.6);
}

/* ─── actions ─── */
.actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

/* ─── admin tabs ─── */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.admin-tab-btn {
  border: 1px solid #d8cdb4;
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.75rem;
  background: #f2e8d6;
  color: #31403b;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.admin-tab-btn:hover {
  background: #ead9c2;
  border-color: #c8b898;
}

.admin-tab-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.admin-tab-panel {
  display: none;
}

.admin-tab-panel.is-active {
  display: block;
}

/* ─── action dropdown ─── */
.action-dropdown {
  position: relative;
}

.action-dropdown[open] {
  z-index: 15;
}

.action-dropdown-trigger {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid #d8cbb3;
  background: linear-gradient(135deg, #f7f0e4, #e8d9c4);
  color: var(--ink);
  padding: 0.28rem 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.action-dropdown-trigger::-webkit-details-marker {
  display: none;
}

.action-dropdown-trigger .caret {
  font-size: 0.65rem;
  transition: transform var(--transition);
}

.action-dropdown[open] .action-dropdown-trigger .caret {
  transform: rotate(180deg);
}

.action-dropdown-menu {
  position: static;
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  margin-top: 0.28rem;
  animation: rise-in 0.15s ease both;
}

.action-dropdown-menu form + form {
  margin-top: 0.22rem;
}

.action-dropdown-menu button {
  width: 100%;
  justify-content: flex-start;
  padding: 0.28rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 7px;
}

.history-actions {
  min-width: 90px;
}

/* ─── search bar ─── */
.search {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.search input[type="search"] {
  flex: 1;
  min-width: 200px;
}

/* ─── form elements ─── */
input,
textarea,
select,
button {
  font: inherit;
}

label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

input,
textarea,
select {
  width: 100%;
  color: var(--ink);
  padding: 0.6rem 0.72rem;
  border: 1.5px solid #cdbfa6;
  border-radius: var(--radius-sm);
  background: #fffef9;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  font-size: 0.9rem;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13, 87, 80, 0.14);
}

input::placeholder,
textarea::placeholder {
  color: #b8a98a;
}

/* ─── buttons ─── */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 1px 3px rgba(10, 50, 45, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
  letter-spacing: 0.1px;
}

button:hover,
.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(10, 50, 45, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  filter: brightness(1.06);
}

button:active,
.button:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  filter: none;
  box-shadow: none;
}

.button-muted {
  color: var(--ink);
  background: linear-gradient(135deg, #f5edd8, #e2d4bc);
  box-shadow: 0 1px 3px rgba(28, 22, 14, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.button-muted:hover {
  filter: brightness(1.03);
}

.button-sm {
  padding: 0.32rem 0.6rem;
  font-size: 0.82rem;
  border-radius: 7px;
}

.danger {
  background: linear-gradient(135deg, #c03232, var(--danger));
  box-shadow: 0 1px 3px rgba(120, 20, 20, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.danger:hover {
  filter: brightness(1.08);
}

/* ─── form grid ─── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #3a4540;
  letter-spacing: 0.1px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

/* ─── flash messages ─── */
.flash-list {
  margin-bottom: 1rem;
}

.flash {
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flash-success {
  background: #ebf6ef;
  border: 1px solid #c2dccb;
  color: #1c5230;
}

.flash-error {
  background: #fff0f0;
  border: 1px solid #f0c2c2;
  color: #842020;
}

/* ─── template list ─── */
.template-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.template-list li {
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(215, 200, 175, 0.65);
  background: linear-gradient(135deg, #fefcf6, #f4eada);
  transition: border-color var(--transition);
}

.template-list li:hover {
  border-color: #c8b496;
}

.template-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.template-head form {
  margin: 0;
}

/* ─── messages hub / tabs ─── */
.message-hub {
  padding: 1.15rem 1.25rem;
}

.message-subtitle {
  margin: -0.3rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.message-tabs {
  display: inline-flex;
  gap: 0.25rem;
  background: rgba(220, 206, 184, 0.5);
  border: 1px solid rgba(210, 195, 170, 0.7);
  padding: 0.24rem;
  border-radius: 11px;
  margin-bottom: 1.1rem;
}

.tab-button {
  border: 0;
  border-radius: 8px;
  padding: 0.46rem 0.88rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.875rem;
  background: transparent;
  color: #42504c;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.6);
}

.tab-button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 1px 4px rgba(10, 50, 45, 0.2);
}

.tab-button:focus-visible {
  outline: 2px solid rgba(13, 87, 80, 0.45);
  outline-offset: 2px;
}

.tab-pane {
  display: none;
  border: 1px solid rgba(210, 195, 170, 0.65);
  border-radius: var(--radius);
  padding: 1.05rem 1.1rem;
  background: linear-gradient(145deg, #fffbf3, #f8eedf);
}

.tab-pane.active {
  display: block;
  animation: rise-in 0.22s ease both;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.pane-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: -0.015em;
}

.pane-badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  color: #fff;
  background: linear-gradient(135deg, #9e5328, #7a3e1c);
  padding: 0.22rem 0.5rem;
  letter-spacing: 0.3px;
  font-weight: 600;
}

/* ─── send progress popup ─── */
.send-progress-popup {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 180;
}

.send-progress-panel {
  width: min(420px, calc(100vw - 2.5rem));
  border: 1px solid rgba(210, 195, 170, 0.8);
  border-radius: var(--radius);
  background: rgba(254, 251, 244, 0.97);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  padding: 0.9rem;
  display: grid;
  gap: 0.65rem;
  animation: rise-in 0.25s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.send-progress-panel.is-finished {
  border-color: #b9dcc5;
  background: rgba(238, 250, 242, 0.97);
}

.send-progress-panel.is-error {
  border-color: #f0c2c2;
  background: rgba(255, 245, 245, 0.97);
}

.send-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.send-progress-head strong {
  font-size: 0.94rem;
}

.send-progress-text {
  margin: 0;
  color: #4a4134;
  font-size: 0.9rem;
}

.send-progress-list-wrap {
  border: 1px solid #d9cbb4;
  border-radius: 9px;
  background: #fffef9;
  padding: 0.56rem 0.65rem;
}

.send-progress-label {
  margin: 0 0 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

#send-progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.22rem;
  max-height: 180px;
  overflow-y: auto;
}

#send-progress-list li {
  font-size: 0.84rem;
  color: #3e3830;
  padding: 0.18rem 0;
}

.send-progress-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  border: 1px solid rgba(210, 195, 170, 0.8);
  border-radius: var(--radius-pill);
  background: rgba(254, 251, 244, 0.97);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  padding: 0.48rem 0.72rem;
  cursor: pointer;
  font-family: var(--font-sans);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  transition: box-shadow var(--transition), transform var(--transition);
}

.send-progress-compact:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.send-progress-compact-action {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 700;
}

.send-progress-popup.is-minimized .send-progress-panel {
  display: none;
}

/* ─── supplier picker ─── */
.supplier-picker {
  border: 1.5px solid rgba(210, 195, 170, 0.7);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  background: linear-gradient(135deg, #fefcf5, #f6ecd9);
}

.supplier-picker legend {
  padding: 0 0.4rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: #3a4540;
  letter-spacing: 0.2px;
}

.supplier-list {
  display: grid;
  gap: 0.4rem;
  margin-top: 0.55rem;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.check-all {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: #31403b;
  margin-bottom: 0.35rem;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  transition: background var(--transition);
}

.check-all:hover {
  background: rgba(210, 195, 170, 0.25);
}

.check-all input[type="checkbox"],
.supplier-item input[type="checkbox"] {
  display: none;
}

.check-ui {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  border-radius: 5px;
  border: 1.5px solid #c4b090;
  background: #fff;
  position: relative;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.check-ui::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transform-origin: center;
  transition: transform 0.14s ease;
}

.check-all input[type="checkbox"]:checked + .check-ui,
.supplier-item input[type="checkbox"]:checked + .check-ui {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 87, 80, 0.15);
}

.check-all input[type="checkbox"]:checked + .check-ui::after,
.supplier-item input[type="checkbox"]:checked + .check-ui::after {
  transform: rotate(-45deg) scale(1);
}

.supplier-item {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  border: 1px solid #d6c8b2;
  border-radius: 9px;
  padding: 0.52rem 0.62rem;
  background: #fffdf7;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.supplier-item:hover {
  border-color: #c0a880;
  background: #fffaf0;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.supplier-item:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 87, 80, 0.12);
}

.supplier-meta {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  line-height: 1.3;
}

.supplier-meta small {
  color: var(--muted);
  font-size: 0.8rem;
}

.supplier-empty {
  border: 1.5px dashed #cbbca2;
  border-radius: 9px;
  padding: 1rem;
  background: rgba(252, 246, 236, 0.6);
  text-align: center;
}

.supplier-empty p {
  margin: 0.3rem 0 0.6rem;
  color: var(--muted);
}

/* ─── import result ─── */
.import-result {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #fefcf5, var(--surface-2));
}

/* ─── upload field ─── */
.upload-field {
  position: relative;
  border: 1.5px dashed #bfad93;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #fefaf2, #f6ecd9);
  padding: 1rem 1.1rem;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.upload-field:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.upload-input {
  display: none;
}

.upload-title {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 0.12rem;
}

.upload-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.upload-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.upload-trigger {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 0.42rem 0.78rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 1px 3px rgba(10, 50, 45, 0.2);
}

.upload-filename {
  color: var(--ink);
  font-size: 0.9rem;
}

/* ─── misc ─── */
.msg {
  max-width: 360px;
  font-size: 0.86rem;
  background: rgba(244, 238, 226, 0.5);
  border: 1px solid rgba(210, 195, 170, 0.4);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.meta {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.pager {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.9rem;
}

/* ─── settings ─── */
.settings-panel {
  max-width: 860px;
}

.settings-intro {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-help {
  border: 1px solid rgba(215, 200, 175, 0.7);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #fffcf0, #f5ebd7);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.settings-help h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.settings-help ol {
  margin: 0;
  padding-left: 1.3rem;
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

/* ─── status pills ─── */
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 0.28rem 0.62rem;
  border: 1px solid transparent;
}

.status-disconnected {
  background: #f0ece4;
  color: #5c6661;
  border-color: #d8ccb8;
}

.status-connecting {
  background: #fff4df;
  color: #8b541f;
  border-color: #e8c89d;
}

.status-waiting {
  background: #fff0cf;
  color: #885722;
  border-color: #e7be7b;
}

.status-connected {
  background: #e5f6ea;
  color: #1a5e30;
  border-color: #b9dcc5;
}

.status-error {
  background: #ffefef;
  color: #8b2b2b;
  border-color: #ebc1c1;
}

/* ─── QR code ─── */
.wa-qr-card {
  border: 1px solid rgba(215, 200, 175, 0.7);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #fffcf2, #f5ebd7);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.wa-qr-card h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.wa-qr-wrap {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1.5px dashed #c8b898;
  border-radius: 9px;
  background: #fffef9;
  padding: 0.75rem;
}

#wa-qr-image {
  max-width: min(300px, 100%);
  width: 100%;
  height: auto;
  border-radius: 9px;
  border: 1px solid #d6cab6;
  background: #fff;
  padding: 0.4rem;
  cursor: zoom-in;
  transition: box-shadow var(--transition);
}

#wa-qr-image:hover {
  box-shadow: var(--shadow);
}

.qr-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.qr-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.qr-preview-panel {
  position: relative;
  max-width: min(92vw, 720px);
  margin: 5vh auto 0;
  padding: 0.9rem;
  border-radius: var(--radius);
  border: 1px solid #d8c8af;
  background: #fffaf2;
  display: grid;
  gap: 0.6rem;
  justify-items: end;
  box-shadow: var(--shadow-lg);
  animation: rise-in 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#qr-preview-image {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 9px;
  border: 1px solid #d6cab6;
  background: #fff;
  padding: 0.4rem;
}

/* ─── auth panel ─── */
.auth-panel {
  max-width: 440px;
  margin: 2rem auto;
  background: rgba(253, 250, 242, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.auth-actions .button {
  text-decoration: none;
}

/* ─── billing ─── */
.billing-panel {
  max-width: 860px;
}

.billing-plan-card {
  max-width: 860px;
  background: linear-gradient(145deg, #fffdf4, #f6ecd8);
  transition: transform var(--transition), box-shadow var(--transition);
}

.billing-plan-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.billing-plans-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.billing-price {
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 2.5vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ─── confirm dialog ─── */
body.dialog-open {
  overflow: hidden;
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.confirm-dialog[hidden] {
  display: none;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 16, 10, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.confirm-panel {
  position: relative;
  width: min(440px, 100%);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid rgba(215, 200, 175, 0.7);
  background: linear-gradient(145deg, #fffcf4, #f5ebd6);
  box-shadow: var(--shadow-lg);
  animation: rise-in 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.confirm-panel h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.2rem;
  letter-spacing: -0.015em;
}

.confirm-panel p {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ─── recent recipients ─── */
.recent-recipients {
  margin-top: 0.8rem;
  border-top: 1px dashed #cbbca4;
  padding-top: 0.65rem;
}

.recent-recipients h4 {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: #3a4540;
}

.recent-recipients ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.28rem;
}

.recent-recipients li {
  color: #4e463a;
  font-size: 0.88rem;
}

.recent-recipients small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ─── scrollbar (webkit) ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(210, 195, 170, 0.2);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb {
  background: rgba(180, 162, 132, 0.5);
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 132, 102, 0.7);
}

/* ─── responsive ─── */
@media (max-width: 860px) {
  /* Sidebar becomes a slide-in drawer on mobile */
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 248px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: none;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(8, 28, 24, 0.3);
  }

  .sidebar-overlay {
    display: block;
  }

  .mobile-topbar {
    display: flex;
  }

  .app-shell {
    margin-left: 0;
    padding-top: 52px;
  }

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

  .panel-head {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .message-tabs {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .settings-actions > * {
    width: 100%;
  }

  .layout {
    padding-top: 1rem;
    padding-bottom: 2rem;
  }

  .panel {
    padding: 0.9rem 1rem;
  }

  body.sidebar-mobile-open {
    overflow: hidden;
  }
}

/* ─── admin dashboard specific ─── */
.panel > h3,
.panel > h2 {
  font-family: var(--font-serif);
  letter-spacing: -0.015em;
  margin-top: 0;
}

code {
  font-size: 0.86em;
  background: rgba(210, 195, 170, 0.35);
  border: 1px solid rgba(200, 183, 150, 0.4);
  border-radius: 5px;
  padding: 0.12em 0.35em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

pre.msg {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

hr {
  border: 0;
  border-top: 1px solid rgba(215, 200, 175, 0.6);
  margin: 1.1rem 0;
}

small {
  font-size: 0.82rem;
}

/* ─── wa provider card ─── */
.wa-provider-card {
  border: 1px solid rgba(215, 200, 175, 0.7);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #fffcf3, #f5ebd7);
  padding: 0.9rem 1rem;
  margin-bottom: 0.95rem;
}

.wa-provider-card h2 {
  margin: 0 0 0.45rem;
  font-family: var(--font-serif);
  font-size: 1rem;
}

.settings-list {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.32rem;
  color: #51473a;
  font-size: 0.9rem;
}