/* ==========================================================================
   CusmaDocs UI — modern, professional, fresh (Light-first refresh)
   Consolidated + cleaned (buttons/icons inline, deduped tables, etc.)
   ==========================================================================
*/

/* -------- CSS Variables (Light palette by default) -------- */
:root{
  /* Surfaces & text */
  --bg: #f7f9fc;           /* page background */
  --panel: #ffffff;        /* panels / cards */
  --panel-2: #f8fafc;      /* elevated/inputs */
  --border: #e5e7eb;       /* borders/dividers */
  --text: #0f172a;         /* primary text */
  --muted: #475569;        /* secondary text */
  --link: #2563eb;         /* links */

  /* Brand & states */
  --brand: #3b82f6;        /* primary / CTA */
  --brand-2: #2563eb;      /* hover/alt */
  --good: #16a34a;         /* success */
  --bad: #dc2626;          /* error */
  --warn: #d97706;         /* warning */

  /* Radii, shadow, focus */
  --radius-xl: 20px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 26px rgba(16,24,40,.12), 0 2px 8px rgba(16,24,40,.06);
  --shadow-raise: 0 8px 24px rgba(16,24,40,.10), 0 2px 6px rgba(16,24,40,.06);
  --shadow-float: 0 20px 40px rgba(16,24,40,.14), 0 6px 14px rgba(16,24,40,.08);
  --focus: 0 0 0 3px rgba(59,130,246,.22);
}

/* Force light theme - ignore system dark mode preferences */
/* Removed all dark mode media queries to ensure consistent light theme */

/* -------- Base -------- */
*{box-sizing:border-box}
html,body{min-height:100%}
body{
  margin:0;
  background:
    radial-gradient(1200px 840px at 80% -10%, rgba(59,130,246,.10), transparent 60%),
    radial-gradient(1000px 700px at -10% 120%, rgba(2,132,199,.08), transparent 60%),
    linear-gradient(180deg, #f7f9fc 0%, #f3f6fb 60%, #eef2f8 100%);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a{color:var(--link);text-decoration:none}
a:hover{opacity:.9}

/* -------- Layout Shell -------- */
.header{
  display:flex;align-items:center;justify-content:space-between;
  padding:12px 28px;border-bottom:1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  position:sticky;top:0;z-index:100;box-shadow: var(--shadow);
  transition: background .3s ease, box-shadow .3s ease;
}
.header:hover{ background: color-mix(in srgb, var(--panel) 85%, transparent); box-shadow: var(--shadow-raise); }
.brand{display:flex;gap:10px;align-items:center;font-weight:800;letter-spacing:.3px;font-size:1.15rem;color:var(--text)}
.brand__dot{width:12px;height:12px;border-radius:50%;background:var(--brand);box-shadow:0 0 0 6px rgba(59,130,246,.20)}
.brand-logo{height:55px;width:128px;object-fit:cover;object-position:center;display:block;margin-top:6px}
.nav a{color:var(--muted);margin:0 6px;padding:8px 14px;border:1px solid transparent;border-radius:var(--radius-md);font-weight:500;transition:background .25s,color .25s}
.nav a:hover,.nav a.active{color:var(--text);background:rgba(59,130,246,.10)}
.nav a.active{position:relative}
.nav a.active::after{content:"";position:absolute;left:14px;right:14px;bottom:6px;height:2px;border-radius:2px;background:var(--brand)}
.main{max-width:1400px;margin:24px auto;padding:0 16px}
.footer{color:var(--muted);font-size:12px;text-align:center;margin:28px 0 18px}

/* ===== Hamburger button ===== */
.nav-toggle {
  display: none; position: relative; width: 42px; height: 42px;
  border: 1px solid var(--border, #e5e7eb); background: var(--panel-2, #f8fafc);
  border-radius: .75rem; padding: 0; cursor: pointer; flex: 0 0 auto;
}
.nav-toggle .bar {
  position: absolute; left: 10px; right: 10px; height: 2px; background: var(--text, #0f172a);
  transition: transform .2s ease, opacity .2s ease, top .2s ease;
}
.nav-toggle .bar:nth-child(1){ top: 13px; }
.nav-toggle .bar:nth-child(2){ top: 20px; }
.nav-toggle .bar:nth-child(3){ top: 27px; }
.nav-toggle[aria-expanded="true"] .bar:nth-child(1){ top: 20px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bar:nth-child(2){ opacity: 0; }
.nav-toggle[aria-expanded="true"] .bar:nth-child(3){ top: 20px; transform: rotate(-45deg); }

/* ===== Mobile behavior ===== */
@media (max-width: 768px) {
  .nav-toggle { display: inline-block; }

  /* Convert nav into a slide-down sheet */
  .header { position: sticky; }
  .header .nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--panel, #fff); border-bottom: 1px solid var(--border, #e5e7eb);
    transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: transform .18s ease, opacity .18s ease;
    display: grid; gap: .25rem; padding: .5rem;
  }
  .header .nav a { padding: .75rem .75rem; border-radius: .5rem; }
  .header .nav.open { transform: translateY(0); opacity: 1; pointer-events: auto; }

  /* Keep brand and hamburger in a single row */
  .header { align-items: center; }
}

/* Motion-safe */
@media (prefers-reduced-motion: reduce) {
  .nav-toggle .bar, .header .nav { transition: none !important; }
}

/* -------- Utilities -------- */
.container{max-width:1400px;margin:32px auto;padding:0 24px}

/* Ensure container has minimum width on desktop - high specificity to prevent overrides */
@media (min-width: 1024px) {
  body.app-page .container,
  .container {
    min-width: 1280px !important;
    max-width: 1400px !important;
    width: auto !important;
  }
  
  /* Extra specificity for owner pages */
  body.app-page .container:not(.auth-page .container) {
    min-width: 1280px !important;
    max-width: 1400px !important;
    width: auto !important;
  }
}
.container-sm{max-width:720px;margin:48px auto;padding:0 16px}
.container-md{max-width:960px;margin:32px auto;padding:0 16px}
.mt-0{margin-top:0}.mb-0{margin-bottom:0}.mb-1{margin-bottom:6px}.mb-2{margin-bottom:12px}.mb-3{margin-bottom:18px}.mb-4{margin-bottom:24px}
.row{display:flex;gap:12px;flex-wrap:wrap}
.text-muted{color:var(--muted)}
.text-center{text-align:center}
.h1{font-size:28px;font-weight:800;margin:0;letter-spacing:.2px}
.h2{font-size:18px;font-weight:700;margin:0;letter-spacing:.15px}
.mb{margin-bottom:14px}
.p-0{padding:0!important}
.text-right{text-align:right}

/* -------- Panels / Cards -------- */
.card{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius-xl);
  padding:18px;
  box-shadow: var(--shadow-raise);
  animation: cardIn .28s ease both;
}
.card:hover{ box-shadow: var(--shadow-float); transition: box-shadow .25s ease; }
.card--ghost{box-shadow:none}
@keyframes cardIn{from{transform:translateY(6px);opacity:0}to{transform:translateY(0);opacity:1}}

/* -------- Buttons -------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  padding:10px 14px;border-radius:14px;border:1px solid transparent;
  background:var(--brand);color:#fff;cursor:pointer;white-space:nowrap;vertical-align:middle;
  transition:transform .06s ease, filter .22s ease, opacity .22s ease, box-shadow .22s ease;
  box-shadow: 0 8px 18px rgba(59,130,246,.18), inset 0 1px 0 rgba(255,255,255,.28);
}
.btn:hover{filter:brightness(1.05);transform:translateY(-1px)}
.btn:active{transform:translateY(1px)}
.btn-sm{ padding:6px 10px; border-radius:10px; font-size:.9rem; }
.btn--outline{background:transparent;color:var(--text);border:1px solid var(--border);box-shadow:none}
.btn--outline:hover{background:var(--panel-2);color:var(--text)}
.btn--muted{background:var(--panel-2);border:1px solid var(--border);color:var(--text)}
.btn--muted:hover{background:var(--panel);color:var(--text)}
.btn--ghost{border:1px solid transparent;background:transparent;color:var(--text)}
.btn--ghost:hover{background:var(--panel-2);color:var(--text)}
.btn--danger{background:var(--bad);border-color:transparent;box-shadow:0 6px 16px rgba(220,38,38,.18)}
.btn--danger:hover{background:color-mix(in oklab, var(--bad) 85%, black)}

/* Colored variants */
.btn-red{ background-color:#dc2626; color:#fff; border:1px solid #b91c1c; }
.btn-red:hover{ background-color:#b91c1c; }
.btn-green{ background-color:#16a34a; color:#fff; border:1px solid #15803d; }
.btn-green:hover{ background-color:#15803d; }
.btn-yellow{ background-color:#d97706; color:#fff; border:1px solid #b45309; }
.btn-yellow:hover{ background-color:#b45309; }

/* Button groups / action cells */
.actions{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.actions .btn{ margin:0; }

/* Icons in buttons (Bootstrap Icons) */
.btn i.bi{ flex:0 0 auto; font-size:1em; line-height:1; color:inherit; }

/* -------- Forms -------- */
.form{display:block;gap:12px}
.label{color:var(--muted);display:block}
.input,.select,.textarea{
  width:100%;margin-top:6px;background:var(--panel-2);
  border:1px solid var(--border);border-radius:12px;
  padding:10px;color:var(--text);outline:none;transition:border-color .2s,box-shadow .2s,background .2s;
}
.input:focus,.select:focus,.textarea:focus{box-shadow:0 0 0 4px color-mix(in oklab, var(--brand) 20%, transparent);border-color:color-mix(in oklab, var(--brand) 65%, var(--border))}
.checkbox{accent-color:var(--brand)}
::placeholder{ color:var(--muted); }

/* Label-wrapped inputs */
label{ display:block; color:var(--muted); font-size:.95rem; }
label > input, label > textarea, label > select{
  width:100%; margin-top:6px;
  background:var(--panel-2); color:var(--text);
  border:1px solid var(--border); border-radius:10px;
  padding:10px 12px; outline:none;
}
label > input:focus, label > textarea:focus, label > select:focus{
  border-color:var(--brand); box-shadow:0 0 0 3px rgba(59,130,246,.18);
}

/* Keep checkbox/radio inline */
input[type="checkbox"], input[type="radio"]{
  width:auto; display:inline-block; vertical-align:middle; margin-right:6px;
}
label.checkbox-inline, label.radio-inline{ display:inline-flex; align-items:center; gap:.35rem; font-weight:500; cursor:pointer; }

/* -------- Tables -------- */
.table{ width:100%; border-collapse:separate; border-spacing:0; }
.table th, .table td{ padding:14px 16px; border-bottom:1px solid var(--border); }
.table thead th{ color:#64748b; font-weight:600; text-align:left; background:var(--panel-2); position:sticky; top:0; z-index:1; backdrop-filter: blur(4px); }
.table td .btn{ white-space:nowrap; }

/* -------- Pills / Badges -------- */
.pill{ display:inline-block; padding:2px 8px; border-radius:999px; border:1px solid var(--border); font-size:12px; color:var(--text); background:var(--panel-2) }
.pill--good{border-color:#86efac;color:#166534;background:#ecfdf5}
.pill--bad{border-color:#fecaca;color:#7f1d1d;background:#fff1f2}
.pill--warn{border-color:#fde68a;color:#7a5a1f;background:#fffbeb}

/* -------- Flash -------- */
.flash{ margin:12px 0; padding:10px 12px; border-radius:var(--radius-md); border:1px solid var(--border); background:var(--panel); color:var(--text) }
.flash--success{ background:#ecfdf5; color:#166534; border:1px solid #86efac; }
.flash--error{ background:#fff1f2; color:#7f1d1d; border:1px solid #fecaca; }
.flash--info{ background:#eff6ff; color:#1e40af; border:1px solid #93c5fd; }
.alert{ padding:10px 14px; border-radius:12px; margin-bottom:12px; }
.alert-success{ background:#ecfdf5; color:#166534; border:1px solid #86efac; }
.alert-danger{ background:#fff1f2; color:#7f1d1d; border:1px solid #fecaca; }

/* -------- Grid (Dashboard metrics) - DEPRECATED, use grid-4, grid-3, grid-2 instead -------- */
.grid{ display:grid; gap:16px; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)) }
/* Legacy metric styling - use .kpi class for new designs */
.metric .num{font-size:36px;font-weight:800;line-height:1.1;color:var(--text)}
.metric h3{margin:0 0 6px;font-size:14px;color:var(--muted);font-weight:600;letter-spacing:.3px;text-transform:uppercase}

/* -------- Auth Cards / Layout -------- */
.auth-card{ position:relative; background:rgba(255,255,255,.62); -webkit-backdrop-filter:saturate(140%) blur(12px); backdrop-filter:saturate(140%) blur(12px); border:1px solid rgba(15,23,42,.08); box-shadow:0 12px 30px rgba(16,24,40,.12), 0 2px 6px rgba(16,24,40,.06); overflow:hidden; max-width:480px; margin-left:auto; margin-right:auto; }
.auth-card .title{margin:0 0 6px;color:var(--text);text-align:center}
.auth-card .subtitle{margin:0 0 18px;color:var(--muted);text-align:center}
.auth-logo-wrap{ text-align:center; margin:16px 0; display:flex; align-items:center; justify-content:center; }
.auth-logo{ height:120px; width:256px; object-fit:cover; object-position:center; display:inline-block; }

body.auth-page{ margin:0!important; padding:0!important; background:#fff; color:var(--text); overflow-x:hidden; }
body.auth-page .header, body.auth-page .topbar, body.auth-page header.site-header, body.auth-page nav.site-nav, body.auth-page .footer{ display:none!important; }

.auth-overlay{ min-height:100vh; display:grid; place-items:center; padding:2rem; background-image: url('/assets/login-bg-3.png'), radial-gradient(1200px 840px at 80% -10%, rgba(59,130,246,.10), transparent 60%), radial-gradient(1000px 700px at -10% 120%, rgba(2,132,199,.08), transparent 60%), linear-gradient(180deg, #f7f9fc 0%, #f3f6fb 60%, #eef2f8 100%); background-attachment: fixed, fixed, fixed, scroll; background-size: cover, 100% 100%; background-position: center; background-repeat: no-repeat; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }

body.auth-page .main, body.auth-page .container, body.auth-page .container-sm, body.auth-page .container-md{ max-width:none!important; width:100%!important; margin:0!important; padding:0!important; background:transparent!important; border:0!important; box-shadow:none!important; }

/* Auth split */
body.auth-page .auth-split-wrap{ display:flex; width:100vw; min-height:100svh; }
.auth-left{ background:#fff; width:min(520px,44vw); display:flex; align-items:center; justify-content:center; border-right:1px solid var(--border); padding:32px 56px; box-sizing:border-box; }
.auth-right{ flex:1; background-image:var(--login-hero); background-size:cover; background-position:center; position:relative; }
.auth-right::after{ content:""; position:absolute; inset:0; background:linear-gradient(90deg, rgba(0,0,0,0) 20%, rgba(0,0,0,.06) 60%, rgba(0,0,0,.10) 100%); pointer-events:none; }

/* Muted background specifically for register page */
.auth-right.register-bg::after{ background:linear-gradient(90deg, rgba(255,255,255,.70) 0%, rgba(255,255,255,.50) 40%, rgba(255,255,255,.30) 100%); }

@media (max-width:920px){ .auth-right{ display:none; } .auth-left{ width:100%; border-right:none; padding:24px; } .auth-card{ max-width:520px; } }

/* Remember/Forgot cluster */
.remember-wrap{ display:flex; flex-direction:column; align-items:flex-start; gap:4px; margin-bottom:1.5rem; }
.checkbox-wrap{ display:inline-flex; align-items:center; gap:8px; font-size:.95rem; color:var(--muted); }
.checkbox{ width:16px; height:16px; margin:0; vertical-align:middle; accent-color:var(--brand); }
.forgot-link{ font-size:.85rem; color: color-mix(in srgb, var(--muted) 80%, var(--link) 20%); text-decoration:none; margin-left:25px; opacity:.85; transition: color .2s, opacity .2s; }
.forgot-link:hover{ color:var(--link); opacity:1; text-decoration:underline; }

/* Auth page full-width button variant */
.auth-page .btn-primary.w-full,
.auth-split .btn-primary.w-full{ width:100%; padding:.95rem 1rem; }

/* ---- Modal ---- */
.modal{ position:fixed; inset:0; display:none; align-items:center; justify-content:center; background:rgba(16,24,40,.55); z-index:1000; padding:24px; -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); }
.modal.show{ display:flex; }
.modal-dialog{ width:100%; max-width:920px; }
.modal-content{ background:var(--panel); border:1px solid var(--border); border-radius:22px; box-shadow:var(--shadow-float); overflow:hidden; animation:modalIn .25s ease both; }
@keyframes modalIn{from{transform:translateY(10px) scale(.98);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}
.modal-header,.modal-footer{ padding:16px 18px; background:rgba(16,24,40,.02); }
.modal-body{ padding:18px; }
.modal-title{ margin:0; font-size:1.1rem; color:var(--text); }
.close{ border:0; background:transparent; color:var(--muted); font-size:22px; line-height:1; cursor:pointer; padding:4px 8px; border-radius:10px; }
.close:hover{ background:rgba(2,6,23,.06); color:var(--text); }

/* -------- Responsive tweaks -------- */
@media (max-width:640px){ .nav a{margin:0 4px} .h1{font-size:24px} }

/* -------- Bootstrap Icons integration -------- */
/* Requires: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css"> */
.with-icon-left{ display:inline-flex; align-items:center; gap:.5rem; }
.with-icon-left .bi{ font-size:1.1em; line-height:1; vertical-align:middle; }
.btn .bi{ color:inherit; }
.btn--outline .bi, .btn--ghost .bi{ color:var(--muted); }

/* -------- App pages background overlay -------- */
body.app-page{
  --dash-bg-overlay: rgba(255,255,255,.78);
  min-height: 100vh;
  background:
    linear-gradient(var(--dash-bg-overlay), var(--dash-bg-overlay)),
    url('/assets/login-bg-3.png') center center / cover no-repeat fixed,
    radial-gradient(1200px 840px at 80% -10%, rgba(59,130,246,.10), transparent 60%),
    radial-gradient(1000px 700px at -10% 120%, rgba(2,132,199,.08), transparent 60%),
    linear-gradient(180deg, #f7f9fc 0%, #f3f6fb 60%, #eef2f8 100%);
  background-attachment: scroll, fixed, scroll, scroll, scroll;
}
/* Force light theme for app pages */

/* ========================================================================== */
/* Admin Dashboard Layout Enhancements                                        */
/* ========================================================================== */

.admin-dash {
  display: flex;
  flex-direction: column;
  gap: 1.5rem; /* vertical spacing between dashboard sections */
  padding-bottom: 2rem;
}

/* KPI cards layout (4 across on large, 2 on tablet, 1 on mobile) */
.admin-dash .grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

/* Two-column grids (like role + sign-ins, users + certs) */
.admin-dash .grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

/* Card styling */
.admin-dash .card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  padding: 1.25rem;
}

/* KPI card visuals */
.admin-dash .card.kpi {
  text-align: left;
}
.admin-dash .kpi-main {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.25rem;
}
.admin-dash .kpi-sub {
  font-size: 0.95rem;
  color: var(--muted);
}
.trend {
  margin-left: 0.35rem;
  font-weight: 600;
}
.trend.up { color: var(--good); }
.trend.down { color: var(--bad); }
.trend.flat { color: var(--muted); }

/* Headings inside cards */
.card-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* Table wrapping and compact spacing */
.table-wrap {
  overflow-x: auto;
}
.table.compact th,
.table.compact td {
  padding: 0.45rem 0.6rem;
}

/* Grid & card spacing on small screens */
@media (max-width: 768px) {
  .admin-dash .grid-4,
  .admin-dash .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Admin Dropdown - Match existing top-nav style
   ========================================================================== */
.nav-item.nav-dropdown {
  position: relative;
  display: inline-block;
}

/* make trigger look like a regular nav link */
.nav-btn {
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 0.4rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-btn:hover,
.nav-dropdown.open .nav-btn {
  background: var(--panel-2);
  color: var(--link);
}

.nav-btn .caret {
  font-size: 0.8em;
  opacity: 0.7;
  margin-left: 0.15rem;
}

/* dropdown container */
.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  padding: 0.35rem;
  display: none;
  z-index: 50;
}

.nav-dropdown.open .dropdown-menu {
  display: block;
}

/* dropdown items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 0.4rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.dropdown-item:hover {
  background: var(--panel-2);
  color: var(--link);
}

.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 0.3rem 0.25rem;
}

/* Make buttons styled like nav links */
.nav a,
.nav .nav-link{
  color:var(--muted);
  margin:0 6px;
  padding:8px 14px;
  border:1px solid transparent;
  border-radius:var(--radius-md);
  font-weight:500;
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  background:transparent;
  line-height:1.1;
  transition:background .25s,color .25s;
}

/* Unified hover/active states (same tint as other links) */
.nav a:hover,
.nav a.active,
.nav .nav-link:hover,
.nav-dropdown.open .nav-link{
  color:var(--text);
  background:rgba(59,130,246,.10);
}

/* Keep caret & icons aligned like other items */
.nav .nav-link .caret{ font-size:.9em; opacity:.7; margin-left:.1rem; }
.nav .nav-link .bi{ line-height:1; }

/* Mobile sheet should treat button like a link */
@media (max-width: 768px){
  .header .nav a,
  .header .nav .nav-link{
    padding:.75rem .75rem;
    border-radius:.5rem;
  }
}

/* Admin Users: inline role editor */
.role-form{
  display:inline-flex; align-items:center; gap:8px; flex-wrap:nowrap;
}

/* -------- Solid background selects (Admin Users) -------- */
.select-sm, .role-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  /* Solid neutral panel background */
  background-color: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 36px 8px 12px;
  height: 36px;
  font: inherit;
  color: var(--text);
  line-height: 1.2;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, background-color .2s;

  /* Inline SVG caret */
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23647689' viewBox='0 0 16 16'%3E%3Cpath d='M3.2 5.6a1 1 0 0 1 1.4 0L8 9l3.4-3.4a1 1 0 1 1 1.4 1.4L8.7 11.1a1.2 1.2 0 0 1-1.4 0L3.2 7a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
}

.select-sm:focus,
.role-select:focus {
  outline: none;
  border-color: color-mix(in oklab, var(--brand) 65%, var(--border));
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
  background-color: var(--panel);
}

.select-sm:disabled,
.role-select:disabled {
  opacity: .65;
  cursor: not-allowed;
}

/* Force light theme for select elements */

.role-select:focus{
  border-color: color-mix(in oklab, var(--brand) 65%, var(--border));
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
  outline: none;
}

.role-select:disabled{
  opacity:.65; cursor:not-allowed;
}

/* Make the action cell behave nicely on narrow screens */
.table td.actions-cell{
  white-space:nowrap;
}
.table td.actions-cell .btn-sm{
  height:36px;              /* same height as select */
  line-height:1;            /* perfect alignment */
  padding:6px 12px;
}

/* Optional: shrink font slightly inside table controls */
.table .role-select, .table .btn-sm{
  font-size:.95rem;
}

/* Normalize buttons and links to same visual size */
.btn,
.btn-sm,
.btn--outline,
.btn--ghost,
.btn--muted {
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.2;
  text-decoration: none;
  vertical-align: middle;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  box-sizing: border-box;
}

/* Ensure same baseline alignment for <a> and <button> */
a.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  background-clip: padding-box;
}

/* --- Compact variant: identical sizing for both tag types --- */
.btn-sm,
a.btn-sm,
button.btn-sm {
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.1;
  height: 36px; /* lock height consistency */
}

/* Prevent native button extra padding in Safari/Firefox */
button.btn,
button.btn-sm {
  border-width: 1px;
  background-clip: padding-box;
  line-height: 1.1;
  font-family: inherit;
  font-size: inherit;
}

/* 404 Page */
.error-card{
  text-align:center; padding:2.25rem; background:var(--panel);
  border:1px solid var(--border); border-radius:16px;
  box-shadow: 0 8px 24px rgba(2,8,23,.05);
}
.error-hero{ color:var(--text); }
.error-illustration{ display:block; margin:0 auto 0.75rem; color:var(--brand-2); }
.error-hero .h1{ margin:.25rem 0 .5rem; }
.error-hero .muted{ color:var(--muted); margin:0 auto 0.75rem; max-width:48ch; }
.error-actions{ display:flex; gap:.5rem; flex-wrap:wrap; justify-content:center; margin: .5rem 0 1rem; }
.error-search{ display:flex; gap:.5rem; justify-content:center; flex-wrap:wrap; }
.error-search .input{ min-width:260px; max-width:480px; background:var(--panel-2); border:1px solid var(--border); }
.error-meta{ margin-top:1rem; text-align:left; }
.error-meta summary{ cursor:pointer; color:var(--muted); }
.error-meta-grid{ display:grid; grid-template-columns: 140px 1fr; gap:.5rem 1rem; margin-top:.5rem; }
.error-meta-grid .k{ color:var(--muted); }
.error-meta-grid .v{ color:var(--text); word-break:break-all; }

/* Ensure .btn-sm is consistent for <a> and <button> as you noted */
.btn-sm{ font-size:.875rem; line-height:1; padding:.5rem .7rem; border-radius:10px; }
a.btn.btn-sm, button.btn.btn-sm{ display:inline-flex; align-items:center; gap:.35rem; }

/* ========== Table polish: zebra, hover, density, truncation ========== */
.table.zebra tbody tr:nth-child(even){ background: color-mix(in srgb, var(--panel) 90%, var(--panel-2) 10%); }
.table.hover tbody tr:hover{ background: color-mix(in srgb, var(--panel) 85%, var(--panel-2) 15%); }

/* Dense variant for admin lists */
.table.dense th, .table.dense td{ padding:10px 12px; font-size: 0.9375rem; }

/* Modern table enhancements */
.table tbody tr {
  transition: background-color 0.15s ease;
}

.table .badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

/* Action buttons in tables */
.table .actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.table .actions .btn {
  margin: 0;
}

/* Make sure icons in tables are properly sized */
.table .bi {
  font-size: 1rem;
  vertical-align: middle;
}

/* Empty state styling in tables */
.table .muted,
.table td.muted {
  color: var(--muted);
  font-style: italic;
}

/* Status badges in tables */
.table .status-draft {
  background-color: #f3f4f6;
  color: #374151;
}

.table .status-signed {
  background-color: #d1fae5;
  color: #065f46;
}

.table .status-void {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Column helpers */
.cell-right, .t-right, .text-right { text-align:right; }
.cell-center, .t-center, .text-center { text-align:center; }
.cell-nowrap{ white-space:nowrap; }
.cell-mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

/* Truncate long text but keep full value on hover via title attr */
.truncate{
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom;
}
@media (max-width: 820px){
  .truncate{ max-width: 200px; }
}

/* Visual chips for roles & status */
.chip{ display:inline-flex; align-items:center; gap:.35rem; padding:.2rem .5rem; border-radius:999px; border:1px solid var(--border); background:var(--panel-2); font-size:.85rem; }
.chip i{ font-size:1em; line-height:1; }
.chip.owner{ border-color:#c7d2fe; background:#eef2ff; color:#3730a3; }
.chip.admin{ border-color:#bae6fd; background:#e0f2fe; color:#075985; }
.chip.staff{ border-color:#bbf7d0; background:#ecfdf5; color:#166534; }
.chip.readonly{ border-color:#fde68a; background:#fffbeb; color:#7a5a1f; }

.badge-live{ display:inline-block; width:8px; height:8px; border-radius:999px; background:var(--good); box-shadow:0 0 0 3px rgba(22,163,74,.15); }
.badge-dead{ display:inline-block; width:8px; height:8px; border-radius:999px; background:#9ca3af; }

/* Row actions appear on hover to reduce clutter */
.row-actions{ opacity:.0; transition:opacity .15s ease; display:inline-flex; gap:6px; }
tbody tr:hover .row-actions{ opacity:1; }

/* Sticky header already present; make it slightly raised */
.table thead th{ z-index:2; box-shadow:0 1px 0 var(--border); }

/* Card titles for sections */
.card .card-sub{ color:var(--muted); font-size:.9rem; margin:-2px 0 10px; }

/* Compact “copy” button for IDs (mono, subtle) */
.copy-btn{
  border:1px solid var(--border); background:var(--panel-2); color:var(--text);
  border-radius:8px; padding:4px 8px; font-size:.8rem; line-height:1; cursor:pointer;
}
.copy-btn:hover{ background:color-mix(in srgb, var(--panel-2) 80%, var(--panel) 20%); }

/* Responsive: hide less-crucial columns on very small screens */
@media (max-width: 640px){
  .col-hide-sm{ display:none; }
}

.audit-subject-cell {
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-width: 260px;
}
.audit-subject-cell .truncate {
  flex: 1 1 auto;        /* allow text to take remaining width */
  min-width: 0;          /* prevent overflow when truncated */
}

/* Users table: stacked name + email */
.table .text-muted {
  color: var(--muted);
  font-weight: 400;
}

/* Align icons and text nicely */
.table .bi-person-circle {
  margin-right: 6px;
  font-size: 1.05em;
  vertical-align: middle;
}

/* Users search bar */
.user-search{
  display:inline-flex; align-items:center; gap:8px;
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: 12px;
  padding: 6px 8px 6px 10px;
}
.user-search .bi-search{ color: var(--muted); }
.user-search .input-search{
  border:0; background:transparent; outline:none;
  min-width: 220px; font: inherit; color: var(--text);
  padding: 6px 6px;
}
.user-search .input-search::placeholder{ color:#9aa7b7; }
@media (max-width: 640px){
  .user-search .input-search{ min-width: 140px; }
}

/* Pagination */
.pagination{
  display:flex; align-items:center; justify-content:center; gap:6px;
  flex-wrap:wrap;
}
.pagination .btn-sm{
  min-width:34px; text-align:center; line-height:1.2;
}
.pagination .btn-sm.active{
  background:var(--brand);
  color:#fff;
  border-color:var(--brand);
}
.page-info{
  color:var(--muted);
  font-size:.9rem;
  padding:0 .5rem;
}

.field-error{
  display:none;
  margin:6px 0 0;
  font-size:.875rem;
  color:#dc2626; /* or var(--bad) to match your palette */
}
.input.is-invalid{
  border-color:#dc2626 !important;
  outline-color:#dc2626;
}

/* -------- Form Sections & Layout -------- */
.form {
  width: 100%;
}

/* Owner form should not be constrained by grid */
.owner-form {
  width: 100%;
  display: block;
}




.form-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
  border-bottom: none;
}

.form-section h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.form-row .form-group {
  margin-bottom: 0;
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}

/* -------- Text Utilities -------- */
.text-danger {
  color: var(--bad);
}

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

.text-center {
  text-align: center;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-4 {
  margin-bottom: 16px;
}


/* -------- Metric Cards - LEGACY (use .kpi class for modern design) -------- */
.metric {
  text-align: center;
}

.metric h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.metric .num {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}

/* -------- Screen Reader Only -------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ==========================================================================
   MODERN KPI CARDS & GRIDS - Global styles matching admin design
   ========================================================================== */

/* Grid Layouts */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Modern KPI Card Styling */
.card.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-raise);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  animation: cardIn .28s ease both;
}

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

.card.kpi .muted {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card.kpi .muted i {
  font-size: 1rem;
  opacity: 0.7;
}

.kpi-main {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Badge styling for KPIs */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
}

.badge-success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-secondary {
  background-color: #f3f4f6;
  color: #374151;
}

.badge-info {
  background-color: #dbeafe;
  color: #1e40af;
}

.badge-primary {
  background-color: #ddd6fe;
  color: #5b21b6;
}

/* Trend indicators */
.trend {
  margin-left: 0.35rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.trend.up {
  color: var(--good);
}

.trend.down {
  color: var(--bad);
}

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

/* Page Header - Modern Layout */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-header .header-content {
  flex: 1;
  min-width: 0;
}

.page-header .header-content .h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.page-header .header-content .muted {
  font-size: 0.9375rem;
  color: var(--muted);
  margin: 0;
}

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

/* Icon badges for page headers */
.dashboard-icon,
.security-icon,
.development-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-radius: 12px;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
  flex-shrink: 0;
}

/* Card Title with Icons */
.card-title {
  font-weight: 600;
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title i {
  font-size: 1.25rem;
  color: var(--brand);
}

/* Ensure buttons in card-title maintain proper size */
.card-title .btn,
.card-title .btn-sm {
  font-size: 0.875rem;
}

.card-title .btn-sm {
  padding: 0.4rem 0.875rem;
  min-height: 32px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .page-header .header-actions {
    width: 100%;
    justify-content: stretch;
  }
  
  .page-header .header-actions .btn {
    flex: 1;
  }
  
  .kpi-main {
    font-size: 1.875rem;
  }
}

@media (max-width: 640px) {
  .dashboard-icon,
  .security-icon,
  .development-icon {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .kpi-main {
    font-size: 1.625rem;
  }
}

/* AI Status Badges */
.ai-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
}

.ai-status-badge.pending {
  background-color: #fef3c7;
  color: #92400e;
}

.ai-status-badge i {
  font-size: 0.875rem;
}
