/* ---------- Base ---------- */
:root{
    --bg:#0b0f14;
    --panel:#111824;
    --panel2:#0f1620;
    --border:#223046;
    --text:#e8eef6;
    --muted:#9bb0c8;
    --accent:#4da3ff;
    --danger:#ff5c72;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
    --radius:14px;
  }
  
  *{ box-sizing:border-box; }
  html, body{ height:100%; }
  body{
    margin:0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
    background: radial-gradient(1200px 600px at 20% 0%, rgba(77,163,255,.10), transparent 50%),
                radial-gradient(900px 500px at 80% 20%, rgba(255,92,114,.08), transparent 60%),
                var(--bg);
    color:var(--text);
  }
  
  a{ color:var(--accent); text-decoration:none; }
  a:hover{ text-decoration:underline; }
  
  h1,h2,h3{ margin:0 0 10px 0; }
  p{ margin:0 0 10px 0; }
  
  /* ---------- Sticky header/navigation safety ---------- */
  header,
  .topnav,
  .tabs,
  .tabbar,
  .sticky-nav{
    position: sticky;
    top: 0;
    z-index: 950;
    background: rgba(11,15,20,.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(34,48,70,.65);
  }
  
  /* ---------- Top nav link styling (FIX) ---------- */
  header nav,
  .topnav,
  .tabs,
  .tabbar,
  .sticky-nav,
  .nav-links{
    display:flex;
    align-items:center;
    gap:10px;
    padding: 10px 12px;
  }
  
  /* Style links/buttons inside the top nav */
  header nav a,
  .topnav a,
  .tabs a,
  .tabbar a,
  .sticky-nav a,
  .nav-links a{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding: 8px 10px;
    border-radius: 12px;
    color: var(--muted);
    border: 1px solid transparent;
    text-decoration:none;
    font-weight:800;
    letter-spacing:.1px;
    line-height:1;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
  }
  
  header nav a:hover,
  .topnav a:hover,
  .tabs a:hover,
  .tabbar a:hover,
  .sticky-nav a:hover,
  .nav-links a:hover{
    background: rgba(255,255,255,.04);
    border-color: rgba(34,48,70,.75);
    color: var(--text);
    text-decoration:none;
  }
  
  /* Active state */
  header nav a.active,
  .topnav a.active,
  .tabs a.active,
  .tabbar a.active,
  .sticky-nav a.active,
  .nav-links a.active,
  header nav a[aria-current="page"],
  .topnav a[aria-current="page"],
  .tabs a[aria-current="page"],
  .tabbar a[aria-current="page"],
  .sticky-nav a[aria-current="page"],
  .nav-links a[aria-current="page"]{
    background: rgba(77,163,255,.14);
    border-color: rgba(77,163,255,.35);
    color: var(--text);
  }
  
  /* Optional: if your top nav has buttons, keep consistent */
  header nav button,
  .topnav button,
  .tabs button,
  .tabbar button,
  .sticky-nav button{
    border-radius: 12px;
  }
  
  /* ---------- Helpers ---------- */
  .muted{ color:var(--muted); }
  .pill{
    display:inline-block;
    font-size:12px;
    padding:2px 8px;
    border:1px solid var(--border);
    border-radius:999px;
    color:var(--muted);
    margin-left:8px;
  }
  .danger-text{ color:var(--danger); }
  
  /* ---------- Layout ---------- */
  .page{
    min-height:100vh;
    display:flex;
  }
  
  .sidebar{
    width:260px;
    flex:0 0 260px;
    border-right:1px solid var(--border);
    background: linear-gradient(180deg, rgba(17,24,36,.95), rgba(15,22,32,.90));
    position:sticky;
    top:0;
    height:100vh;
    padding:16px;
    z-index: 900;
  }
  
  .sidebar .brand{
    font-weight:800;
    letter-spacing:.2px;
    margin-bottom:12px;
  }
  
  .sidebar .nav{
    display:flex;
    flex-direction:column;
    gap:8px;
    margin-top:10px;
  }
  
  .sidebar .nav .btn{
    width:100%;
    justify-content:flex-start;
  }
  
  .sidebar .divider{
    height:1px;
    background:var(--border);
    margin:14px 0;
    opacity:.9;
  }
  
  .content{
    flex:1;
    padding:18px;
    max-width:1200px;
    width:100%;
  }
  
  .header-bar{
    display:flex;
    justify-content:space-between;
    align-items:flex-end;
    gap:12px;
    margin-bottom:14px;
  }
  
  .header-bar .titleblock h1{ margin:0; }
  .header-bar .titleblock .muted{ margin-top:4px; }
  
  /* ---------- Cards / Blocks ---------- */
  .card{
    background: linear-gradient(180deg, rgba(17,24,36,.95), rgba(13,19,28,.95));
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:14px;
    box-shadow: var(--shadow);
  }
  
  .stack{ display:flex; flex-direction:column; gap:12px; }
  
  .row{ display:flex; }
  .wrap{ flex-wrap:wrap; }
  .gap{ gap:10px; }
  
  .two-col{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:12px;
  }
  
  @media (max-width: 900px){
    .sidebar{ width:220px; flex-basis:220px; }
  }
  @media (max-width: 780px){
    .page{ flex-direction:column; }
    .sidebar{
      width:100%;
      height:auto;
      position:relative;
      border-right:none;
      border-bottom:1px solid var(--border);
    }
    .content{ padding:14px; }
    .two-col{ grid-template-columns: 1fr; }
  }
  
  /* ---------- Forms ---------- */
  label{ display:flex; flex-direction:column; gap:6px; font-size:13px; color:var(--muted); }
  input, select, textarea{
    background: rgba(8,12,18,.8);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 10px;
    outline:none;
  }
  input:focus, select:focus, textarea:focus{
    border-color: rgba(77,163,255,.9);
    box-shadow: 0 0 0 3px rgba(77,163,255,.20);
  }
  textarea{ min-height:90px; resize:vertical; }
  
  /* ---------- Buttons ---------- */
  button, .button, .btn{
    appearance:none;
    border:none;
    background: rgba(77,163,255,.15);
    color: var(--text);
    border:1px solid rgba(77,163,255,.35);
    border-radius: 12px;
    padding: 10px 12px;
    cursor:pointer;
    font-weight:700;
    display:inline-flex;
    gap:8px;
    align-items:center;
    justify-content:center;
  }
  button:hover, .button:hover, .btn:hover{ background: rgba(77,163,255,.22); }
  button:disabled{ opacity:.55; cursor:not-allowed; }
  
  .danger{
    background: rgba(255,92,114,.13);
    border-color: rgba(255,92,114,.35);
  }
  .danger:hover{ background: rgba(255,92,114,.18); }
  
  .ghost{
    background: transparent;
    border-color: var(--border);
  }
  .ghost:hover{ background: rgba(255,255,255,.04); }
  
  /* ---------- Lists ---------- */
  ul.list{
    list-style:none;
    padding:0;
    margin:0;
    display:flex;
    flex-direction:column;
    gap:10px;
  }
  ul.list > li{
    background: rgba(8,12,18,.55);
    border:1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
  }
  
  .meta-row{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    align-items:center;
    margin-top:8px;
  }
  
  /* ---------- Unit Groups ---------- */
  .unit-group{
    margin-top: 12px;
  }
  .unit-group:first-child{
    margin-top: 0;
  }
  .unit-group-title{
    display:flex;
    align-items:baseline;
    justify-content:space-between;
    gap:10px;
    padding: 8px 2px;
    border-bottom: 1px solid rgba(34,48,70,.65);
    margin-bottom: 10px;
  }
  .unit-group-title h3{
    margin: 0;
    font-size: 14px;
    letter-spacing:.2px;
  }
  .unit-group-title .count{
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }
  
/* ================================
   Builder Drawer / Sidebar
================================ */

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 999;
  }
  
  .drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  
  .drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 95%;
    height: 100vh;
    background: #0f1620;
    border-left: 1px solid #223046;
    box-shadow: -8px 0 24px rgba(0,0,0,0.4);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
  }
  
  .drawer.open {
    transform: translateX(0);
  }
  
  .drawer-header {
    padding: 16px;
    border-bottom: 1px solid #223046;
  }
  
  .drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
  }
  
  .drawer-footer {
    padding: 16px;
    border-top: 1px solid #223046;
  }
  
  body.drawer-open {
    overflow: hidden;
  }
  

  /* Sticky top navigation (builder too) */
.topnav, header.topnav, .top-nav, .nav {
    position: sticky;
    top: 0;
    z-index: 1200;
  }
  
  /* Builder selections: 2-up layout */
  #army-list ul.builder-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-left: 0;
    list-style: none;
  }
  
  #army-list ul.builder-grid > li {
    margin: 0;
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
  }
  

  
  /* Mobile: 1-up */
  @media (max-width: 820px) {
    #army-list ul.builder-grid {
      grid-template-columns: 1fr;
    }
  }
  


  /* ---------- Grids ---------- */
  .unit-grid{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:12px;
  }
  @media (max-width: 780px){
    .unit-grid{ grid-template-columns: 1fr; }
  }
  
  /* ---------- Modal ---------- */
  body.modal-open{ overflow: hidden; }
  
  .modal-backdrop{
    position:fixed;
    inset:0;
    background: rgba(0,0,0,.60);
    display:none;
    align-items:center;
    justify-content:center;
    padding:18px;
    z-index:1000;
  }
  .modal-backdrop.open{ display:flex; }
  
  .modal{
    width:min(860px, 100%);
    max-height: 90vh;
    display:flex;
    flex-direction:column;
    background: linear-gradient(180deg, rgba(17,24,36,.98), rgba(13,19,28,.98));
    border:1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow:hidden;
  }
  
  .modal .modal-header{
    padding:14px 14px 10px 14px;
    border-bottom:1px solid var(--border);
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
    flex:0 0 auto;
  }
  
  .modal .modal-body{
    padding:14px;
    overflow:auto;
    flex: 1 1 auto;
  }
  
  .modal .modal-footer{
    padding:14px;
    border-top:1px solid var(--border);
    display:flex;
    gap:10px;
    justify-content:flex-end;
    flex-wrap:wrap;
    flex:0 0 auto;
  }
  
  /* ---------- Print ---------- */
  .print-only{ display:none; }
  
  @media print{
    body{ background:white !important; color:#000 !important; }
    .page, .sidebar, .no-print, .modal-backdrop{ display:none !important; }
    .print-only{ display:block !important; }
    .print-title{ font-size:20px; font-weight:900; margin-bottom:4px; color:#000; }
    .print-sub{ font-size:12px; margin-bottom:6px; color:#000; }
    .print-meta{ font-size:11px; margin-bottom:10px; color:#000; }
  
    table.print-table{
      width:100%;
      border-collapse:collapse;
      font-size:11px;
    }
    table.print-table th, table.print-table td{
      border:1px solid #333;
      padding:6px;
      vertical-align:top;
    }
    table.print-table tr, .print-unit, .print-table{
      break-inside: avoid;
      page-break-inside: avoid;
    }
    h2{ break-after: avoid; page-break-after: avoid; }
  }
  