/* ====================================================
   HEAT Points System - Refined Business Aesthetic
   ==================================================== */

:root {
  --bg:        #f5f4ef;
  --surface:   #ffffff;
  --surface-2: #faf9f4;
  --ink:       #1a1817;
  --ink-soft:  #4a4642;
  --ink-mute:  #8a857f;
  --line:      #e6e2d8;
  --line-soft: #f0ede5;

  --brand:     #c8351c;     /* HEAT red */
  --brand-dk:  #9e2818;
  --brand-soft:#fae8e3;

  --gold:      #b8965b;
  --emerald:   #2d6a4f;
  --slate:     #2c4a52;

  --success:   #2d6a4f;
  --success-bg:#e3efe7;
  --warn:      #c47a00;
  --warn-bg:   #fbf0d6;
  --danger:    #b3261e;
  --danger-bg: #fbe5e3;
  --info:      #2c4a52;
  --info-bg:   #e0eaed;

  --radius:    6px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(26,24,23,0.04), 0 1px 3px rgba(26,24,23,0.06);
  --shadow:    0 2px 6px rgba(26,24,23,0.05), 0 8px 20px rgba(26,24,23,0.06);

  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-body:    'Inter Tight', 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Subtle paper texture */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 25% 20%, rgba(200,53,28,0.015), transparent 50%),
    radial-gradient(circle at 75% 80%, rgba(184,150,91,0.020), transparent 50%);
  z-index: 0;
}

a { color: var(--brand-dk); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
h1 { font-size: 1.75rem; line-height: 1.15; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* ============ LAYOUT ============ */
.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  background: #1a1817;
  color: #d8d3c8;
  padding: 28px 0;
  border-right: 1px solid #0e0c0b;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid #2a2522;
  margin-bottom: 18px;
}
.sidebar-brand .logo {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
  color: #fff;
  letter-spacing: -0.01em;
}
.sidebar-brand .logo .accent {
  color: var(--brand);
}
.sidebar-brand .tagline {
  font-size: 0.7rem;
  color: #8a857f;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar-section {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6a6560;
  padding: 14px 24px 6px;
}

.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 24px;
  color: #c8c2b6;
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar-nav a:hover {
  background: #232020;
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: #232020;
  color: #fff;
  border-left-color: var(--brand);
}
.sidebar-nav .icon {
  width: 18px;
  display: inline-block;
  text-align: center;
  opacity: 0.75;
}

.sidebar-foot {
  margin-top: auto;
  padding: 18px 24px;
  border-top: 1px solid #2a2522;
  font-size: 0.78rem;
  color: #8a857f;
}

/* ============ MAIN ============ */
.main {
  padding: 0;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 36px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 {
  font-size: 1.4rem;
  font-weight: 500;
}
.topbar .crumb {
  font-size: 0.75rem;
  color: var(--ink-mute);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 0.85rem;
}
.user-pill .role {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  padding: 2px 8px;
  border-radius: 100px;
}
.user-pill .role.role-superadmin { background: var(--brand); }
.user-pill .role.role-admin { background: var(--slate); }
.user-pill .role.role-staff { background: var(--gold); }

.content {
  padding: 32px 36px 60px;
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.card-header h2 { margin: 0; }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  background: linear-gradient(135deg, transparent 50%, var(--brand-soft) 50%);
  opacity: 0.5;
}
.stat .label {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.stat .value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat .sub {
  font-size: 0.78rem;
  color: var(--ink-mute);
  margin-top: 4px;
}

/* Stat brand colors */
.stat.brand-celtac::after     { background: linear-gradient(135deg, transparent 50%, #e3efe7 50%); }
.stat.brand-celtac-lab::after { background: linear-gradient(135deg, transparent 50%, #e0eaed 50%); }
.stat.brand-troya::after      { background: linear-gradient(135deg, transparent 50%, #fbf0d6 50%); }
.stat.brand-wurx::after       { background: linear-gradient(135deg, transparent 50%, #f0e3ed 50%); }
.stat.brand-heat::after       { background: linear-gradient(135deg, transparent 50%, var(--brand-soft) 50%); }

/* ============ TABLES ============ */
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.tbl th {
  background: var(--surface-2);
  text-align: left;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }

table.tbl td.num,
table.tbl th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
table.tbl td.muted { color: var(--ink-mute); }
table.tbl td.actions {
  white-space: nowrap;
  text-align: right;
}

.row-num {
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

/* ============ FORMS ============ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}
.form-row.full { grid-template-columns: 1fr; }
.form-row.thirds { grid-template-columns: 1fr 1fr 1fr; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.field input,
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field .help {
  font-size: 0.78rem;
  color: var(--ink-mute);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dk); border-color: var(--brand-dk); color: #fff; }

.btn-dark {
  background: var(--ink);
  color: #fff;
}
.btn-dark:hover { background: #000; color: #fff; }

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-mute); color: var(--ink); }

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--line);
}
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }

.btn-sm { padding: 6px 11px; font-size: 0.78rem; }

/* ============ BADGES ============ */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.badge.ok      { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge.warn    { background: var(--warn-bg);    color: var(--warn);    border-color: transparent; }
.badge.danger  { background: var(--danger-bg);  color: var(--danger);  border-color: transparent; }
.badge.info    { background: var(--info-bg);    color: var(--info);    border-color: transparent; }

.brand-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.brand-tag.celtac      { background: #e3efe7; color: var(--emerald); border-color: transparent; }
.brand-tag.celtac_lab  { background: #e0eaed; color: var(--slate);   border-color: transparent; }
.brand-tag.troya       { background: #fbf0d6; color: var(--warn);    border-color: transparent; }
.brand-tag.wurx        { background: #f0e3ed; color: #6b3a5e;        border-color: transparent; }
.brand-tag.heat        { background: var(--brand-soft); color: var(--brand-dk); border-color: transparent; }

/* ============ FLASH ============ */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  border-left: 3px solid;
}
.flash.success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.flash.error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger); }
.flash.info    { background: var(--info-bg);    color: var(--info);    border-color: var(--info); }
.flash.warn    { background: var(--warn-bg);    color: var(--warn);    border-color: var(--warn); }

/* ============ FILTERS ============ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.filters .field { gap: 4px; }
.filters input, .filters select { padding: 8px 10px; font-size: 0.88rem; }

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.pagination a, .pagination span {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
}
.pagination .current {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.pagination .info { border: 0; background: transparent; color: var(--ink-mute); padding-left: 12px; font-size: 0.82rem; }

/* ============ AUTH PAGE ============ */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(200,53,28,0.06), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(184,150,91,0.08), transparent 40%),
    var(--bg);
  padding: 20px;
  position: relative;
}
.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(26,24,23,0.025) 39px, rgba(26,24,23,0.025) 40px);
  pointer-events: none;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px 30px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}
.auth-card .brand-mark {
  text-align: center;
  margin-bottom: 28px;
}
.auth-card .brand-mark .logo {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.auth-card .brand-mark .logo .accent { color: var(--brand); }
.auth-card .brand-mark .tagline {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 6px;
}

/* ============ MISC ============ */
.section-title {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 18px;
  font-size: 0.92rem;
}
.kv dt { color: var(--ink-mute); font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; color: var(--ink); }

.muted { color: var(--ink-mute); }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 24px 0;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-mute);
}
.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.content > * { animation: fadeUp 0.4s ease both; }
.content > *:nth-child(2) { animation-delay: 0.05s; }
.content > *:nth-child(3) { animation-delay: 0.1s; }

/* Mobile */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .form-row, .form-row.thirds { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { padding-top: 8px; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
}

/* ===== Role badges ===== */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1;
}
.role-superadmin { background: #2a1c1a; color: #f9e7e3; }
.role-admin      { background: #f4dcd6; color: #802016; }
.role-staff      { background: #e6e8d8; color: #4a5328; }
.role-user       { background: #e1e5ec; color: #38465c; }

/* ===== Type badges (transaction types) ===== */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.4;
    background: #ece9e2;
    color: var(--ink-soft);
}
.type-import        { background: #e6f0e6; color: #2f5a30; }
.type-manual_add    { background: #e3eaf5; color: #2c4a78; }
.type-manual_deduct { background: #f4dcd6; color: #802016; }
.type-adjustment    { background: #f0e7d3; color: #6b4d10; }
.type-redemption    { background: #f0e3ed; color: #6b3a5e; }

/* ===== Status dot ===== */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink-soft);
}
.status-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c9c5b8;
}
.status-active::before   { background: #4a8a4f; }
.status-inactive::before { background: #b89a85; }

/* ===== Code pill ===== */
.code-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    background: #ece9e2;
    color: var(--ink);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 12px;
    font-weight: 500;
}

/* ===== Form helpers ===== */
.form-divider {
    margin: 28px 0 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--ink-soft);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--rule);
}
.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--ink);
    font-size: 14px;
}
.form-checkbox input[type=checkbox] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* ===== Button modifiers ===== */
.btn-xs {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
}
.btn-danger-text {
    color: var(--accent);
}
.btn-danger-text:hover {
    background: #fceeec;
    color: var(--accent-strong);
}
.btn-danger {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-danger:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

/* ===== Profile grid (already inline-styled but for consistency) ===== */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 980px) {
    .profile-grid { grid-template-columns: 1fr; }
}

/* ===== Error pages ===== */
.error-page {
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-image:
        linear-gradient(var(--rule-soft) 1px, transparent 1px),
        linear-gradient(90deg, var(--rule-soft) 1px, transparent 1px);
    background-size: 32px 32px;
    background-position: -1px -1px;
}
.error-shell {
    max-width: 520px;
    text-align: center;
    background: var(--surface);
    padding: 56px 48px;
    border: 1px solid var(--rule);
    border-radius: 14px;
    box-shadow: 0 1px 0 #fff inset, 0 6px 24px rgba(60, 40, 30, 0.06);
}
.error-code {
    font-family: 'Fraunces', serif;
    font-size: 88px;
    font-weight: 600;
    color: var(--accent);
    margin: 0;
    line-height: 0.9;
    letter-spacing: -0.04em;
}
.error-title {
    font-family: 'Fraunces', serif;
    font-size: 26px;
    font-weight: 500;
    margin: 16px 0 8px;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.error-sub {
    color: var(--ink-soft);
    font-size: 15px;
    margin: 0 0 28px;
    line-height: 1.6;
}
.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Misc text helpers ===== */
.muted-text { color: var(--ink-soft); }
.is-negative { color: var(--accent); }
.empty-cell {
    text-align: center;
    padding: 32px 16px;
    color: var(--ink-soft);
    font-style: italic;
}
.link {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--rule);
    transition: border-color 0.15s, color 0.15s;
}
.link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ============================================================
   PANEL / PAGE / TABLE STYLES (added to match new views)
   ============================================================ */

/* Page header cluster */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.page-head .eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin: 0 0 8px;
}
.page-head .page-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 32px;
    font-weight: 500;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin: 0 0 6px;
    line-height: 1.1;
}
.page-head .page-sub {
    color: var(--ink-soft);
    font-size: 14px;
    margin: 0;
    max-width: 56ch;
    line-height: 1.5;
}
.page-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* Panel — generic container card */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 1px 0 #fff inset, 0 2px 12px rgba(60, 40, 25, 0.04);
    overflow: hidden;
    margin-bottom: 24px;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(to bottom, #fafaf6, var(--surface));
}
.panel-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.005em;
}
.panel-body {
    padding: 22px;
}
.panel-body.p-0 { padding: 0; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table thead th {
    text-align: left;
    padding: 14px 22px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-mute);
    background: #faf8f3;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 14px 22px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
    vertical-align: middle;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}
.data-table tbody tr:hover {
    background: #faf8f3;
}
.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
}
.data-table tbody td strong {
    font-weight: 600;
    color: var(--ink);
}

/* Buttons (in case missing) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
    font-family: inherit;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 1px 2px rgba(158,40,24,0.2);
}
.btn-primary:hover {
    background: var(--brand-dk);
    border-color: var(--brand-dk);
}
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-ghost:hover {
    background: #faf8f3;
    color: var(--ink);
    border-color: #d8d3c5;
}
.btn-xs {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 6px;
    font-weight: 500;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #8a1d17;
    border-color: #8a1d17;
}
.btn-danger-text {
    color: var(--danger);
}
.btn-danger-text:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-bg);
}

/* Stat cards (page-level, not the smaller one) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin: 0 0 10px;
}
.stat-card .stat-value {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 28px;
    font-weight: 500;
    color: var(--ink);
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.015em;
}

/* Refine role/status/code pills to fit project palette */
.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.4;
}
.role-superadmin { background: #2a1815; color: #f9e7e3; }
.role-admin      { background: var(--brand-soft); color: var(--brand-dk); }
.role-staff      { background: #efe6d2; color: #6b4d10; }
.role-user       { background: #e1e8ec; color: var(--slate); }

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ink-soft);
}
.status-dot::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c9c5b8;
    flex-shrink: 0;
}
.status-active::before   { background: var(--success); box-shadow: 0 0 0 2px rgba(45,106,79,0.15); }
.status-inactive::before { background: #b8a698; }

.code-pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 5px;
    background: var(--line-soft);
    color: var(--ink);
    font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--line);
}

/* Form panel + form bits (used on user create/edit/profile) */
.form-panel { max-width: 720px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
@media (max-width: 720px) {
    .form-row { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: flex-start; }
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}
.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: 0;
}
.form-input,
select.form-input {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(200, 53, 28, 0.12);
}
.form-input:disabled {
    background: var(--line-soft);
    color: var(--ink-mute);
    cursor: not-allowed;
}
.form-hint {
    font-size: 12px;
    color: var(--ink-mute);
    margin: 2px 0 0;
}
.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--ink);
    user-select: none;
}
.form-checkbox input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
}
.form-divider {
    margin: 28px 0 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--ink-mute);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--line-soft);
}

/* Misc */
.muted-text { color: var(--ink-mute); font-size: 13px; }
.empty-cell {
    text-align: center;
    padding: 40px 20px;
    color: var(--ink-mute);
    font-style: italic;
}
.is-negative { color: var(--danger); }
.link {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px dotted var(--ink-mute);
    transition: color 0.15s, border-color 0.15s;
}
.link:hover {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

/* ─────────────────────────────────────────────────────────────────────────
   LANGUAGE SWITCHER  (segmented toggle with globe icon)
   Used in admin topbar, sidebar, customer header, and login screens.
   ───────────────────────────────────────────────────────────────────────── */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 4px 3px 9px;
    border-radius: 999px;
    height: 30px;
    box-sizing: border-box;
    font-family: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.lang-switch-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    opacity: 0.55;
    flex-shrink: 0;
}

.lang-switch .lang-opt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 11px;
    height: 22px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}
.lang-switch .lang-opt:active { transform: scale(0.96); }

/* ── Light variant — for dark backgrounds (sidebar, customer header) ── */
.lang-switch--light {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.10);
}
.lang-switch--light .lang-switch-icon { color: rgba(255, 255, 255, 0.55); }
.lang-switch--light .lang-opt {
    color: rgba(255, 255, 255, 0.65);
}
.lang-switch--light .lang-opt:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
}
.lang-switch--light .lang-opt.is-active {
    background: var(--brand, #c8351c);
    color: #fff;
    box-shadow: 0 1px 3px rgba(200, 53, 28, 0.35);
}

/* ── Dark variant — for light backgrounds (admin topbar, login pages) ── */
.lang-switch--dark {
    background: rgba(26, 24, 23, 0.04);
    border: 1px solid rgba(26, 24, 23, 0.08);
}
.lang-switch--dark .lang-switch-icon { color: var(--ink-mute, #8a857f); }
.lang-switch--dark .lang-opt {
    color: var(--ink-soft, #4a4540);
}
.lang-switch--dark .lang-opt:hover {
    color: var(--ink, #1a1817);
    background: rgba(26, 24, 23, 0.06);
    text-decoration: none;
}
.lang-switch--dark .lang-opt.is-active {
    background: var(--brand, #c8351c);
    color: #fff;
    box-shadow: 0 1px 3px rgba(200, 53, 28, 0.30);
}

/* Thai font handling.
   When <html lang="th"> we swap to a Thai-friendly stack so Thai glyphs
   render correctly on systems that don't have a default Thai font. */
html[lang="th"] body {
    font-family: 'IBM Plex Sans Thai', 'Sarabun', 'Inter Tight',
                 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
html[lang="th"] .logo,
html[lang="th"] h1,
html[lang="th"] h2,
html[lang="th"] h3,
html[lang="th"] .cust-page-head h1,
html[lang="th"] .cust-panel-head h2,
html[lang="th"] .cust-hero-card .value,
html[lang="th"] .cust-brand-card .pts,
html[lang="th"] .cust-lot .pts-num {
    font-family: 'IBM Plex Sans Thai', 'Sarabun', var(--font-display, serif);
    letter-spacing: 0;
}
/* Keep the lang-switch own typography from being affected by the Thai swap */
html[lang="th"] .lang-switch .lang-opt {
    font-family: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─────────────────────────────────────────────────────────────────────────
   ADMIN TOPBAR — language switch + user pill alignment
   ───────────────────────────────────────────────────────────────────────── */
.main .topbar .topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
}
.main .topbar .topbar-right .user-pill {
    margin: 0;  /* override any default vertical margin */
}

@media (max-width: 600px) {
    .main .topbar .topbar-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
    .lang-switch { height: 28px; padding: 2px 3px 2px 8px; }
    .lang-switch .lang-opt { height: 20px; padding: 0 9px; font-size: 10px; }
}
