/* =========================
   Base + Theme Tokens
   ========================= */
:root {
  --bg: #f7f7fb;
  --card: #fff;
  --ink: #111;
  --muted: #6b7280;
  --brand: #111;
  --ring: #e5e7eb;
  --logo-size: 48px; /* adjust logo size globally */
}

/* Motion preference */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
}

/* =========================
   Header + Navigation
   ========================= */
.site-header {
  position: sticky;
  top: 0;
  background: #ffffffcc;
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--ring);
  z-index: 100;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

/* Logo */
.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.brand img {
  height: var(--logo-size);
  width: auto;
  display: block;
  border-radius: 6px;
}

/* Nav menu */
.main-nav { position: relative; }

.main-nav .menu {
  display: flex;
  gap: 1rem;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}
.main-nav .menu > li { position: relative; }

.main-nav a {
  display: inline-block;
  padding: .6rem .8rem;
  text-decoration: none;
  color: var(--ink);
  border-radius: 10px;
  transition: background .2s;
}
.main-nav a:hover { background: #efefef; }

/* Caret for dropdown */
.main-nav .has-sub > a { padding-right: 1.6rem; }
.main-nav .caret {
  display: inline-block;
  margin-left: .25rem;
  border: .3rem solid transparent;
  border-top-color: currentColor;
  transform: translateY(.15rem);
}

/* Submenus */
.main-nav .submenu {
  position: absolute;
  left: 0;
  top: calc(100% + .25rem);
  min-width: 12rem;
  list-style: none;
  margin: 0;
  padding: .4rem 0;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: .5rem;
  box-shadow: 0 8px 20px rgba(0,0,0,.08);
  display: none;
  z-index: 1000;
}
.main-nav .submenu li a {
  display: block;
  padding: .5rem .9rem;
  white-space: nowrap;
}
.main-nav .submenu li a:hover { background: #f6f6f6; }
.main-nav .has-sub:hover > .submenu,
.main-nav .has-sub:focus-within > .submenu { display: block; }

/* Burger menu (mobile) */
.nav-toggle { display: none; }

.nav-burger {
  display: none;
  width: 2rem;
  height: 2rem;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  cursor: pointer;
}
.nav-burger span,
.nav-burger span::before,
.nav-burger span::after {
  content: "";
  display: block;
  height: 2px;
  width: 22px;
  background: currentColor;
  position: relative;
}
.nav-burger span::before { position: absolute; top: -6px; }
.nav-burger span::after  { position: absolute; top:  6px; }

/* Mobile nav */
@media (max-width: 820px) {
  .nav-burger { display: flex; }

  .main-nav .menu {
    display: none;
    position: absolute;
    right: 0;
    left: 0;
    top: 100%;
    flex-direction: column;
    background: #fff;
    border-top: 1px solid #eee;
    padding: .5rem 0;
  }

  .nav-toggle:checked ~ .menu { display: flex; }

  .main-nav .menu > li > a {
    width: 100%;
    padding: .8rem 1rem;
  }

  .main-nav .submenu {
    position: static;
    display: none;
    box-shadow: none;
    border: 0;
    padding: 0 0 .5rem 0;
    margin-left: .5rem;
  }

  .main-nav .has-sub:hover > .submenu,
  .main-nav .has-sub:focus-within > .submenu { display: block; }
}

/* =========================
   Login / Logout Button
   ========================= */
.login-link {
  background: var(--brand);
  color: #fff !important;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: background .2s, transform .15s;
}
.login-link:hover { background: #333; transform: translateY(-1px); }
.login-link i { font-size: 1rem; color: #fff; }

/* State overrides */
.login-link.logged-out i { color: #ccc; }
.login-link.logged-in  i { color: #4ade80; }

/* =========================
   Buttons
   ========================= */
button,
.btn {
  display: inline-block;
  background: #111;
  color: #fff;
  border: 0;
  padding: 10px 14px;
  min-width: 80px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.btn-secondary { background: #444; color: #fff; }
.btn-green     { background: #c8e6c9; color: #111; }
.btn-red       { background: #ffcdd2; color: #111; }
.btn-muted     { background: #e0e0e0; color: #111; }

/* =========================
   Cards + Grids
   ========================= */
.card {
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
  margin-bottom: 12px;
}

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

/* =========================
   Stats
   ========================= */
.stat {
  background: #111;
  color: #fff;
  border-radius: 16px;
  padding: 16px;
}
.stat .value { font-size: 28px; font-weight: 700; }
.stat .label { font-size: 12px; opacity: .9; }
.stat--blue  { background: #0f3d91; }
.stat--green { background: #0f6d2f; }
.stat--red   { background: #8b1e1e; }
.stat--brown { background: #7b4a12; }

/* =========================
   Forms
   ========================= */
label {
  display: block;
  font-size: 14px;
  color: #333;
  margin: 8px 0;
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ring);
  border-radius: 10px;
  font: inherit;
}
textarea { min-height: 120px; }

.notice { padding: 10px 12px; border-radius: 10px; }
.notice.success { background: #e8fff0; border: 1px solid #b6f3cc; }

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

/* =========================
   Footer
   ========================= */
.site-footer {
  color: var(--muted);
  border-top: 1px solid var(--ring);
  margin-top: 24px;
  padding: 12px 0 24px;
}

/* =========================
   Home Page
   ========================= */
.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: center;
}
.hero h1 {
  margin: 0 0 .25rem;
  font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.2rem);
}
.hero .lead { color: var(--muted); margin: 0 0 .5rem; }
.hero .actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .25rem; }
.hero-logo {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Feature boxes */
.grid4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 1rem;
  gap: 12px;
}
.feature { text-align: center; }
.feature h3 {
  margin-top: 0;
  margin-bottom: .5rem;
  font-size: 1.2rem;
}

/* Responsive adjustments */
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero-logo { max-width: 180px; }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grid4 { grid-template-columns: 1fr; }
}

/* =========================
   Tables
   ========================= */
.clean-table {
  width: 100%;
  border-collapse: collapse;
}
.clean-table th,
.clean-table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}
.clean-table th { font-weight: 700; }

/* =========================
   Admin Tables (refined)
   ========================= */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee; /* only row separators */
}

.admin-table th {
  background: #fafafa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Actions row */
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Buttons unified size */
.admin-table .btn {
  padding: 6px 12px;
  min-width: 100px;   /* ✅ all buttons same width */
  text-align: center;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Softer color tones */
.admin-table .btn-green {
  background: #e3f6e3;
  color: #0f5132;
}

.admin-table .btn-red {
  background: #fde2e2;
  color: #842029;
}

.admin-table .btn-secondary {
  background: #f0f0f0;
  color: #333;
}

/* Hover states */
.admin-table .btn-green:hover {
  background: #d4f0d4;
}
.admin-table .btn-red:hover {
  background: #f8d0d0;
}
.admin-table .btn-secondary:hover {
  background: #e0e0e0;
}


/* =========================
   Utilities
   ========================= */
.scroll-box {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #eee;
  border-radius: 6px;
}

/* =========================
   Tabs
   ========================= */
.tabs { margin: 15px 0; }
.tab-link {
  background: #f0f0f0;
  border: none;
  padding: 8px 14px;
  margin-right: 5px;
  cursor: pointer;
  border-radius: 6px;
}
.tab-link.active { background: #ddd; }

/* =========================
   Modal
   ========================= */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.4);
}
.modal.hidden { display: none; }
.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  width: 300px;
}
.modal-content label { display: block; margin: 10px 0; }
.modal-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
}

/* =========================
   Misc
   ========================= */
.search-box {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
}
