/* =========================
   PoultryERP — app.css (clean)
   ========================= */

/* ---------- Design tokens ---------- */
:root{
  /* Base (dark) */
  --bg:#0f1419;
  --panel:#141b24;
  --text:#e9f0f6;
  --muted:#90a0b0;
  --line:#1f2a37;

  --accent:#10b981;        /* brand green */
  --accent-2:#0ea5e9;      /* blue for secondary */
  --danger:#ff6b6b;

  /* Auth accents */
  --auth-bg:#0b1220;
  --auth-glass:rgba(255,255,255,.06);
  --auth-border:rgba(255,255,255,.12);
  --auth-txt:#e5e7eb;
  --auth-muted:#94a3b8;
  --auth-btn:#10b981;
  --auth-btn-txt:#062018;
  --auth-heading:#eef6ff;   /* title */
  --auth-accent:#34d399;    /* tagline */
}

/* ---------- Resets ---------- */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font:16px/1.5 system-ui,Segoe UI,Roboto,Arial,sans-serif;
  color:var(--text);
  background:linear-gradient(135deg,#0f1419,#1a2332);
}

/* =========================================================
   AUTH PAGE (applies only when <body class="auth-page">)
   ========================================================= */
body.auth-page{
  position:relative; min-height:100vh;
  display:flex; justify-content:center; align-items:center;
  background:var(--auth-bg); color:var(--auth-txt); overflow:hidden;
  padding:20px;
}

/* Animated background */
.auth-bg{position:fixed; inset:0; pointer-events:none; overflow:hidden; z-index:0}
.auth-bg__gradient{
  position:absolute; inset:-20%;
  background:
    radial-gradient(60% 80% at 70% 20%, rgba(16,185,129,.35), transparent 60%),
    radial-gradient(60% 65% at 20% 80%, rgba(14,165,233,.25), transparent 60%),
    radial-gradient(40% 40% at 90% 80%, rgba(244,114,182,.18), transparent 70%);
  filter:blur(60px); transform:scale(1.1); animation:authGrad 20s ease-in-out infinite;
}
@keyframes authGrad{0%,100%{transform:scale(1.1) rotate(0)}50%{transform:scale(1.15) rotate(2deg)}}
.auth-bg__noise{
  position:absolute; inset:0;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23f)' opacity='.035'/></svg>");
  mix-blend-mode:overlay; opacity:.5;
}

/* Decorative floaters (optional) */
.floater{position:fixed; opacity:.45; filter:blur(.3px); pointer-events:none; z-index:0}
.floater--egg{width:120px;height:160px;left:8%;top:65%;
  background:radial-gradient(ellipse at 40% 35%,#fff 0%,#e7ecf4 35%,#cfd7e5 100%);
  border-radius:50% 50% 48% 52%/56% 56% 44% 44%;
  animation:float1 14s ease-in-out infinite; box-shadow:0 8px 32px rgba(255,255,255,.1)}
.floater--egg2{width:88px;height:118px;right:10%;top:12%;
  background:radial-gradient(ellipse at 45% 35%,#fff 0%,#edf2f7 45%,#d7dfed 100%);
  border-radius:50% 50% 48% 52%/56% 56% 44% 44%;
  animation:float2 16s ease-in-out infinite; box-shadow:0 6px 24px rgba(255,255,255,.1)}
.floater--feather{width:170px;height:170px;left:64%;top:70%;
  background:radial-gradient(ellipse at 50% 40%,rgba(255,255,255,.8) 0%,rgba(255,255,255,.3) 50%,rgba(255,255,255,0) 70%);
  transform:rotate(25deg); animation:float3 18s ease-in-out infinite}
@keyframes float1{0%,100%{transform:translateY(0) rotate(0)}50%{transform:translateY(-25px) rotate(3deg)}}
@keyframes float2{0%,100%{transform:translateY(0) rotate(0)}50%{transform:translateY(20px) rotate(-4deg)}}
@keyframes float3{0%,100%{transform:translate(0,0) rotate(25deg)}50%{transform:translate(-15px,-18px) rotate(30deg)}}

/* Card */
.auth-wrap{position:relative; z-index:1; width:100%; max-width:520px; padding:20px}
.auth-card{
  background:var(--auth-glass); border:1px solid var(--auth-border);
  border-radius:18px; padding:32px;
  box-shadow:0 20px 60px rgba(0,0,0,.35);
  backdrop-filter:blur(12px) saturate(1.1);
  animation:cardIn .6s ease-out;
  color:var(--auth-txt);
}
@keyframes cardIn{from{opacity:0; transform:translateY(20px)} to{opacity:1; transform:translateY(0)}}

/* Brand row */
.brand{display:flex; align-items:center; gap:12px; margin-bottom:6px}
.brand__mark{width:40px;height:40px;flex-shrink:0;filter:drop-shadow(0 2px 4px rgba(0,0,0,.2))}
.brand h1{
  margin:0; font-weight:800; letter-spacing:.2px; font-size:30px;
  color:var(--auth-heading); text-shadow:0 1px 0 rgba(0,0,0,.35);
}
.tagline{
  margin:4px 0 24px; color:var(--auth-accent); font-weight:600; font-size:15px; line-height:1.4
}

/* Form */
.form{display:flex; flex-direction:column; gap:16px}
.field{display:flex; flex-direction:column; gap:6px}
.field span{font-size:14px; color:var(--auth-muted); font-weight:500}
.auth-page input[type="email"], .auth-page input[type="password"]{
  width:100%; background:#0f172a; color:var(--auth-txt);
  border:1px solid #1f2a37; border-radius:12px; padding:14px 16px; outline:none;
  transition:border-color .15s, box-shadow .15s; font-size:15px
}
.auth-page input::placeholder{color:#64748b}
.auth-page input:focus{border-color:#155e75; box-shadow:0 0 0 3px rgba(16,185,129,.15)}
.auth-page .btn{
  margin-top:8px; width:100%; background:var(--auth-btn); color:var(--auth-btn-txt);
  font-weight:700; border:0; border-radius:12px; padding:14px 16px; cursor:pointer;
  transition:transform .05s, filter .15s; font-size:15px
}
.auth-page .btn:hover{filter:brightness(1.08)}
.auth-page .btn:active{transform:translateY(1px)}
.err{margin-top:12px; color:#ef4444; font-weight:600; font-size:14px; text-align:center}
.meta{margin-top:20px; color:var(--auth-muted); text-align:center; font-size:13px}

@media (max-width:480px){
  .auth-card{padding:24px 20px; border-radius:14px}
  .brand h1{font-size:26px}
}

/* =========================================================
   DASHBOARD (applies only when <body class="page">)
   ========================================================= */
body.page{background:linear-gradient(135deg,#0f1419,#1a2332); color:var(--text)}
.topbar{
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 18px; background:#0e1520; border-bottom:1px solid var(--line); position:sticky; top:0; z-index:10
}
.topbar .brand{font-weight:700}
.topbar nav a{color:var(--text); text-decoration:none; margin-left:14px; opacity:.9}
.topbar .ctx{margin-left:auto; display:flex; gap:.5rem; align-items:center}
.pill{padding:.25rem .55rem; border-radius:9999px; font-size:.85rem; opacity:.9}
.pill.user{background:rgba(255,255,255,.06)}
.pill.tenant{background:rgba(77,171,247,.18)}

.container{max-width:1100px; margin:24px auto; padding:0 16px}

.cards{display:grid; grid-template-columns:repeat(4,1fr); gap:16px}
.card{background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:16px}
.card .big{font-size:28px; margin-top:10px}
.card .sub{color:var(--muted); font-size:13px; margin-top:6px}

/* KPI */
.kpi-grid{display:grid; grid-template-columns:repeat(4, minmax(220px,1fr)); gap:16px}
.kpi-card{display:flex; flex-direction:column; justify-content:space-between;
  min-height:170px; padding:18px; border-radius:14px; background:var(--panel);
  border:1px solid var(--line); box-shadow:0 1px 0 rgba(255,255,255,.04) inset}
.kpi-title{font-weight:800; font-size:1.15rem; margin:0 0 10px}
.kpi-value{font-size:2.25rem; line-height:1; margin:4px 0 0; white-space:nowrap}
.kpi-sub{margin-top:auto; font-size:.95rem; opacity:.85}

/* Charts */
.charts{margin-top:22px; display:grid; grid-template-columns:1fr; gap:16px}

/* Drawer */
.drawer{position:fixed; inset:0; display:none; background:rgba(0,0,0,.4); z-index:100}
.drawer .drawer-content{position:absolute; right:0; top:0; bottom:0; width:380px;
  background:#0e1520; border-left:1px solid var(--line); padding:16px; overflow:auto}
.drawer .group{background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; margin-bottom:12px}
.drawer label{display:block; font-size:13px; color:var(--muted); margin:6px 0}
.drawer input,.drawer select{width:100%; padding:8px; border-radius:8px; border:1px solid #2a3a4a; background:#0f1622; color:var(--text)}
.drawer button{margin-top:8px; padding:10px; border:0; border-radius:10px; background:var(--accent); color:#072016; font-weight:700; cursor:pointer}
.drawer .ok{color:#6ee7b7; font-size:12px; margin-top:6px}

/* Modal */
.modal{position:fixed; inset:0; display:none; background:rgba(0,0,0,.5); z-index:100}
.modal .modal-content{width:520px; max-width:calc(100% - 24px); margin:40px auto; background:#0e1520;
  border:1px solid var(--line); border-radius:12px; padding:16px}
.modal label{display:block; color:var(--muted); font-size:13px; margin:6px 0}
.modal input{width:100%; padding:8px; border-radius:8px; border:1px solid #2a3a4a; background:#0f1622; color:var(--text)}
.modal button{margin-top:8px; padding:10px; border:0; border-radius:10px; background:var(--accent); color:#072016; font-weight:700; cursor:pointer}

/* Buttons */
.btn{padding:8px 12px; border:0; border-radius:10px; cursor:pointer; background:var(--accent-2); color:#041018; font-weight:600}
.btn.primary{background:var(--accent); color:#062018}
.btn.ghost{background:transparent; border:1px solid rgba(148,163,184,.35); color:#cbd5e1}
.btn:disabled{opacity:.6; cursor:not-allowed}

/* Reports & tables */
.report{margin-top:24px; scroll-margin-top:80px}
.report-toolbar{
  position:sticky; top:64px; z-index:5;
  display:flex; gap:12px; align-items:center; justify-content:space-between;
  background:rgba(2,6,23,.6); backdrop-filter:blur(6px);
  padding:10px 12px; border:1px solid var(--line); border-radius:12px
}
.report-toolbar label{margin-right:8px; font-size:.92rem}
.report-toolbar input[type="date"]{padding:6px 8px; border-radius:8px; border:1px solid #2a3a4a; background:#0b1220; color:#e2e8f0}
.report-toolbar .left{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.report-toolbar .presets{display:flex; gap:6px}

.table-shell{margin-top:12px; overflow:auto; border:1px solid var(--line); border-radius:14px; background:rgba(2,6,23,.55)}
.table-scroller{overflow:auto; border:1px solid var(--line); border-radius:12px}
table.data, #cumTable{width:100%; border-collapse:separate; border-spacing:0; font-size:.95rem}
table.data thead th, #cumTable thead th{
  position:sticky; top:0; z-index:2; background:#0b1220; color:#e2e8f0; text-align:left;
  font-weight:700; padding:12px 10px; border-bottom:1px solid var(--line)
}
table.data tbody td, table.data tbody th, #cumTable tbody td{padding:10px; border-bottom:1px dashed #233244; white-space:nowrap}
table.data tbody tr:nth-child(odd){background:rgba(148,163,184,.05)}
table.data tfoot th, #cumTable tfoot th{
  position:sticky; bottom:0; z-index:1; background:#0b1220; color:#e2e8f0; padding:12px 10px; border-top:2px solid var(--line)
}
table.data .num{text-align:right}

/* ---------- Light theme ---------- */
body.light{background:#f8fafc; color:#0b1220}
body.light .topbar{background:#ffffff; border-bottom:1px solid #e5e7eb}
body.light .topbar a{color:#0b1220}
body.light .card, body.light .kpi-card, body.light .panel,
body.light .table-shell, body.light .drawer .drawer-content, body.light .modal .modal-content{
  background:#ffffff; border-color:#e5e7eb; color:#0b1220
}
body.light .sub, body.light .muted{color:#475569}
body.light input[type="text"], body.light input[type="date"], body.light input[type="number"],
body.light select, body.light textarea{background:#fff; color:#0b1220; border:1px solid #cbd5e1}
body.light .btn.ghost{border:1px solid #cbd5e1; color:#0b1220}
body.light .table-scroller{border-color:#e5e7eb}
body.light table.data thead th, body.light #cumTable thead th{border-color:#e5e7eb; background:#fff; color:#0b1220}
body.light table.data tbody td, body.light table.data tbody th, body.light #cumTable tbody td{border-color:#e5e7eb}
body.light table.data tfoot th, body.light #cumTable tfoot th{border-color:#e5e7eb; background:#fff; color:#0b1220}
body.light table.data tbody tr:nth-child(odd){background:#fafafa}
body.light .pill.user{background:#eef1f4}
body.light .pill.tenant{background:#e7f3ff}
body.light .charts canvas{background:#ffffff; border-radius:12px}
body.light .report-toolbar{background:#fff; border-color:#e5e7eb}
body.light .report-toolbar input[type="date"]{background:#fff; color:#0b1220; border-color:#cbd5e1}

/* ---------- Responsive ---------- */
@media (max-width:1200px){ .kpi-grid{ grid-template-columns:repeat(3,1fr) } }
@media (max-width:960px){ .cards{ grid-template-columns:repeat(2,1fr) } }
@media (max-width:900px){ .kpi-grid{ grid-template-columns:repeat(2,1fr) } }
@media (max-width:560px){ .cards,.kpi-grid{ grid-template-columns:1fr } }
