:root {
  /* Brand palette */
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #3b82f6;
  --accent: #f97316;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --info: #0ea5e9;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow: 0 10px 25px -10px rgba(15, 23, 42, .25);
  --shadow-lg: 0 25px 50px -12px rgba(15, 23, 42, .25);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1140px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { line-height: 1.2; color: var(--ink); margin: 0 0 .6em; }
h1 { font-size: clamp(1.9rem, 4vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); letter-spacing: -.01em; }
p { color: var(--ink-soft); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 720px; }

/* ---------- Top navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 66px;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: 1.15rem; color: var(--ink); letter-spacing: -.02em;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  display: grid; place-items: center; color: #fff; font-size: 1rem;
  box-shadow: var(--shadow-sm);
}
.nav-links { display: flex; align-items: center; gap: .35rem; }
.nav-links a {
  padding: .5rem .85rem; border-radius: 8px; color: var(--ink-soft);
  font-weight: 500; font-size: .95rem; transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--surface-2); color: var(--ink); }
.nav-links a.active { color: var(--brand); background: #eff6ff; }
.nav-links .nav-link-disabled {
  padding: .5rem .85rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: not-allowed;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
}

.nav-toggle { display: none; background: none; border: 0; font-size: 1.5rem; color: var(--ink); cursor: pointer; }

@media (max-width: 820px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 66px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: .15rem;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: .75rem 20px 1rem; box-shadow: var(--shadow);
    display: none;
  }
  .nav-links.open { display: flex; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: .9rem; cursor: pointer; transition: all .18s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #ea580c; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-warning { background: #facc15; color: #422006; border-color: #eab308; }
.btn-warning:hover { background: #eab308; color: #422006; }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; border-radius: 6px; }
.btn-lg { padding: .7rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Cards & surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 1.6rem;
}
.card-pad-lg { padding: 2.2rem; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .4rem; color: var(--ink); }
.input, .select, .textarea {
  width: 100%; padding: .55rem .75rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: .92rem; color: var(--ink); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.textarea { resize: vertical; min-height: 120px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .35rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .92rem; }
table.data th { background: var(--surface-2); font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.is-current { background: var(--success-bg); }

/* ---------- Roster import preview ---------- */
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-heading h1 { margin: .25rem 0 .35rem; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; }
.stat-card span { display: block; color: var(--muted); font-size: .84rem; margin-bottom: .35rem; }
.stat-card strong { display: block; color: var(--ink); font-size: 1.55rem; line-height: 1; }
.pill-row { display: flex; flex-wrap: wrap; gap: .55rem; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); padding: .35rem .7rem; font-size: .84rem; color: var(--ink-soft); }
.actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.help-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; margin-left: .35rem; color: var(--brand); cursor: help; vertical-align: middle; }
.help-tip i { font-size: .95rem; }
.help-tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + .65rem); transform: translateX(-50%); width: min(360px, 78vw); padding: .85rem 1rem; border-radius: 10px; background: #0f172a; color: #fff; box-shadow: 0 18px 42px rgba(15, 23, 42, .22); font-size: .86rem; line-height: 1.45; font-weight: 500; text-transform: none; letter-spacing: 0; opacity: 0; visibility: hidden; pointer-events: none; z-index: 40; }
.help-tip::before { content: ''; position: absolute; left: 50%; bottom: calc(100% + .28rem); transform: translateX(-50%); border: .42rem solid transparent; border-top-color: #0f172a; opacity: 0; visibility: hidden; pointer-events: none; z-index: 41; }
.help-tip:hover::after, .help-tip:focus::after, .help-tip:hover::before, .help-tip:focus::before { opacity: 1; visibility: visible; }
.roster-positioning { display: grid; grid-template-columns: minmax(280px, .95fr) 1.45fr; gap: 1.25rem; align-items: stretch; }
.dashboard-command-panel { border-left: 4px solid var(--brand); }
.roster-positioning-copy h2 { margin: .2rem 0 .55rem; font-size: clamp(1.35rem, 2vw, 2rem); line-height: 1.15; max-width: 780px; }
.roster-positioning-copy p:last-child { margin-bottom: 0; max-width: 760px; }
.roster-value-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
.roster-value-item { display: grid; grid-template-columns: 2rem 1fr; column-gap: .75rem; row-gap: .2rem; align-content: start; padding: .85rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.roster-value-item i { grid-row: span 2; color: var(--brand); font-size: 1.15rem; margin-top: .15rem; }
.roster-value-item strong { color: var(--ink); font-size: .95rem; }
.roster-value-item span { color: var(--muted); font-size: .84rem; line-height: 1.4; }
.admin-status-card h3 { margin: .2rem 0 .35rem; font-size: 1.12rem; }
.admin-status-card p { margin: 0; }
.project-card-status { display: flex; flex-direction: column; gap: .35rem; margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); font-size: .86rem; }
.notice-card { border: 1px solid var(--line); border-radius: 10px; padding: .9rem; background: var(--surface-2); }
.news-target-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .45rem .75rem; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.news-target-list label { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
.news-template-list { display: grid; gap: .65rem; }
.news-template-list > div { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; background: var(--surface-2); }
.news-template-list strong { display: block; color: var(--ink); margin-bottom: .2rem; }
.news-template-list span { color: var(--muted); font-size: .9rem; }
@media (max-width: 980px) { .roster-positioning { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .roster-value-grid { grid-template-columns: 1fr; } }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-brand { background: #eff6ff; color: var(--brand); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

.alert { padding: .9rem 1.1rem; border-radius: 10px; margin-bottom: 1.1rem; font-size: .93rem; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.alert-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }

/* Toast notifications */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; animation: slideIn 0.3s ease; }
.toast { display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem 1.1rem; border-radius: 10px; font-size: 0.93rem; box-shadow: 0 10px 25px rgba(0,0,0,0.15); cursor: pointer; max-width: 400px; }
.toast-success { background: #166534; color: #fff; }
.toast-danger { background: #991b1b; color: #fff; }
.toast-info { background: #075985; color: #fff; }
.toast-warning { background: #92400e; color: #fff; }
.toast-close { background: none; border: none; color: inherit; opacity: 0.7; font-size: 1.25rem; cursor: pointer; padding: 0; margin-left: auto; }
.toast-close:hover { opacity: 1; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Utilities ---------- */
.section { padding: 3.5rem 0; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2.5rem; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 700; color: var(--brand); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: calc(100vh - 66px); display: grid; place-items: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 410px; }

/* ---------- Dashboard shell ---------- */
.dashboard-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 66px);
}

.dashboard-sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  position: sticky;
  top: 66px;
  height: calc(100vh - 66px);
  overflow-y: auto;
  padding: 1rem .9rem 1.2rem;
}

.dashboard-side-head {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: .85rem .9rem;
  margin-bottom: .9rem;
}

.dashboard-side-head h3 {
  margin: 0;
  font-size: .98rem;
}

.dashboard-side-head p {
  margin: .2rem 0 0;
  font-size: .82rem;
  color: var(--muted);
}

.dashboard-home-link {
  display: block;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.dashboard-home-link:hover {
  color: inherit;
  border-color: #bfdbfe;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.dashboard-main {
  padding: 0 1.2rem 1.2rem;
}

.dashboard-menu {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.dash-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.dash-group-btn {
  width: 100%;
  border: 0;
  background: #fff;
  padding: .78rem .85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 600;
}

.dash-group-btn.has-active {
  color: var(--brand);
  background: #eff6ff;
}

.dash-group-btn span {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
}

.dash-chevron {
  transition: transform .2s ease;
  font-size: .8rem;
}

.dash-group-btn[aria-expanded="true"] .dash-chevron {
  transform: rotate(180deg);
}

.dash-submenu {
  display: none;
  border-top: 1px solid var(--line);
  background: #fcfdff;
  padding: .3rem;
}

.dash-submenu.open {
  display: block;
}

.dash-sub-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: .9rem;
  color: var(--ink-soft);
  border-radius: 8px;
  padding: .58rem .62rem;
}

.dash-sub-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.dash-sub-link.active {
  background: #eff6ff;
  color: var(--brand);
  font-weight: 600;
}

.dash-sub-link.disabled {
  color: var(--muted);
  cursor: not-allowed;
  background: #f8fafc;
}

@media (max-width: 1024px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #cbd5e1; margin-top: 4rem; padding: 3rem 0 2rem; }
.site-footer a { color: #cbd5e1; }
.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-bottom { border-top: 1px solid #1e293b; margin-top: 2rem; padding-top: 1.5rem; font-size: .85rem; color: #94a3b8; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* ---------- Nav link button colour fix ---------- */
.nav-links .btn-primary { color: #fff; }
.nav-links .btn-primary:hover { background: var(--brand-dark); color: #fff; }

/* ---------- Mobile sidebar ---------- */
.sidebar-mobile-bar {
  display: none;
  padding: .55rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.sidebar-mobile-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .4rem .75rem;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--ink);
}
.sidebar-mobile-btn:hover { background: var(--surface-2); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 66px 0 0 0;
  background: rgba(0, 0, 0, .45);
  z-index: 39;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 1024px) {
  .sidebar-mobile-bar { display: flex; }

  .dashboard-sidebar {
    position: fixed;
    top: 66px;
    left: -300px;
    width: 280px;
    height: calc(100vh - 66px);
    z-index: 40;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    overflow-y: auto;
    transition: left .25s ease;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  }
  .dashboard-sidebar.sidebar-open { left: 0; }

  .dashboard-main { padding: 0 1rem 1rem; }
}

/* ---------- Mobile responsive enhancements ---------- */
@media (max-width: 768px) {
  .section { padding: 2rem 0; }
  .card { padding: 1.1rem; }
  .card-pad-lg { padding: 1.4rem; }
  .auth-card { max-width: 100%; }

  .toast-container { top: auto; bottom: 1rem; right: .75rem; left: .75rem; }
  .toast { max-width: 100%; }

  table.data th,
  table.data td { padding: .6rem .75rem; font-size: .85rem; }

  .btn-lg { padding: .65rem 1.1rem; font-size: .95rem; }

  .flex.justify-between { flex-wrap: wrap; gap: .6rem; }

  .footer-bottom { flex-direction: column; text-align: center; }
}
