:root{
  --navy:#0a1a33;
  --navy-2:#122A52;
  --orange:#f5a623;
  --orange-2:#ff8a00;
  --gold:#ffcf6b;
  --ink:#1c2433;
  --slate:#5c6779;
  --bg:#f4f6f9;
  --line:#e7ebf1;
  --green:#1a7f42;
  --red:#b3271e;
  --blue:#1d63c9;
}
*{margin:0;padding:0;box-sizing:border-box;}
body{
  font-family:'Poppins',sans-serif;
  background:var(--bg);
  color:var(--ink);
  font-size:14px;
}
a{text-decoration:none;color:inherit;}

/* Hide the native scrollbar track/thumb across browsers, same as the
   public site. Scrolling itself (touch, wheel, keyboard) still works
   exactly the same — only the visible bar is removed. */
html{
  scrollbar-width:none;       /* Firefox */
  -ms-overflow-style:none;    /* old Edge / IE */
}
html::-webkit-scrollbar{      /* Chrome, Safari, Android Chrome, new Edge */
  display:none;
  width:0;
  height:0;
}

/* ---------- Login ---------- */
.login-wrap{
  min-height:100vh;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(ellipse 900px 500px at 85% -10%, rgba(245,166,35,0.18), transparent 60%), linear-gradient(160deg,#0a1a33 0%, #0d2044 55%, #071122 100%);
  padding:20px;
}
.login-card{
  background:#fff;border-radius:18px;padding:44px 40px;width:100%;max-width:400px;
  box-shadow:0 30px 70px rgba(0,0,0,0.35);
}
.login-card img{width:56px;height:56px;border-radius:12px;margin-bottom:18px;}
.login-card h1{font-size:20px;color:var(--navy);margin-bottom:6px;}
.login-card .sub{font-size:12px;color:var(--slate);margin-bottom:26px;}
.login-card label{display:block;font-size:11.5px;font-weight:600;color:var(--navy);margin-bottom:6px;}
.login-card input{
  width:100%;border:1px solid var(--line);border-radius:9px;padding:12px 14px;
  font-family:'Poppins',sans-serif;font-size:13px;margin-bottom:16px;background:var(--bg);
}
.login-card input:focus{outline:2px solid var(--orange-2);outline-offset:1px;background:#fff;}
.login-card button{
  width:100%;background:linear-gradient(135deg,var(--orange-2),var(--gold));
  color:#0a1a33;font-weight:700;font-size:13.5px;border:none;border-radius:10px;padding:14px;cursor:pointer;
}
.login-error{background:#fdecec;color:var(--red);border:1px solid #f5c2bf;padding:11px 14px;border-radius:8px;font-size:12px;margin-bottom:16px;}
.login-hint{margin-top:18px;font-size:10.5px;color:var(--slate);text-align:center;}

@media(max-width:480px){
  .login-card{padding:32px 24px;border-radius:14px;}
}

/* ---------- Shell layout ---------- */
.admin-shell{display:flex;min-height:100vh;}
.admin-sidebar{
  width:230px;background:var(--navy);color:#fff;padding:26px 18px;
  display:flex;flex-direction:column;position:sticky;top:0;height:100vh;
}
.admin-brand{display:flex;align-items:center;gap:10px;margin-bottom:34px;padding:0 8px;}
.admin-brand img{width:34px;height:34px;border-radius:8px;}
.admin-brand .t{font-size:14px;font-weight:800;letter-spacing:0.5px;}
.admin-brand .t span{color:var(--orange);}
.admin-nav a{
  display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:10px;
  font-size:13px;color:#c3ccdc;font-weight:500;margin-bottom:4px;
}
.admin-nav a:hover{background:rgba(255,255,255,0.06);color:#fff;}
.admin-nav a.active{background:linear-gradient(135deg,var(--orange-2),var(--gold));color:#0a1a33;font-weight:700;}
.admin-nav .ic{width:18px;text-align:center;}
.admin-sidebar-foot{margin-top:auto;padding-top:20px;border-top:1px solid rgba(255,255,255,0.1);}
.admin-sidebar-foot a{font-size:12px;color:#9fb0c9;}
.admin-sidebar-foot a:hover{color:#fff;}

.admin-main{flex:1;min-width:0;}
.admin-topbar{
  background:#fff;border-bottom:1px solid var(--line);padding:20px 34px;
  display:flex;align-items:center;justify-content:space-between;
}
.admin-topbar h1{font-size:19px;color:var(--navy);}
.admin-topbar .who{font-size:12px;color:var(--slate);}
.admin-content{padding:30px 34px;}

/* On tablets, the fixed 230px sidebar starts eating too much of the
   viewport relative to content — narrow it a bit rather than reflowing
   the whole layout yet. */
@media(max-width:1024px){
  .admin-sidebar{width:190px;padding:22px 14px;}
  .admin-content{padding:24px 22px;}
  .admin-topbar{padding:18px 22px;}
}

/* On phones, a fixed-width sticky sidebar leaves almost no room for
   content. Convert the shell to stack vertically: the sidebar becomes a
   normal (non-sticky) horizontal bar at the top with a scrollable row of
   nav links, and the page content flows below it at full width. This is
   CSS-only (no JS toggle) since it doesn't rely on admin-header.php's
   markup — just reflows what's already there. */
@media(max-width:860px){
  .admin-shell{flex-direction:column;}
  .admin-sidebar{
    width:100%;
    height:auto;
    position:static;
    padding:16px 14px;
    flex-direction:row;
    align-items:center;
    flex-wrap:wrap;
    gap:10px;
  }
  .admin-brand{margin-bottom:0;padding:0;flex:1 1 100%;}
  .admin-nav{
    display:flex;
    flex-wrap:nowrap;
    overflow-x:auto;
    gap:6px;
    width:100%;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    -ms-overflow-style:none;
  }
  .admin-nav::-webkit-scrollbar{
    display:none;
    width:0;
    height:0;
  }
  .admin-nav a{
    margin-bottom:0;
    white-space:nowrap;
    padding:9px 12px;
    font-size:12.5px;
  }
  .admin-sidebar-foot{
    margin-top:0;
    padding-top:10px;
    border-top:none;
    flex:1 1 100%;
  }
  .admin-topbar{padding:16px 18px;flex-wrap:wrap;gap:6px;}
  .admin-topbar h1{font-size:17px;}
  .admin-content{padding:18px 16px;}
}

/* ---------- Stat cards ---------- */
.stat-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:18px;margin-bottom:30px;}
.stat-card{background:#fff;border:1px solid var(--line);border-radius:14px;padding:22px;}
.stat-card .lbl{font-size:11px;letter-spacing:1px;text-transform:uppercase;color:var(--slate);margin-bottom:10px;}
.stat-card .val{font-size:30px;font-weight:800;color:var(--navy);}
.stat-card .val.orange{color:var(--orange-2);}
@media(max-width:1100px){.stat-grid{grid-template-columns:1fr 1fr;}}
@media(max-width:480px){
  .stat-grid{grid-template-columns:1fr;gap:12px;}
  .stat-card{padding:18px;}
  .stat-card .val{font-size:26px;}
}

/* ---------- Panels / tables ---------- */
.panel{background:#fff;border:1px solid var(--line);border-radius:14px;overflow:hidden;margin-bottom:26px;}
.panel-head{padding:18px 22px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;}
.panel-head h3{font-size:15px;color:var(--navy);}
.panel-head .muted{font-size:11.5px;color:var(--slate);}
@media(max-width:480px){
  .panel-head{flex-direction:column;align-items:flex-start;gap:6px;}
  .panel{border-radius:12px;}
}

table.leads-table{width:100%;border-collapse:collapse;}
table.leads-table th{
  text-align:left;font-size:10.5px;letter-spacing:0.5px;text-transform:uppercase;
  color:var(--slate);padding:12px 22px;background:var(--bg);border-bottom:1px solid var(--line);
}
table.leads-table td{padding:14px 22px;border-bottom:1px solid var(--line);font-size:12.5px;vertical-align:middle;}
table.leads-table tr:last-child td{border-bottom:none;}
table.leads-table tr:hover{background:#fbfbfd;}
.lead-name{font-weight:600;color:var(--navy);}
.lead-sub{font-size:11px;color:var(--slate);}

/* Below 700px, a 6-column table is unreadable no matter what — convert
   each row into a stacked card instead of a horizontally scrolling table.
   Requires each <td> to carry a data-label="..." attribute (see dashboard.php
   and leads.php) which the ::before rule below turns into a mini heading. */
@media(max-width:700px){
  table.leads-table, table.leads-table thead, table.leads-table tbody,
  table.leads-table th, table.leads-table td, table.leads-table tr{
    display:block;
    width:100%;
  }
  table.leads-table thead{
    position:absolute;
    width:1px;height:1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
    white-space:nowrap;
  }
  table.leads-table tr{
    margin:12px;
    border:1px solid var(--line);
    border-radius:10px;
    padding:6px 14px;
    background:#fff;
  }
  table.leads-table td{
    border:none;
    padding:8px 0;
    text-align:left;
    position:relative;
  }
  table.leads-table td[data-label]:not([data-label=""])::before{
    content:attr(data-label);
    display:block;
    font-size:10.5px;
    font-weight:700;
    letter-spacing:0.5px;
    text-transform:uppercase;
    color:var(--slate);
    margin-bottom:2px;
  }
  table.leads-table .btn-view{
    display:block;
    width:100%;
    text-align:center;
  }
}

.badge{display:inline-block;padding:5px 12px;border-radius:20px;font-size:10.5px;font-weight:700;letter-spacing:0.3px;}
.badge.new{background:#e8f0fe;color:var(--blue);}
.badge.contacted{background:#fff3e0;color:#b06a00;}
.badge.in_progress{background:#fdf1e8;color:var(--orange-2);}
.badge.closed{background:#e8f7ee;color:var(--green);}

.btn{display:inline-flex;align-items:center;gap:6px;padding:9px 16px;border-radius:8px;font-size:12px;font-weight:600;border:none;cursor:pointer;}
.btn-view{background:var(--navy);color:#fff;}
.btn-view:hover{background:var(--navy-2);}
.btn-danger{background:#fdecec;color:var(--red);}
.btn-danger:hover{background:#fadada;}
.btn-save{background:linear-gradient(135deg,var(--orange-2),var(--gold));color:#0a1a33;}

.filters{display:flex;gap:10px;padding:16px 22px;border-bottom:1px solid var(--line);flex-wrap:wrap;background:var(--bg);}
.filters input, .filters select{
  border:1px solid var(--line);border-radius:8px;padding:9px 12px;font-family:'Poppins',sans-serif;font-size:12.5px;background:#fff;
}
.filters input[type=text]{flex:1;min-width:180px;}
@media(max-width:480px){
  .filters{padding:14px 16px;}
  .filters input[type=text]{min-width:0;flex-basis:100%;}
}

.empty-state{padding:50px 22px;text-align:center;color:var(--slate);font-size:13px;}

/* ---------- Lead detail ---------- */
.detail-grid{display:grid;grid-template-columns:1.3fr 1fr;gap:22px;align-items:start;}
.detail-card{background:#fff;border:1px solid var(--line);border-radius:14px;padding:26px;}
.detail-row{display:flex;justify-content:space-between;padding:12px 0;border-bottom:1px solid var(--line);font-size:12.5px;}
.detail-row:last-child{border-bottom:none;}
.detail-row .k{color:var(--slate);}
.detail-row .v{color:var(--navy);font-weight:600;text-align:right;max-width:60%;}
.detail-msg{background:var(--bg);border-radius:10px;padding:16px;font-size:12.5px;color:var(--ink);line-height:1.7;margin-top:10px;}

@media(max-width:860px){
  .detail-grid{grid-template-columns:1fr;}
  .detail-card{padding:20px;}
}

.form-group{margin-bottom:16px;}
.form-group label{display:block;font-size:11.5px;font-weight:600;color:var(--navy);margin-bottom:6px;}
.form-group select, .form-group textarea{
  width:100%;border:1px solid var(--line);border-radius:9px;padding:10px 12px;
  font-family:'Poppins',sans-serif;font-size:12.5px;background:var(--bg);
}
.form-group textarea{min-height:100px;resize:vertical;}

.toast{padding:12px 16px;border-radius:9px;font-size:12.5px;margin-bottom:18px;}
.toast.success{background:#e8f7ee;color:var(--green);border:1px solid #b9e6c7;}
.toast.error{background:#fdecec;color:var(--red);border:1px solid #f5c2bf;}

.back-link{font-size:12px;color:var(--slate);margin-bottom:16px;display:inline-flex;align-items:center;gap:6px;}
.back-link:hover{color:var(--navy);}