/* ============================================
   WAK PLONG LAPORAN - Dark Theme
   ============================================ */

:root {
  --bg: #0c1220;
  --bg2: #111827;
  --bg3: #1a2332;
  --bg4: #243044;
  --surface: #1e293b;
  --border: #2a3a50;
  --border2: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --accent: #f59e0b;
  --accent2: #fbbf24;
  --red: #ef4444;
  --green: #22c55e;
  --blue: #3b82f6;
  --purple: #a855f7;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
}

* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; }
body {
  font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* LOGIN */
.login-screen {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; transition: opacity .4s, visibility .4s;
}
.login-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.login-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 40px 32px; width: 92%; max-width: 380px;
  text-align: center; box-shadow: var(--shadow);
}
.login-logo {
  width: 56px; height: 56px; background: var(--red); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 900; color: #fff; margin: 0 auto 16px;
}
.login-box h1 { font-size: 20px; font-weight: 800; letter-spacing: 1px; margin-bottom: 4px; }
.login-box .sub { font-size: 12px; color: var(--text3); margin-bottom: 24px; }
.login-input {
  width: 100%; background: var(--bg3); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 14px; font-size: 22px;
  text-align: center; letter-spacing: 10px; color: var(--text);
  font-family: 'JetBrains Mono', monospace; outline: none; transition: .2s;
}
.login-input:focus { border-color: var(--accent); }
.login-input::placeholder { letter-spacing: 4px; font-size: 14px; color: var(--text3); }
.login-err { font-size: 12px; color: var(--red); margin-top: 8px; min-height: 20px; font-weight: 600; }
.login-btn {
  width: 100%; margin-top: 16px; padding: 14px; border: none;
  border-radius: var(--radius); background: var(--accent); color: var(--bg);
  font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; transition: .15s;
}
.login-btn:hover { background: var(--accent2); }
.login-btn:active { transform: scale(.97); }
.login-btn:disabled { opacity: .5; cursor: default; transform: none; }

/* LAYOUT */
.app { display: none; flex-direction: column; min-height: 100vh; }
.app.show { display: flex; }

.topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 16px 20px; display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 12px; position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  width: 36px; height: 36px; background: var(--red); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff; flex-shrink: 0;
}
.topbar h1 { font-size: 16px; font-weight: 800; letter-spacing: .5px; }
.topbar h1 span { color: var(--accent); }
.btn-logout {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 14px; color: var(--text2); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.btn-logout:hover { background: var(--bg4); color: var(--text); }

/* FILTER */
.filter-bar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 14px 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.filter-bar label { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; }
.filter-bar input[type=date] {
  background: var(--bg3); border: 1.5px solid var(--border); border-radius: 8px;
  padding: 8px 12px; color: var(--text); font-family: 'JetBrains Mono', monospace;
  font-size: 12px; outline: none; transition: .2s;
}
.filter-bar input[type=date]:focus { border-color: var(--accent); }
.filter-bar input[type=date]::-webkit-calendar-picker-indicator { filter: invert(1) brightness(.7); }
.filter-sep { color: var(--text3); font-size: 13px; font-weight: 600; }
.btn-filter {
  background: var(--accent); color: var(--bg); border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 12px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.btn-filter:hover { background: var(--accent2); }
.btn-filter:active { transform: scale(.97); }
.quick-btns { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.btn-quick {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; color: var(--text2); font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: .15s; white-space: nowrap;
}
.btn-quick:hover { background: var(--bg4); color: var(--text); border-color: var(--border2); }
.btn-quick.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* CONTENT */
.content { flex: 1; padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* SUMMARY CARDS */
.summary-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.s-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.s-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  border-radius: 4px 0 0 4px;
}
.s-card.c-yellow::before { background: var(--accent); }
.s-card.c-blue::before { background: var(--blue); }
.s-card.c-green::before { background: var(--green); }
.s-card.c-red::before { background: var(--red); }
.s-label { font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 6px; }
.s-value { font-size: 26px; font-weight: 800; font-family: 'JetBrains Mono', monospace; line-height: 1.1; }
.s-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* CHART */
.chart-section {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.chart-section h2 {
  font-size: 14px; font-weight: 700; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.chart-section h2 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.chart-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.chart-tab {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 14px; color: var(--text2); font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.chart-tab:hover { background: var(--bg4); }
.chart-tab.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* Bar chart */
.bar-group { display: flex; align-items: flex-end; gap: 3px; height: 220px; padding: 0 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar {
  width: 100%; max-width: 48px; border-radius: 6px 6px 2px 2px;
  transition: height .5s cubic-bezier(.4,0,.2,1); position: relative; cursor: pointer; min-height: 2px;
}
.bar:hover { filter: brightness(1.2); }
.bar .bar-tooltip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--bg); border: 1px solid var(--border2);
  border-radius: 8px; padding: 8px 12px; font-size: 11px; white-space: nowrap;
  z-index: 50; box-shadow: var(--shadow); pointer-events: none;
}
.bar:hover .bar-tooltip { display: block; }
.bar-tooltip .bt-label { color: var(--text2); font-weight: 600; }
.bar-tooltip .bt-value { color: var(--accent); font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.bar-label { font-size: 9px; color: var(--text3); margin-top: 6px; font-weight: 600; text-align: center; }
.bar-axis { display: flex; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; }
.bar-axis span { font-size: 9px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.donut-svg { width: 200px; height: 200px; flex-shrink: 0; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.dl-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dl-label { color: var(--text2); }
.dl-value { font-weight: 700; font-family: 'JetBrains Mono', monospace; margin-left: auto; }

/* Daily */
.daily-chart { overflow-x: auto; padding-bottom: 8px; }
.daily-bars { display: flex; align-items: flex-end; gap: 2px; height: 160px; min-width: fit-content; }
.daily-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 28px; flex-shrink: 0; }
.daily-bar {
  width: 20px; border-radius: 4px 4px 1px 1px; transition: height .4s ease;
  cursor: pointer; position: relative; min-height: 1px;
}
.daily-bar:hover { filter: brightness(1.25); }
.daily-bar .bar-tooltip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; padding: 8px 12px; font-size: 11px; white-space: nowrap; z-index: 50; box-shadow: var(--shadow); }
.daily-bar:hover .bar-tooltip { display: block; }
.daily-date { font-size: 8px; color: var(--text3); margin-top: 4px; font-family: 'JetBrains Mono', monospace; writing-mode: vertical-lr; text-orientation: mixed; height: 36px; overflow: hidden; }

/* DETAIL TABLE */
.detail-section {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 20px;
}
.detail-header {
  padding: 16px 20px; display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 10px; border-bottom: 1px solid var(--border);
}
.detail-header h2 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.detail-header h2 .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.detail-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.branch-select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; color: var(--text); font-size: 12px; font-family: inherit; outline: none; cursor: pointer;
}
.branch-select option { background: var(--bg2); }
.btn-export {
  background: var(--green); color: var(--bg); border: none; border-radius: 8px;
  padding: 6px 14px; font-size: 11px; font-weight: 700; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.btn-export:hover { filter: brightness(1.1); }
.btn-print {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 14px; font-size: 11px; font-weight: 600; color: var(--text2);
  cursor: pointer; font-family: inherit; transition: .15s;
}
.btn-print:hover { background: var(--bg4); color: var(--text); }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead { background: var(--bg3); }
th { padding: 10px 14px; text-align: left; font-weight: 700; color: var(--text2); font-size: 10px; text-transform: uppercase; letter-spacing: .8px; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.td-order { font-weight: 700; font-family: 'JetBrains Mono', monospace; color: var(--accent); font-size: 11px; white-space: nowrap; }
.td-time { color: var(--text3); font-family: 'JetBrains Mono', monospace; font-size: 11px; white-space: nowrap; }
.td-items { color: var(--text2); line-height: 1.5; max-width: 300px; }
.td-total { font-weight: 800; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.td-branch { font-weight: 600; }
.tag-gb { color: #60a5fa; }
.tag-md { color: #f97316; }
.tag-sj { color: #a78bfa; }
.tbl-empty { text-align: center; color: var(--text3); padding: 40px; font-size: 13px; }
.tbl-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text3); }

/* LOADING */
.loading { text-align: center; padding: 60px 20px; }
.spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 12px; font-size: 13px; color: var(--text3); }

/* WARNING */
.warning-bar {
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3);
  border-radius: 8px; padding: 10px 16px; margin-bottom: 16px;
  font-size: 12px; color: var(--accent2); display: flex; align-items: center; gap: 8px;
}

/* EMPTY */
.empty-state { text-align: center; padding: 80px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-text { font-size: 14px; color: var(--text3); }

/* PRINT */
@media print {
  body { background: #fff !important; color: #000 !important; font-size: 11px; }
  .topbar, .filter-bar, .btn-export, .btn-print, .btn-logout, .chart-tabs, .login-screen { display: none !important; }
  .app { display: flex !important; }
  .s-card, .chart-section, .detail-section { border: 1px solid #ddd !important; background: #fff !important; break-inside: avoid; }
  .s-value, .td-total { color: #000 !important; }
  .s-label, .s-sub, th { color: #666 !important; }
  td { color: #333 !important; border-color: #eee !important; }
  .bar-tooltip { display: none !important; }
  .content { max-width: 100%; padding: 10px; }
  .summary-row { grid-template-columns: repeat(4, 1fr); }
  .bar { cursor: default; }
  .donut-legend .dl-label, .donut-legend .dl-value { color: #333 !important; }
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .summary-row { grid-template-columns: 1fr 1fr; }
  .s-value { font-size: 20px; }
  .filter-bar { padding: 10px 14px; }
  .content { padding: 14px; }
  .donut-wrap { flex-direction: column; }
  .quick-btns { margin-left: 0; width: 100%; }
  .detail-tools { width: 100%; }
}
