:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --surface-2: #fbf7ef;
  --ink: #18212b;
  --muted: #667085;
  --line: #e2d9ca;
  --accent: #111827;
  --accent-soft: #efe7db;
  --danger: #b42318;
  --success: #067647;
  --warning: #b54708;
  --info: #175cd3;
  --shadow: 0 24px 80px rgba(24, 33, 43, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 247, 230, 0.95), transparent 36rem),
    linear-gradient(135deg, #f7f1e6 0%, #eee5d7 100%);
  color: var(--ink);
}

a { color: inherit; }

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 760;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  color: var(--accent);
  background: var(--accent-soft);
}

button.ghost {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.auth-card form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
  letter-spacing: -0.08em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.28rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

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

.form-message {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--danger);
}

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

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid rgba(226, 217, 202, 0.9);
  background: rgba(255, 253, 248, 0.84);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-symbol {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
}

.brand-lockup small {
  display: block;
  color: var(--muted);
}

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

.nav-list a {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 760;
}

.nav-list a.active,
.nav-list a:hover {
  color: var(--ink);
  background: var(--accent-soft);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
}

.content-shell {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 30px;
  border-bottom: 1px solid rgba(226, 217, 202, 0.88);
  background: rgba(246, 241, 232, 0.86);
  backdrop-filter: blur(18px);
}

.top-header h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

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

.admin-chip,
.pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.view {
  width: min(100%, 1240px);
  padding: 30px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
  align-items: start;
}

.card,
.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 14px 46px rgba(24, 33, 43, 0.08);
}

.card {
  padding: 22px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.panel-header,
.row-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.panel-body {
  padding: 20px 22px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td a {
  font-weight: 800;
  text-decoration: none;
}

.badge.success { color: var(--success); background: #ecfdf3; border-color: #abefc6; }
.badge.warning { color: var(--warning); background: #fffaeb; border-color: #fedf89; }
.badge.danger { color: var(--danger); background: #fef3f2; border-color: #fecdca; }
.badge.info { color: var(--info); background: #eff8ff; border-color: #b2ddff; }

.details {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px 18px;
}

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

.details dd {
  margin: 0;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-item {
  max-width: 76%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.message-item.outbound {
  justify-self: end;
  background: #111827;
  color: #fff;
}

.message-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.message-item.outbound .message-meta {
  color: rgba(255,255,255,0.72);
}

.empty,
.error,
.notice {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
}

.error {
  color: var(--danger);
  border-color: #fecdca;
  background: #fef3f2;
}

.skeleton {
  min-height: 140px;
  border-radius: 24px;
  background: linear-gradient(90deg, rgba(255,255,255,0.38), rgba(255,255,255,0.9), rgba(255,255,255,0.38));
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite linear;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 16px;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
}

.mobile-only { display: none; }

@keyframes shimmer {
  to { background-position-x: -220%; }
}

[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 8;
    inset: 0 auto 0 0;
    width: min(310px, 84vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .grid.cards,
  .two-col { grid-template-columns: 1fr; }
  .view,
  .top-header { padding-inline: 18px; }
}

@media (max-width: 680px) {
  .auth-card { padding: 26px; }
  .top-header { align-items: flex-start; }
  .header-actions { flex-direction: column; align-items: flex-end; }
  .details { grid-template-columns: 1fr; }
  .message-item { max-width: 100%; }
  table { min-width: 560px; }
}
