/* app/ui.css (LIGHT) — MOBILE APP FEEL FINAL ✅ */
:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --card2:#fbfbff;
  --text:#0f172a;
  --muted:#64748b;
  --brand:#22c55e;
  --brand2:#16a34a;
  --danger:#ef4444;
  --line:rgba(2,6,23,.10);
  --shadow:0 12px 30px rgba(2,6,23,.08);

  /* ✅ mobile spacing */
  --radius:18px;
  --radius2: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;
  background:
    radial-gradient(1000px 600px at 10% 0%, rgba(34,197,94,.18), transparent 60%),
    radial-gradient(900px 500px at 90% 20%, rgba(59,130,246,.14), transparent 55%),
    var(--bg);
  color:var(--text);
  overflow-x:hidden; /* ✅ no horizontal scroll */
}
a{color:inherit;text-decoration:none}
button{font-family:inherit}
img{max-width:100%;height:auto}
input,textarea,select{font-family:inherit}

/* ================== LAYOUT ================== */
.shell{display:grid;grid-template-columns:280px 1fr;min-height:100vh}

/* Sidebar */
.sidebar{
  position:sticky;top:0;height:100vh;padding:18px;
  border-right:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,.35));
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;align-items:center;gap:10px;
  padding:12px;border:1px solid var(--line);border-radius:16px;
  background:rgba(255,255,255,.85);box-shadow:var(--shadow);
}
.brand .logo{
  width:40px;height:40px;border-radius:12px;display:grid;place-items:center;
  background:rgba(34,197,94,.12);
  border:1px solid rgba(34,197,94,.30);
  font-weight:900;
}
.brand .title{font-weight:900}
.brand .sub{color:var(--muted);font-size:12px;margin-top:2px}

.nav{margin-top:14px;display:flex;flex-direction:column;gap:8px}
.nav a{
  display:flex;align-items:center;gap:10px;padding:12px;border-radius:14px;
  border:1px solid transparent;background:rgba(255,255,255,.70);
}
.nav a:hover{border-color:var(--line);background:rgba(255,255,255,.95)}
.nav a.active{
  border-color:rgba(34,197,94,.35);
  background:rgba(34,197,94,.10);
}
.nav .icon{
  width:34px;height:34px;border-radius:12px;display:grid;place-items:center;
  border:1px solid var(--line);background:rgba(2,6,23,.04);
}

.profileBox{
  margin-top:18px;padding:12px;border-radius:16px;
  border:1px solid var(--line);background:rgba(255,255,255,.85);
  box-shadow:var(--shadow);
}
.profileBox .name{font-weight:800}
.profileBox .role{color:var(--muted);font-size:12px}
.profileBox .btnRow{display:flex;gap:10px;margin-top:10px}

/* Main */
.main{
  padding:20px 20px 90px;
  min-width:0; /* ✅ grid overflow fix */
}

/* ================== BUTTONS ================== */
.btn{
  border:1px solid var(--line);
  cursor:pointer;padding:10px 12px;border-radius:12px;
  background:rgba(2,6,23,.03);color:var(--text);
  transition:transform .05s ease, background .15s ease;
}
.btn:active{transform:scale(.99)}
.btn:hover{background:rgba(2,6,23,.06)}
.btn.primary{
  background:linear-gradient(135deg,var(--brand),var(--brand2));
  border-color:rgba(34,197,94,.35);
  color:#05230f;font-weight:900;
}
.btn.danger{
  background:rgba(239,68,68,.10);
  border-color:rgba(239,68,68,.25);
  color:#7f1d1d;font-weight:800;
}

/* ================== TOPBAR (APP FEEL) ================== */
.topbar{
  display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
  padding:14px;border-radius:18px;border:1px solid var(--line);
  background:rgba(255,255,255,.88);box-shadow:var(--shadow);
}
.topbar .h{font-size:18px;font-weight:900}
.topbar .p{color:var(--muted);font-size:12px;margin-top:2px}
.topbar .right{
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;
  justify-content:flex-end;
}

.pill{
  padding:8px 10px;border-radius:999px;border:1px solid var(--line);
  background:rgba(2,6,23,.03);color:var(--muted);font-size:12px;
  white-space:nowrap;
}

/* ================== CARDS / GRID ================== */
.grid{margin-top:16px;display:grid;grid-template-columns:repeat(12,1fr);gap:14px}
.card{
  border:1px solid var(--line);
  background:rgba(255,255,255,.88);
  border-radius:18px;padding:14px;box-shadow:var(--shadow);
  min-width:0;
}
.card h3{margin:0 0 6px;font-size:14px}
.card .muted{color:var(--muted);font-size:12px}
.kpi{display:flex;flex-direction:column;gap:8px}
.kpi .val{font-size:22px;font-weight:900}
.kpi .tag{
  display:inline-flex;padding:6px 10px;border-radius:999px;border:1px solid var(--line);
  background:rgba(2,6,23,.03);color:var(--muted);font-size:12px;
}

/* ================== TABLES ================== */
.tableWrap{
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  border:1px solid var(--line);
  border-radius:16px;
  background:rgba(255,255,255,.6);
}
table{width:100%;border-collapse:collapse;min-width:760px;background:transparent}
th,td{padding:12px;border-bottom:1px solid var(--line);text-align:left;font-size:13px;vertical-align:top}
th{color:var(--muted);font-weight:800}
tr:hover td{background:rgba(2,6,23,.02)}

.badge{
  display:inline-flex;padding:6px 10px;border-radius:999px;font-size:12px;
  border:1px solid var(--line);background:rgba(2,6,23,.03);
}
.badge.ok{border-color:rgba(34,197,94,.30);background:rgba(34,197,94,.10);color:#14532d}
.badge.warn{border-color:rgba(245,158,11,.30);background:rgba(245,158,11,.10);color:#7c2d12}
.badge.danger{border-color:rgba(239,68,68,.25);background:rgba(239,68,68,.10);color:#7f1d1d}

/* ================== FORMS ================== */
.form{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.field label{display:block;font-size:12px;color:var(--muted);margin:0 0 6px}
.field input,.field select,.field textarea{
  width:100%;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.92);
  color:var(--text);
  outline:none;
}
.field textarea{resize:vertical; min-height:96px}
.field input:focus,.field select:focus,.field textarea:focus{
  border-color:rgba(34,197,94,.45);
  box-shadow:0 0 0 3px rgba(34,197,94,.12);
}
.form .full{grid-column:1 / -1}
.err{color:#991b1b;font-size:12px;margin-top:8px}
.hr{height:1px;background:var(--line);margin:12px 0}

/* ✅ file input better */
input[type="file"]{
  padding:10px;
  background:#fff;
}

/* ================== MOBILE NAV ================== */
.mobileNav{
  display:none;position:fixed;left:0;right:0;bottom:0;
  padding:10px 10px 16px;background:rgba(246,247,251,.92);
  backdrop-filter: blur(10px);
  border-top:1px solid var(--line);
}
.mobileNav .row{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
.mItem{
  padding:10px;border-radius:14px;border:1px solid var(--line);
  background:rgba(255,255,255,.95);
  text-align:center;font-size:12px;color:var(--muted);
}
.mItem div{margin-top:2px;font-size:11px}
.mItem.active{color:var(--text);border-color:rgba(34,197,94,.35);background:rgba(34,197,94,.12)}

/* helpers */
.small{font-size:12px;color:var(--muted)}
.flex{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.rightAlign{text-align:right}
.copyBtn{padding:8px 10px;border-radius:12px;border:1px solid var(--line);background:rgba(2,6,23,.03);cursor:pointer}
.copyBtn:hover{background:rgba(2,6,23,.06)}
.searchRow{display:flex;gap:10px;flex-wrap:wrap}
.searchRow input{min-width:260px}

.treeCell{display:flex; align-items:center; gap:8px;}
.treeIndent{display:inline-block;width:var(--indent, 0px);flex:0 0 auto;}
.treeToggle{
  width:28px; height:28px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:10px;
  cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  font-weight:800;
}
.treeToggle.disabled{opacity:.35; cursor:default;}
.smallTag{font-size:12px;color:var(--muted);}

/* ==========================================================
   ✅ MOBILE "APP MODE"
========================================================== */
@media(max-width:980px){
  .shell{grid-template-columns:1fr}
  .sidebar{display:none}
  .mobileNav{display:block}

  /* main padding + app-like */
  .main{
    padding:12px 12px 110px;
    max-width:720px;
    margin:0 auto;
  }

  .topbar{
    position:sticky;
    top:10px;
    z-index:20;
    border-radius:18px;
  }

  /* topbar buttons become scroll row */
  .topbar .right{
    width:100%;
    justify-content:flex-start;
    overflow:auto;
    -webkit-overflow-scrolling:touch;
    padding-top:10px;
    gap:8px;
  }
  .topbar .right::-webkit-scrollbar{display:none}

  /* buttons smaller for mobile */
  .btn{padding:10px 11px;border-radius:14px;white-space:nowrap}

  /* forms single column */
  .form{grid-template-columns:1fr}

  /* KPI cards stack */
  .grid{gap:12px}
  .card{border-radius:18px}

  /* inputs full width always */
  .searchRow input, #q{
    width:100% !important;
    min-width:0 !important;
  }

  /* ✅ TABLE => better mobile: allow horizontal but not ugly */
  table{min-width:720px}

  /* on onboarding page: photo preview larger */
  #photoPreview{
    width:96px !important;
    height:96px !important;
    border-radius:16px !important;
  }
}

/* ==========================================================
   ✅ EXTRA SMALL PHONES
========================================================== */
@media(max-width:420px){
  .topbar .h{font-size:16px}
  .pill{font-size:11px;padding:7px 9px}
  .btn{padding:10px}
}
