/* =====================================================================
   SmartWaste Monitor — Design Tokens
   Tema: panel kontrol industri (SCADA/HMI) untuk pemantauan limbah cair
   ===================================================================== */
:root{
  --bg: #060B14;
  --panel: #0E1626;
  --panel-2: #121C30;
  --panel-3: #0A111E;
  --border: #1E2A3F;
  --border-soft: #16202F;
  --text: #DCE6F2;
  --text-dim: #9FB0C3;
  --muted: #6F84A0;

  --accent-tds: #22D3EE;      /* cyan  - kejernihan air */
  --accent-temp: #F5A623;     /* amber - panas */
  --accent-doconc: #4ADE80;   /* hijau - oksigen/kehidupan */
  --accent-dosat: #A78BFA;    /* violet - saturasi */
  --accent-ph: #FB7185;       /* rose - keasaman/pH */
  --accent-signal: #60A5FA;   /* biru - sinyal */

  --success: #34D399;
  --warning: #F5B94E;
  --danger: #F87171;
  --offline: #4B5A6E;

  /* Palet warna diambil dari logo "IPAL Batik Astoetik" — dipakai khusus di halaman login */
  --astoetik-teal-deep: #0E5664;
  --astoetik-teal: #145E6E;
  --astoetik-cyan: #198EAF;
  --astoetik-green: #649735;
  --astoetik-gold: #B48340;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: radial-gradient(circle at 15% 0%, #0B1524 0%, var(--bg) 45%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}
a{ color: inherit; text-decoration: none; }
h1,h2,h3{ font-family: var(--font-display); margin: 0; }

/* ---------------- Layout shell ---------------- */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel-3), #060A12);
  border-right: 1px solid var(--border-soft);
  display:flex;
  flex-direction:column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand{ display:flex; align-items:center; gap:10px; padding: 6px 8px 22px; }
.brand-mark{
  width:36px; height:36px; border-radius:8px;
  background: linear-gradient(135deg, var(--accent-tds), var(--accent-doconc));
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight:700; color:#04121A; font-size:13px;
}
.brand-text{ display:flex; flex-direction:column; line-height:1.2; }
.brand-text strong{ font-family: var(--font-display); font-size:14px; }
.brand-text span{ font-size:11px; color: var(--muted); }

.sidebar-nav{ flex:1; display:flex; flex-direction:column; gap:2px; margin-top: 6px; }
.nav-label{
  font-size:10px; text-transform:uppercase; letter-spacing:.12em;
  color: var(--muted); margin: 14px 10px 6px;
}
.nav-item{
  display:flex; align-items:center; gap:10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px; font-weight:500;
  transition: background .15s ease, color .15s ease;
  border: 1px solid transparent;
}
.nav-item:hover{ background: var(--panel-2); color: var(--text); }
.nav-item.active{
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
.nav-ico{ width:14px; text-align:center; font-size:11px; opacity:.85; }
.nav-item.accent-tds.active .nav-ico, .nav-item.accent-tds:hover .nav-ico{ color: var(--accent-tds); }
.nav-item.accent-temp.active .nav-ico, .nav-item.accent-temp:hover .nav-ico{ color: var(--accent-temp); }
.nav-item.accent-doconc.active .nav-ico, .nav-item.accent-doconc:hover .nav-ico{ color: var(--accent-doconc); }
.nav-item.accent-dosat.active .nav-ico, .nav-item.accent-dosat:hover .nav-ico{ color: var(--accent-dosat); }
.nav-item.accent-ph.active .nav-ico, .nav-item.accent-ph:hover .nav-ico{ color: var(--accent-ph); }

.sidebar-footer{ font-size:11px; color: var(--muted); padding: 10px 8px 2px; }

/* ---------------- Main / topbar ---------------- */
.main-area{ flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar{ position: relative; background: var(--panel); border-bottom: 1px solid var(--border-soft); overflow:hidden; }
.flowline{
  position:absolute; top:0; left:0; right:0; height:2px;
  background: repeating-linear-gradient(90deg, var(--accent-tds) 0 18px, transparent 18px 34px);
  opacity:.55;
  animation: flow 2.4s linear infinite;
}
@keyframes flow{ from{ background-position-x:0; } to{ background-position-x:-52px; } }
@media (prefers-reduced-motion: reduce){ .flowline{ animation:none; } }

.topbar-inner{
  display:flex; align-items:center; justify-content:space-between; gap: 16px;
  padding: 18px 28px;
  flex-wrap: wrap;
}
.topbar-title h1{ font-size: 20px; }
.topbar-title p{ margin:2px 0 0; font-size:12.5px; color: var(--muted); }

.topbar-status{ display:flex; flex-direction:column; align-items:flex-end; gap:6px; }

.topbar-clock{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding: 4px 18px; border-left: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft);
}
.topbar-clock .clock-time{
  font-family: var(--font-mono); font-size: 20px; font-weight:600; color: var(--text);
  letter-spacing: .02em;
}
.topbar-clock .clock-date{ font-size: 11px; color: var(--muted); margin-top:2px; white-space: nowrap; }

/* ---------------- Panel Indeks Kualitas Air ---------------- */
.quality-score-badge{
  display:flex; flex-direction:column; align-items:center; gap:2px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  background: rgba(111,132,160,.1); border: 1px solid var(--border);
}
.quality-score-badge span[data-score-value]{ font-family: var(--font-display); font-size: 22px; font-weight:700; color: var(--text); }
.quality-score-badge .quality-score-label{ font-size: 10px; color: var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.quality-score-badge.status-normal{ border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.quality-score-badge.status-warning{ border-color: rgba(245,185,78,.35); background: rgba(245,185,78,.08); }
.quality-score-badge.status-danger{ border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.08); }

.quality-overall{
  display:inline-block; margin-bottom:14px; padding: 8px 16px; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-weight:700; font-size:14px;
  background: rgba(111,132,160,.1); color: var(--offline); border: 1px solid var(--border);
}
.quality-overall.status-normal{ background: rgba(52,211,153,.1); color: var(--success); border-color: rgba(52,211,153,.35); }
.quality-overall.status-warning{ background: rgba(245,185,78,.1); color: var(--warning); border-color: rgba(245,185,78,.35); }
.quality-overall.status-danger{ background: rgba(248,113,113,.1); color: var(--danger); border-color: rgba(248,113,113,.35); }
.status-pill{
  display:flex; align-items:center; gap:8px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 12px; font-weight:600;
}
.status-pill .dot{ width:8px; height:8px; border-radius:50%; background: var(--offline); }
.status-pill[data-state="online"] .dot{ background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-pill[data-state="offline"] .dot{ background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-detail{ display:flex; gap:14px; font-size: 11px; color: var(--muted); font-family: var(--font-mono); }

.content{ padding: 24px 28px 60px; display:flex; flex-direction:column; gap:22px; }

/* ---------------- Stat cards ---------------- */
.cards-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap:16px; }
.stat-card{
  position:relative;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  overflow:hidden;
}
.stat-card::before{
  content:""; position:absolute; left:0; top:0; bottom:0; width:3px;
  background: var(--accent-signal);
}
.stat-card.accent-tds::before{ background: var(--accent-tds); }
.stat-card.accent-temp::before{ background: var(--accent-temp); }
.stat-card.accent-doconc::before{ background: var(--accent-doconc); }
.stat-card.accent-dosat::before{ background: var(--accent-dosat); }
.stat-card.accent-ph::before{ background: var(--accent-ph); }
.stat-card.accent-signal::before{ background: var(--accent-signal); }

.stat-card-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.stat-label{ font-size:12px; color: var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.stat-value{ display:flex; align-items:baseline; gap:6px; }
.stat-number{ font-family: var(--font-display); font-size: 30px; font-weight:700; }
.stat-unit{ font-size:12px; color: var(--muted); }
.stat-sub{ margin-top:8px; font-size:11.5px; color: var(--muted); font-family: var(--font-mono); }
.stat-link{ display:inline-block; margin-top:10px; font-size:11.5px; color: var(--text-dim); }
.stat-link:hover{ color: var(--accent-tds); }

.gauge-ring{ display:none; } /* placeholder ring reserved for future gauge treatment */

.status-badge{
  font-size:10.5px; font-weight:700; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing:.03em;
  background: rgba(111,132,160,.15); color: var(--offline);
  border: 1px solid rgba(111,132,160,.3);
}
.status-badge.status-normal{ background: rgba(52,211,153,.12); color: var(--success); border-color: rgba(52,211,153,.35); }
.status-badge.status-warning{ background: rgba(245,185,78,.12); color: var(--warning); border-color: rgba(245,185,78,.35); }
.status-badge.status-danger{ background: rgba(248,113,113,.12); color: var(--danger); border-color: rgba(248,113,113,.35); }
.status-badge.status-offline{ background: rgba(75,90,110,.15); color: var(--offline); border-color: rgba(75,90,110,.35); }

/* ---------------- Panels / charts ---------------- */
.panel{
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
}
.panel-head{ display:flex; justify-content:space-between; align-items:flex-end; gap:14px; flex-wrap:wrap; margin-bottom: 14px; }
.panel-head h2{ font-size:16px; }
.panel-sub{ margin:4px 0 0; font-size:12px; color: var(--muted); }

.range-selector{ display:flex; gap:4px; background: var(--panel-3); border:1px solid var(--border); border-radius: 999px; padding:3px; }
.range-selector button{
  border:none; background:transparent; color: var(--muted);
  font-size:11.5px; font-weight:600; padding:6px 12px; border-radius:999px; cursor:pointer;
  font-family: var(--font-mono);
}
.range-selector button.active{ background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }

.custom-range-form{
  display:flex; align-items:center; gap:12px; flex-wrap:wrap;
  background: var(--panel-3); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 14px;
}
.custom-range-form label{ display:flex; align-items:center; gap:6px; font-size:12px; color: var(--muted); }
.custom-range-form input[type=date]{
  background: var(--panel-2); border:1px solid var(--border); color: var(--text);
  padding: 5px 8px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size:12.5px;
}
.custom-range-form .btn-primary{ padding: 6px 14px; font-size:12.5px; }
.custom-range-form[hidden]{ display:none; }

/* ---------------- Halaman Pengaturan (settings.php) ---------------- */
.settings-alert{
  padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: 13px; border: 1px solid var(--border);
}
.settings-alert.success{ background: rgba(52,211,153,.1); color: var(--success); border-color: rgba(52,211,153,.35); }
.settings-alert.error{ background: rgba(248,113,113,.1); color: var(--danger); border-color: rgba(248,113,113,.35); }

.threshold-table input[type=number]{
  width: 100px; background: var(--panel-3); border:1px solid var(--border); color: var(--text);
  padding: 6px 8px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size:12.5px;
}
.source-badge{
  font-size:10.5px; font-weight:700; padding: 3px 9px; border-radius: 999px; text-transform:uppercase;
  border: 1px solid var(--border); color: var(--muted); background: rgba(111,132,160,.1);
}
.source-badge.custom{ color: var(--accent-tds); border-color: rgba(34,211,238,.35); background: rgba(34,211,238,.1); }

.settings-actions{ display:flex; gap:12px; margin-top:18px; }
.btn-reset-row{ font-size: 11.5px; padding: 5px 10px; }
.btn-reset-row:disabled{ opacity:.35; cursor:not-allowed; }

.chart-wrap{ position:relative; width:100%; }
.chart-wrap-lg{ height: 340px; }
.chart-wrap-sm{ height: 160px; }
.chart-legend-note{ margin-top:10px; font-size:11px; color: var(--muted); }

.mini-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap:16px; }
.mini-panel{ background: var(--panel); border:1px solid var(--border-soft); border-radius: var(--radius); padding:16px; }
.mini-panel-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.mini-panel-head h3{ font-size:13px; }
.mini-panel-head a{ font-size:11px; color: var(--muted); }
.mini-panel-head a:hover{ color: var(--accent-tds); }
.mini-stats{ display:flex; justify-content:space-between; margin-top:10px; font-size:11px; color: var(--muted); font-family: var(--font-mono); }
.mini-stats b{ color: var(--text); }

.accent-text-tds{ color: var(--accent-tds); }
.accent-text-temp{ color: var(--accent-temp); }
.accent-text-doconc{ color: var(--accent-doconc); }
.accent-text-dosat{ color: var(--accent-dosat); }
.accent-text-ph{ color: var(--accent-ph); }

/* ---------------- Detail page ---------------- */
.detail-head{ display:flex; flex-wrap:wrap; gap:16px; }
.detail-current{
  background: var(--panel); border:1px solid var(--border-soft); border-radius: var(--radius);
  padding: 22px 24px; flex: 1 1 260px; position:relative; overflow:hidden;
}
.detail-current::before{ content:""; position:absolute; left:0; top:0; bottom:0; width:3px; background: var(--accent-signal); }
.detail-current.accent-tds::before{ background: var(--accent-tds); }
.detail-current.accent-temp::before{ background: var(--accent-temp); }
.detail-current.accent-doconc::before{ background: var(--accent-doconc); }
.detail-current.accent-dosat::before{ background: var(--accent-dosat); }
.detail-current.accent-ph::before{ background: var(--accent-ph); }
.detail-label{ font-size:12px; text-transform:uppercase; letter-spacing:.06em; color: var(--muted); font-weight:700; }
.detail-value{ display:flex; align-items:baseline; gap:8px; margin: 10px 0; }
.detail-value span:first-child{ font-family: var(--font-display); font-size:44px; font-weight:700; }
.detail-unit{ font-size:14px; color: var(--muted); }
.detail-updated{ margin: 10px 0 0; font-size:11.5px; color: var(--muted); font-family: var(--font-mono); }

.detail-stats{ display:grid; grid-template-columns: repeat(2,1fr); gap:12px; flex: 1 1 320px; }
.detail-stat-box{
  background: var(--panel); border:1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 14px 16px; display:flex; flex-direction:column; gap:6px; justify-content:center;
}
.detail-stat-box span{ font-size:11px; color: var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.detail-stat-box b{ font-family: var(--font-mono); font-size:16px; }

/* ---------------- Tables ---------------- */
.table-wrap{ overflow-x:auto; border:1px solid var(--border-soft); border-radius: var(--radius-sm); }
.data-table{ width:100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th{
  text-align:left; background: var(--panel-3); color: var(--muted);
  padding: 10px 14px; font-weight:600; text-transform:uppercase; font-size:10.5px; letter-spacing:.05em;
  border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
.data-table tbody td{ padding: 9px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
.data-table tbody tr:hover{ background: var(--panel-2); }
.data-table .mono{ font-family: var(--font-mono); color: var(--text-dim); }
.empty-row{ text-align:center; color: var(--muted); padding: 24px !important; }

/* ---------------- Filter bar / buttons ---------------- */
.filter-bar{ display:flex; gap:14px; flex-wrap:wrap; align-items:flex-end; margin-bottom:16px; }
.filter-field{ display:flex; flex-direction:column; gap:6px; }
.filter-field label{ font-size:11px; color: var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.filter-field select, .filter-field input[type=date]{
  background: var(--panel-3); border:1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size:13px;
}
.btn-primary, .btn-outline{
  padding: 8px 16px; border-radius: var(--radius-sm); font-size:13px; font-weight:600; cursor:pointer; border:1px solid transparent;
  display:inline-block;
}
.btn-primary{ background: linear-gradient(135deg, var(--accent-tds), var(--accent-doconc)); color:#04121A; border:none; }
.btn-outline{ background: transparent; border:1px solid var(--border); color: var(--text-dim); }
.btn-outline:hover{ border-color: var(--accent-tds); color: var(--accent-tds); }

.pagination{ display:flex; gap:6px; justify-content:center; margin-top:16px; flex-wrap:wrap; }
.pagination button{
  min-width: 32px; padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--panel-3); border:1px solid var(--border); color: var(--text-dim);
  font-family: var(--font-mono); font-size:12px; cursor:pointer;
}
.pagination button.active{ background: var(--panel-2); color: var(--text); border-color: var(--accent-tds); }
.pagination button:disabled{ opacity:.4; cursor:not-allowed; }

/* ---------------- Hamburger (mobile only) ---------------- */
.hamburger-btn{
  display:none; flex-direction:column; justify-content:center; gap:4px;
  width:36px; height:36px; padding:0; border-radius: var(--radius-sm);
  background: var(--panel-2); border:1px solid var(--border); cursor:pointer; flex-shrink:0;
}
.hamburger-btn span{ display:block; width:16px; height:2px; margin:0 auto; background: var(--text-dim); border-radius:2px; transition: transform .2s ease, opacity .2s ease; }
.hamburger-btn:hover span{ background: var(--accent-tds); }

.sidebar-overlay{
  display:none; position:fixed; inset:0; background: rgba(3,7,14,.6);
  backdrop-filter: blur(2px); z-index: 40; opacity:0; transition: opacity .2s ease;
}
.sidebar-overlay.sidebar-overlay-visible{ display:block; opacity:1; }

.sidebar-close-btn{ display:none; }

.nav-item-logout{ color: var(--danger); margin-top: 6px; }
.nav-item-logout .nav-ico{ color: var(--danger); }
.nav-item-logout:hover{ background: rgba(248,113,113,.1); color: var(--danger); }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px){
  .app-shell{ flex-direction:column; }

  .hamburger-btn{ display:flex; }

  .sidebar{
    position: fixed; top:0; left:0; bottom:0; z-index: 50;
    width: min(78vw, 300px); height: 100vh;
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: 12px 0 32px rgba(0,0,0,.45);
    flex-direction: column; overflow-y:auto; overflow-x:hidden;
    align-items: stretch; gap:0; padding: 18px 14px;
  }
  .sidebar.sidebar-open{ transform: translateX(0); }

  .sidebar-brand{ position:relative; padding-right: 34px; }
  .sidebar-close-btn{
    display:flex; align-items:center; justify-content:center;
    position:absolute; right:0; top:2px; width:28px; height:28px;
    background: var(--panel-2); border:1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-dim); font-size:13px; cursor:pointer;
  }

  .sidebar-nav{ flex-direction:column; margin-top:4px; }
  .nav-label{ display:block; }
  .sidebar-footer{ display:block; margin-top:auto; }

  body.sidebar-locked{ overflow:hidden; }

  .content{ padding: 18px; }
  .topbar-inner{ padding: 14px 18px; flex-wrap: wrap; }
  .topbar-title{ order:2; flex: 1 1 auto; min-width: 0; }
  .topbar-status{ align-items:flex-start; order:3; }
  .topbar-clock{ border:none; padding: 0; align-items:flex-start; order:4; }
  .detail-value span:first-child{ font-size:34px; }
}

@media (max-width: 480px){
  .ai-chat-panel{ width: calc(100vw - 24px); height: min(72vh, 560px); right: -6px; }
  .ai-chat-fab{ width:54px; height:54px; }
  .login-brand-row{ flex-direction:column; text-align:center; }
  .login-partners{ flex-wrap: wrap; gap: 16px; }
}


/* =====================================================================
   Chat AI Widget (floating)
   ===================================================================== */
.ai-chat-root{ position: fixed; right: 22px; bottom: 22px; z-index: 60; }

.ai-chat-fab{
  width: 58px; height: 58px; border-radius: 50%; position:relative;
  background: linear-gradient(135deg, var(--accent-tds), var(--accent-dosat));
  border: none; color: #04121A; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow: 0 8px 24px rgba(34,211,238,.28), 0 2px 8px rgba(0,0,0,.35);
  transition: transform .18s ease, box-shadow .18s ease;
}
.ai-chat-fab:hover{ transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 30px rgba(34,211,238,.35); }
.ai-chat-fab svg{ width:26px; height:26px; }
.ai-fab-icon-close{ display:none; }
.ai-chat-root.ai-open .ai-fab-icon-chat{ display:none; }
.ai-chat-root.ai-open .ai-fab-icon-close{ display:block; }

.ai-fab-pulse{
  position:absolute; inset:-4px; border-radius:50%;
  border: 2px solid rgba(34,211,238,.45);
  animation: aiPulse 2.4s ease-out infinite;
}
.ai-chat-root.ai-open .ai-fab-pulse{ display:none; }
@keyframes aiPulse{
  0%{ transform: scale(.9); opacity:.8; }
  80%{ transform: scale(1.35); opacity:0; }
  100%{ opacity:0; }
}

.ai-chat-panel{
  position:absolute; right:0; bottom:74px; width: 360px; height: 500px;
  background: var(--panel); border:1px solid var(--border); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  display:flex; flex-direction:column; overflow:hidden;
  animation: aiPanelIn .18s ease;
}
/* Penting: [hidden] harus tetap bisa menyembunyikan panel walau .ai-chat-panel
   sudah mengatur display:flex di atas. Tanpa baris ini, atribut `hidden` dari
   HTML tidak berefek karena kalah spesifisitas/asal dari style author di atas,
   sehingga tombol tutup/minimize terlihat tidak berfungsi. */
.ai-chat-panel[hidden]{ display:none; }
@keyframes aiPanelIn{ from{ opacity:0; transform: translateY(10px) scale(.98); } to{ opacity:1; transform:none; } }

.ai-chat-head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px; background: linear-gradient(120deg, var(--panel-2), var(--panel-3));
  border-bottom: 1px solid var(--border-soft);
}
.ai-chat-head-left{ display:flex; align-items:center; gap:10px; }
.ai-chat-avatar{
  width:34px; height:34px; border-radius:10px; flex-shrink:0;
  background: linear-gradient(135deg, var(--accent-tds), var(--accent-doconc));
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight:700; font-size:12px; color:#04121A;
}
.ai-chat-head-left strong{ display:block; font-size:13.5px; font-family: var(--font-display); }
.ai-chat-head-left span{ display:block; font-size:11px; color: var(--muted); }
.ai-chat-minimize{
  width:26px; height:26px; border-radius:7px; background: transparent; border:1px solid var(--border);
  color: var(--text-dim); font-size:16px; line-height:1; cursor:pointer;
}
.ai-chat-minimize:hover{ color: var(--text); border-color: var(--accent-tds); }

.ai-chat-body{ flex:1; overflow-y:auto; padding: 14px 14px 4px; display:flex; flex-direction:column; gap:10px; }
.ai-msg{ display:flex; }
.ai-msg-bubble{
  max-width: 84%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height:1.5;
  word-wrap: break-word;
}
.ai-msg-bot{ justify-content:flex-start; }
.ai-msg-bot .ai-msg-bubble{ background: var(--panel-2); border:1px solid var(--border-soft); color: var(--text); border-bottom-left-radius:3px; }
.ai-msg-user{ justify-content:flex-end; }
.ai-msg-user .ai-msg-bubble{ background: linear-gradient(135deg, rgba(34,211,238,.22), rgba(167,139,250,.18)); border:1px solid rgba(34,211,238,.35); color: var(--text); border-bottom-right-radius:3px; }

.ai-chat-typing{ display:flex; gap:4px; padding: 0 16px 8px; }
.ai-chat-typing[hidden]{ display:none; }
.ai-chat-typing span{
  width:6px; height:6px; border-radius:50%; background: var(--muted);
  animation: aiTypingDot 1.1s ease-in-out infinite;
}
.ai-chat-typing span:nth-child(2){ animation-delay:.15s; }
.ai-chat-typing span:nth-child(3){ animation-delay:.3s; }
@keyframes aiTypingDot{ 0%,60%,100%{ opacity:.3; transform: translateY(0); } 30%{ opacity:1; transform: translateY(-3px); } }

.ai-chat-input-row{
  display:flex; align-items:center; gap:8px; padding: 10px 12px;
  border-top: 1px solid var(--border-soft); background: var(--panel-3);
}
.ai-chat-input-row input{
  flex:1; background: var(--panel-2); border:1px solid var(--border); color: var(--text);
  padding: 9px 12px; border-radius: 999px; font-family: var(--font-body); font-size:13px;
}
.ai-chat-input-row input:focus{ outline:none; border-color: var(--accent-tds); }
.ai-chat-send{
  width:34px; height:34px; border-radius:50%; flex-shrink:0; cursor:pointer;
  background: linear-gradient(135deg, var(--accent-tds), var(--accent-doconc)); border:none; color:#04121A;
  display:flex; align-items:center; justify-content:center;
}
.ai-chat-send svg{ width:16px; height:16px; }
.ai-chat-send:disabled{ opacity:.5; cursor:not-allowed; }

/* =====================================================================
   Login Page
   ===================================================================== */
body.login-body{
  margin:0; min-height:100vh; overflow-x:hidden;
  display:flex; align-items:center; justify-content:center;
  background: #061417; color: var(--text); font-family: var(--font-body);
  position: relative;
}

.login-slideshow{ position:fixed; inset:0; z-index:0; overflow:hidden; background: #061417; }
.login-slide{
  position:absolute; inset:-5%; opacity:0; filter: saturate(1);
  animation: loginSlideShow 24s infinite;
  background-size: cover;
}
.login-slide-1{
  background:
    radial-gradient(circle at 20% 25%, rgba(25,142,175,.35), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(100,151,53,.24), transparent 50%),
    linear-gradient(160deg, #051217, #0A2530 60%, #051217);
  animation-delay: 0s;
}
.login-slide-2{
  background:
    radial-gradient(circle at 75% 20%, rgba(180,131,64,.28), transparent 55%),
    radial-gradient(circle at 15% 80%, rgba(20,94,110,.35), transparent 50%),
    linear-gradient(200deg, #051217, #0A2228 55%, #051217);
  animation-delay: 6s;
}
.login-slide-3{
  background:
    radial-gradient(circle at 50% 85%, rgba(100,151,53,.26), transparent 55%),
    radial-gradient(circle at 85% 15%, rgba(25,142,175,.30), transparent 50%),
    linear-gradient(140deg, #051217, #0B2A2E 60%, #051217);
  animation-delay: 12s;
}
.login-slide-4{
  background:
    radial-gradient(circle at 30% 60%, rgba(180,131,64,.22), transparent 55%),
    radial-gradient(circle at 70% 25%, rgba(14,86,100,.40), transparent 50%),
    linear-gradient(180deg, #051217, #09232A 55%, #051217);
  animation-delay: 18s;
}
@keyframes loginSlideShow{
  0%{ opacity:0; transform: scale(1.06) translate(0,0); }
  4%{ opacity:1; }
  22%{ opacity:1; transform: scale(1.1) translate(-1%,-1%); }
  27%{ opacity:0; }
  100%{ opacity:0; }
}
@media (prefers-reduced-motion: reduce){ .login-slide{ animation: none; opacity:1; } }

.login-slide-grid{
  position:absolute; inset:0;
  background-image:
    linear-gradient(rgba(220,230,242,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(220,230,242,.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 40%, black, transparent 75%);
}
.login-slide-batik{
  position:absolute; inset:0; opacity:.16; mix-blend-mode: soft-light;
  background-image: radial-gradient(circle at center, rgba(180,131,64,.9) 0 3px, transparent 4px 100%);
  background-size: 46px 46px;
  background-position: 0 0, 23px 23px;
  mask-image: radial-gradient(circle at 50% 45%, black, transparent 78%);
  animation: batikDrift 40s linear infinite;
}
@keyframes batikDrift{ from{ background-position: 0 0; } to{ background-position: 92px 92px; } }
.login-slide-vignette{
  position:absolute; inset:0;
  background: radial-gradient(circle at 50% 38%, rgba(5,18,23,.35), rgba(5,18,23,.9) 78%);
}

.login-wrap{ position:relative; z-index:1; padding: 24px; width:100%; display:flex; justify-content:center; }

.login-card{
  width: 100%; max-width: 440px;
  background: rgba(10,28,32,.72);
  border: 1px solid rgba(25,142,175,.25);
  border-radius: 18px;
  padding: 32px 30px 26px;
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 30px 70px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
}

.login-brand-row{ display:flex; align-items:center; gap:14px; margin-bottom: 22px; }
.login-brand-logo{ width:64px; height:64px; object-fit:contain; border-radius:12px; background: rgba(255,255,255,.05); padding:6px; flex-shrink:0; }
.login-brand-text h1{ font-size: 21px; line-height:1.15; letter-spacing:-.01em; background: linear-gradient(120deg, #DCE6F2, var(--astoetik-cyan)); -webkit-background-clip:text; background-clip:text; color:transparent; }
.login-brand-text p{ margin: 4px 0 0; font-size:12.5px; color: var(--muted); }

.login-alert{
  background: rgba(248,113,113,.1); border:1px solid rgba(248,113,113,.35); color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size:12.5px; margin-bottom:16px;
}

.login-form{ display:flex; flex-direction:column; gap:14px; }
.login-field{ display:flex; flex-direction:column; gap:6px; }
.login-field span{ font-size:11.5px; color: var(--muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.login-field input{
  background: rgba(5,18,23,.6); border:1px solid rgba(25,142,175,.28); color: var(--text);
  padding: 11px 13px; border-radius: var(--radius-sm); font-family: var(--font-body); font-size:14px;
  width:100%;
}
.login-field input:focus{ outline:none; border-color: var(--astoetik-cyan); box-shadow: 0 0 0 3px rgba(25,142,175,.18); }

.login-pass-wrap{ position:relative; }
.login-pass-wrap input{ padding-right:40px; }
.login-pass-toggle{
  position:absolute; right:6px; top:50%; transform: translateY(-50%);
  width:28px; height:28px; background:transparent; border:none; cursor:pointer;
  font-size:14px; opacity:.75;
}
.login-pass-toggle:hover{ opacity:1; }

.login-submit{
  margin-top:4px; padding: 12px 16px; border-radius: var(--radius-sm); border:none; cursor:pointer;
  background: linear-gradient(135deg, var(--astoetik-cyan), var(--astoetik-green)); color:#04121A;
  font-family: var(--font-display); font-weight:700; font-size:14px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.login-submit:hover{ transform: translateY(-1px); box-shadow: 0 8px 20px rgba(25,142,175,.3); }
.login-submit:active{ transform: translateY(0); }

.login-divider{ display:flex; align-items:center; gap:10px; margin: 24px 0 16px; color: var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.08em; }
.login-divider::before, .login-divider::after{ content:""; flex:1; height:1px; background: rgba(25,142,175,.2); }

.login-partners{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.login-partner{ flex:1; display:flex; flex-direction:column; align-items:center; gap:8px; text-align:center; }
.login-partner-logo{ width:44px; height:44px; object-fit:contain; border-radius:9px; background: rgba(255,255,255,.05); padding:5px; }
.login-partner-mark{
  width:44px; height:44px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-weight:700; font-size:12px; color: var(--text-dim);
  background: rgba(5,18,23,.6); border:1px solid rgba(25,142,175,.28);
}
.login-partner-mark-vendor{ background: linear-gradient(135deg, var(--astoetik-cyan), var(--astoetik-teal-deep)); color:#EAF6FA; border:none; }
.login-partner-mark-gold{ background: linear-gradient(135deg, var(--astoetik-gold), #8C6229); color:#FBF3E4; border:none; }
.login-partner span{ font-size:10px; color: var(--muted); line-height:1.3; }

.login-footnote{ margin: 22px 0 0; text-align:center; font-size:10.5px; color: var(--muted); }
