:root{
  --bg:#f6f2ea;
  --bg-alt:#e9eef4;
  --panel:rgba(255,255,255,.88);
  --panel-solid:#ffffff;
  --muted:#5c6877;
  --text:#17212b;
  --text-soft:#304253;
  --primary:#9f1d2a;
  --primary-600:#7d1822;
  --primary-100:#f8dde1;
  --accent:#c48b33;
  --accent-100:#f7ecd8;
  --border:#ddd8cf;
  --border-strong:#c9c2b3;
  --ring:rgba(159,29,42,.16);
  --success:#1f6b53;
  --shadow:0 20px 52px rgba(15,23,42,.08);
  --shadow-sm:0 10px 28px rgba(15,23,42,.06);
  --radius:22px;
  --radius-md:16px;
  --radius-sm:12px;
  --font-body:"Segoe UI Variable Text","Trebuchet MS","Segoe UI",sans-serif;
  --font-display:Georgia,"Times New Roman",serif;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  color:var(--text);
  font-family:var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(196,139,51,.18), transparent 26%),
    radial-gradient(circle at top right, rgba(159,29,42,.14), transparent 28%),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-alt) 100%);
}

a{color:inherit}

.page-shell{
  max-width:1280px;
  margin:32px auto;
  padding:0 18px 40px;
}

.app-shell{
  background:var(--panel);
  backdrop-filter:blur(18px);
  border:1px solid rgba(255,255,255,.72);
  border-radius:32px;
  box-shadow:var(--shadow);
  overflow:hidden;
}

.app-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  padding:26px 30px 20px;
  border-bottom:1px solid rgba(201,194,179,.45);
  background:
    linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,250,244,.82)),
    linear-gradient(90deg, rgba(159,29,42,.04), transparent);
}

.brand-block{
  display:grid;
  gap:8px;
}

.brand-kicker{
  display:inline-flex;
  align-items:center;
  gap:8px;
  width:max-content;
  padding:6px 11px;
  border-radius:999px;
  background:var(--primary-100);
  color:var(--primary);
  font-size:12px;
  font-weight:700;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.brand-title{
  margin:0;
  font-family:var(--font-display);
  font-size:clamp(30px,4vw,44px);
  line-height:1.02;
  letter-spacing:-.03em;
}

.brand-copy,
.sub,
.muted{
  margin:0;
  color:var(--muted);
  font-size:14px;
  line-height:1.55;
}

.app-meta{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:10px;
  align-items:center;
  color:var(--text-soft);
  font-size:14px;
}

.chip,
.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:7px 11px;
  border-radius:999px;
  background:rgba(255,255,255,.86);
  border:1px solid rgba(201,194,179,.8);
  color:var(--text-soft);
  font-size:12px;
  font-weight:700;
  letter-spacing:.03em;
}

.chip-accent{
  background:var(--accent-100);
  border-color:rgba(196,139,51,.28);
  color:#855718;
}

.chip-primary{
  background:var(--primary-100);
  border-color:rgba(159,29,42,.16);
  color:var(--primary);
}

.tabs{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  padding:20px 30px 0;
}

.tab-chip{
  display:inline-flex;
  align-items:center;
  padding:11px 15px;
  border-radius:999px;
  border:1px solid transparent;
  background:rgba(255,255,255,.72);
  color:var(--muted);
  text-decoration:none;
  font-size:14px;
  font-weight:700;
  transition:transform .14s ease, background .14s ease, border-color .14s ease, color .14s ease;
}

.tab-chip:hover{
  transform:translateY(-1px);
  background:rgba(255,255,255,.94);
  border-color:rgba(201,194,179,.65);
  color:var(--text);
}

.tab-chip.active{
  background:var(--text);
  border-color:var(--text);
  color:#fff;
  box-shadow:var(--shadow-sm);
}

.content-stack{
  display:grid;
  gap:24px;
  padding:24px 30px 30px;
}

.hero{
  position:relative;
  overflow:hidden;
  display:grid;
  gap:18px;
  padding:30px;
  border:1px solid rgba(201,194,179,.4);
  border-radius:28px;
  background:
    radial-gradient(circle at top right, rgba(196,139,51,.18), transparent 28%),
    linear-gradient(135deg, rgba(159,29,42,.94), rgba(110,26,33,.96));
  color:#fff;
}

.hero::after{
  content:"";
  position:absolute;
  inset:auto -42px -46px auto;
  width:180px;
  height:180px;
  border-radius:50%;
  background:rgba(255,255,255,.08);
}

.hero > *{position:relative;z-index:1}

.hero h1,
.hero h2{
  margin:0;
  font-family:var(--font-display);
  font-size:clamp(28px,4vw,42px);
  line-height:1.04;
  letter-spacing:-.03em;
}

.hero > p{
  margin:0;
  max-width:760px;
  font-size:15px;
  line-height:1.65;
  color:rgba(255,255,255,.82);
}

.hero-actions,
.actions,
.toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

.stats-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
}

.metric-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
}

.metric-card{
  padding:18px 20px;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(255,248,242,.96);
  box-shadow:0 16px 34px rgba(34,20,20,.12);
  color:var(--text);
}

.metric-label{
  margin:0 0 6px;
  color:var(--primary);
  font-size:12px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.metric-value{
  margin:0;
  color:var(--text);
  font-size:30px;
  line-height:1.05;
  font-weight:800;
}

.metric-copy{
  margin:8px 0 0;
  color:var(--text-soft);
  font-size:14px;
  line-height:1.5;
}

.stat-card{
  padding:18px 20px;
  border-radius:20px;
  border:1px solid rgba(201,194,179,.42);
  background:rgba(255,255,255,.8);
  box-shadow:var(--shadow-sm);
}

.stat-label{
  margin:0 0 6px;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.stat-value{
  margin:0;
  font-size:28px;
  line-height:1.1;
  font-weight:800;
  color:var(--text);
}

.stat-copy{
  margin:8px 0 0;
  color:var(--muted);
  font-size:13px;
  line-height:1.45;
}

.section{
  display:grid;
  gap:14px;
  min-width:0;
}

.section-heading{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:14px;
}

.section-title{
  margin:0;
  font-size:22px;
  line-height:1.1;
  letter-spacing:-.02em;
}

.section-copy{
  margin:0;
  color:var(--muted);
  font-size:14px;
  line-height:1.55;
}

.feature-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
}

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

.feature-card{
  display:grid;
  gap:12px;
  padding:22px;
  min-height:188px;
  border-radius:22px;
  border:1px solid rgba(201,194,179,.46);
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(252,249,245,.92));
  box-shadow:var(--shadow-sm);
  text-decoration:none;
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.feature-card:hover{
  transform:translateY(-3px);
  border-color:rgba(159,29,42,.22);
  box-shadow:0 18px 36px rgba(15,23,42,.1);
}

.feature-card.primary{
  background:
    radial-gradient(circle at top right, rgba(196,139,51,.18), transparent 28%),
    linear-gradient(180deg, rgba(159,29,42,.96), rgba(114,28,33,.96));
  color:#fff;
}

.feature-card.primary .feature-copy,
.feature-card.primary .feature-meta{
  color:rgba(255,255,255,.8);
}

.feature-eyebrow{
  color:var(--primary);
  font-size:12px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.feature-card.primary .feature-eyebrow{
  color:rgba(255,255,255,.74);
}

.feature-title{
  margin:0;
  font-size:20px;
  line-height:1.18;
  letter-spacing:-.02em;
}

.feature-copy{
  margin:0;
  color:var(--muted);
  font-size:14px;
  line-height:1.6;
}

.feature-meta{
  margin-top:auto;
  color:var(--text-soft);
  font-size:13px;
  font-weight:700;
}

.stack{
  display:grid;
  gap:16px;
}

.split-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:18px;
}

.card{
  background:var(--panel-solid);
  border:1px solid rgba(201,194,179,.52);
  border-radius:24px;
  min-width:0;
  box-shadow:var(--shadow-sm);
  padding:22px;
}

.card h1,
.card h2,
.card h3{
  margin:0 0 8px;
}

.toolbar{
  margin:0 0 16px;
}

.inline-form{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:flex-end;
}

.field{
  display:grid;
  gap:6px;
  min-width:0;
}

.field.grow{
  flex:1 1 220px;
}

.label{
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.input,
.select,
.textarea,
input,
select,
textarea{
  width:100%;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  color:var(--text);
  font:inherit;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.textarea{
  min-height:120px;
  resize:vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
input:focus,
select:focus,
textarea:focus{
  outline:0;
  border-color:rgba(159,29,42,.42);
  box-shadow:0 0 0 4px var(--ring);
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:44px;
  padding:10px 15px;
  border:1px solid rgba(201,194,179,.82);
  border-radius:999px;
  background:rgba(255,255,255,.88);
  color:var(--text);
  text-decoration:none;
  cursor:pointer;
  font:inherit;
  font-weight:700;
  transition:transform .14s ease, border-color .14s ease, background .14s ease, color .14s ease;
}

.btn:hover{
  transform:translateY(-1px);
  border-color:rgba(159,29,42,.24);
  background:#fff;
}

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

.btn-primary:hover{
  background:var(--primary-600);
  border-color:var(--primary-600);
}

.btn-ghost{
  background:transparent;
}

.btn-danger{
  background:#b4232f;
  border-color:#b4232f;
  color:#fff;
}

.btn-danger:hover{
  background:#931b25;
  border-color:#931b25;
}

.table-wrap{
  overflow-x:auto;
  overflow-y:auto;
  border-radius:20px;
  border:1px solid rgba(201,194,179,.52);
  max-width:100%;
}

/* Sticky phantom scrollbar injected by sticky-scroll.js */
.ss-phantom{
  position:fixed;
  bottom:0;
  overflow-x:auto;
  overflow-y:hidden;
  height:14px;
  z-index:500;
  background:var(--bg,#f6f2ea);
  border-top:1px solid rgba(201,194,179,.5);
  box-sizing:border-box;
  display:none;
}
.ss-phantom::-webkit-scrollbar{height:10px}
.ss-phantom::-webkit-scrollbar-track{background:var(--bg,#f6f2ea)}
.ss-phantom::-webkit-scrollbar-thumb{background:var(--primary,#9f1d2a);border-radius:5px}
.ss-phantom::-webkit-scrollbar-thumb:hover{background:var(--primary-600,#7d1822)}

.table{
  width:100%;
  min-width:500px;
  border-collapse:collapse;
  background:var(--panel-solid);
}

.table th,
.table td{
  padding:12px 14px;
  border-bottom:1px solid rgba(222,216,207,.72);
  text-align:left;
  font-size:14px;
  vertical-align:top;
}

.table th{
  position:sticky;
  top:0;
  z-index:1;
  background:#faf7f2;
  color:var(--text-soft);
  font-size:12px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.table tbody tr:nth-child(even){
  background:rgba(249,246,241,.58);
}

.table tbody tr:hover{
  background:rgba(248,221,225,.34);
}

.table tfoot th,
.table tfoot td{
  background:#faf3e6;
  font-weight:800;
}

.num{
  text-align:right;
  white-space:nowrap;
}

.empty-state{
  padding:28px;
  border-radius:22px;
  border:1px dashed rgba(201,194,179,.9);
  background:rgba(255,255,255,.7);
  color:var(--muted);
  text-align:center;
}

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

.chart-row{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:18px;
}

.chart-card{
  display:grid;
  gap:12px;
}

.chart-card canvas{
  width:100%;
  min-height:320px;
}

.divider{
  height:1px;
  background:linear-gradient(90deg, transparent, rgba(201,194,179,.8), transparent);
}

.list-clean{
  margin:0;
  padding:0;
  list-style:none;
}

.list-clean li + li{
  margin-top:10px;
}

@media (max-width:1080px){
  .feature-grid.cols-4{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .feature-grid,
  .split-grid,
  .chart-row{
    grid-template-columns:1fr 1fr;
  }

  .stats-grid,
  .metric-grid{
    grid-template-columns:1fr 1fr;
  }
}

@media (max-width:760px){
  .page-shell{
    margin:18px auto;
    padding:0 12px 24px;
  }

  .app-header,
  .tabs,
  .content-stack{
    padding-left:16px;
    padding-right:16px;
  }

  .app-header{
    padding-top:18px;
  }

  .app-meta{
    justify-content:flex-start;
  }

  .stats-grid,
  .metric-grid,
  .feature-grid,
  .feature-grid.cols-4,
  .split-grid,
  .chart-row{
    grid-template-columns:1fr;
  }

  .hero{
    padding:22px;
  }
}

/* =====================================================================
   LEGACY PAGE LAYOUT — used by CRUD / report pages
   ===================================================================== */

.legacy-page{
  max-width:1280px;
  margin:0 auto;
  padding:0 20px 48px;
  font-family:var(--font-body);
  color:var(--text);
}

/* Top navigation bar */
.page-nav{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  padding:14px 20px;
  background:
    linear-gradient(135deg,rgba(255,255,255,.95),rgba(255,250,244,.88)),
    linear-gradient(90deg,rgba(159,29,42,.04),transparent);
  border-bottom:1px solid rgba(201,194,179,.5);
  position:sticky;
  top:0;
  z-index:100;
  backdrop-filter:blur(12px);
}

.page-nav-left,
.page-nav-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

/* Page title row below nav */
.page-heading{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  flex-wrap:wrap;
  gap:12px;
  padding:24px 0 16px;
}

.page-title{
  margin:0;
  font-size:clamp(20px,3vw,28px);
  line-height:1.1;
  letter-spacing:-.02em;
}

/* Alert / message banners */
.alert{
  padding:12px 16px;
  border-radius:14px;
  font-size:14px;
  line-height:1.5;
  margin-bottom:14px;
}

.alert-err{
  background:#fde8e9;
  border:1px solid rgba(159,29,42,.28);
  color:#7a1212;
}

.alert-ok{
  background:#e4f5ee;
  border:1px solid rgba(31,107,83,.28);
  color:#0f5132;
}

.alert-info{
  background:#e8f0fb;
  border:1px solid rgba(43,108,176,.24);
  color:#1a4a7a;
}

/* Filter/action toolbar for list pages */
.controls{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
}

/* Pagination */
.pagination{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:6px;
  margin-top:16px;
}

.pagination a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:36px;
  height:36px;
  padding:0 10px;
  border-radius:999px;
  border:1px solid rgba(201,194,179,.7);
  background:rgba(255,255,255,.8);
  color:var(--text-soft);
  text-decoration:none;
  font-size:13px;
  font-weight:700;
  transition:background .12s, border-color .12s, color .12s;
}

.pagination a:hover{
  background:#fff;
  border-color:rgba(159,29,42,.3);
  color:var(--primary);
}

.pagination strong{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:36px;
  height:36px;
  padding:0 10px;
  border-radius:999px;
  background:var(--primary);
  color:#fff;
  font-size:13px;
  font-weight:800;
  border:1px solid var(--primary);
}

/* Form card wrapper for create/edit pages */
.form-card{
  max-width:760px;
  background:var(--panel-solid);
  border:1px solid rgba(201,194,179,.52);
  border-radius:24px;
  box-shadow:var(--shadow-sm);
  padding:28px 28px 32px;
}

.form-card h2,
.form-card h3{
  margin:0 0 20px;
  font-size:22px;
  letter-spacing:-.02em;
}

.form-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}

.form-field{
  display:grid;
  gap:6px;
}

.form-field label,
.field-label{
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.form-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:24px;
  padding-top:18px;
  border-top:1px solid rgba(201,194,179,.45);
}

.inline-check{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:10px;
  font-size:14px;
  color:var(--text-soft);
}

.inline-check input[type="checkbox"]{
  width:auto;
  accent-color:var(--primary);
}

.field-hint{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
}

/* Login page */
.login-wrap{
  max-width:440px;
  margin:8vh auto;
  padding:20px;
}

.login-card{
  background:#fff;
  border:1px solid rgba(201,194,179,.6);
  border-radius:24px;
  box-shadow:var(--shadow);
  padding:32px 28px;
}

.login-logo{
  display:block;
  margin:0 0 4px;
  font-family:var(--font-display);
  font-size:28px;
  letter-spacing:-.03em;
  color:var(--text);
}

.login-sub{
  color:var(--muted);
  font-size:14px;
  margin:0 0 22px;
}

.login-footer{
  margin-top:14px;
  font-size:12px;
  color:var(--muted);
  text-align:center;
}

/* Responsive tweaks for legacy pages */
@media (max-width:760px){
  .legacy-page{
    padding:0 12px 32px;
  }

  .page-nav{
    padding:12px 14px;
  }

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

  .form-card{
    padding:20px 16px 24px;
  }

  .page-heading{
    padding:16px 0 12px;
  }
}
