/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --blue:   #1d4ed8;
  --lblue:  #eff6ff;
  --green:  #16a34a;
  --lgreen: #f0fdf4;
  --red:    #dc2626;
  --lred:   #fef2f2;
  --amber:  #d97706;
  --lamber: #fffbeb;
  --gray:   #6b7280;
  --lgray:  #f9fafb;
  --border: #e5e7eb;
  --text:   #111827;
  --radius: 10px;
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f3f4f6;
  color: var(--text);
  font-size: 14px;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(90deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(2,6,23,.3);
  position: sticky;
  top: 0;
  z-index: 30;
}
header h1 { font-size: 1.25rem; font-weight: 700; }
header p  { font-size: .78rem; opacity: .8; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
main { margin: 0 20px 0 84px; padding: 20px 0 40px; transition: margin-left .22s ease; }

/* ── Sidebar (collapsed by default, expands on hover) ─────────────────────────── */
:root {
  --navy:      #0b1730;
  --navy-2:    #13234a;
  --navy-ac:   #2563eb;
  --sb-collapsed: 64px;
  --sb-expanded:  230px;
}

.sidebar {
  position: fixed;
  top: 86px;
  bottom: 20px;
  left: 20px;
  width: var(--sb-collapsed);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(2,6,23,.35), 0 2px 6px rgba(2,6,23,.2);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 20;
  overflow: hidden;
  backdrop-filter: blur(0px);
  transition: width .22s ease, box-shadow .22s ease, background .22s ease, backdrop-filter .22s ease;
}
.sidebar:hover {
  width: var(--sb-expanded);
  background: linear-gradient(180deg, rgba(11,23,48,.65) 0%, rgba(19,35,74,.65) 100%);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 20px 44px rgba(2,6,23,.45), 0 2px 6px rgba(2,6,23,.25);
}

.sidebar-title {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 4px 10px 10px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s ease;
}
.sidebar:hover .sidebar-title { opacity: 1; transition: opacity .2s ease .08s; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: .86rem;
  font-weight: 600;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s, transform .1s;
}
.sidebar-item .si-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}
.sidebar-item .si-icon svg { width: 18px; height: 18px; }
.sidebar-item .si-label {
  opacity: 0;
  transition: opacity .12s ease;
}
.sidebar:hover .sidebar-item .si-label { opacity: 1; transition: opacity .2s ease .08s; }

.sidebar-item:hover        { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-item:active       { transform: scale(.98); }
.sidebar-item.active       {
  background: linear-gradient(90deg, var(--navy-ac), #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
}
.sidebar-item.disabled     { color: rgba(255,255,255,.28); cursor: default; }
.sidebar-item.disabled:hover { background: none; color: rgba(255,255,255,.28); }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto !important; margin: 16px 16px 0; bottom: auto; flex-direction: row; overflow-x: auto; box-shadow: 0 10px 30px rgba(2,6,23,.35); }
  .sidebar-title { display: none; }
  .sidebar-item .si-label { opacity: 1; }
  main { margin: 0 !important; padding: 20px 16px 40px !important; }
}

/* ── Views (single-page navigation) ────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 22px;
  margin-bottom: 16px;
}

/* ── Upload Grid ─────────────────────────────────────────────────────────────── */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .upload-grid { grid-template-columns: 1fr; } }

.upload-col h3 {
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Drop Zone ───────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 8px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover,
.drop-zone.drag-over { border-color: var(--blue); background: var(--lblue); }
.drop-zone.has-file  { border-color: var(--green); background: var(--lgreen); }
.drop-zone input[type=file] { display: none; }
.drop-zone .dz-icon  { font-size: 1.8rem; margin-bottom: 6px; }
.drop-zone .dz-title { font-size: .85rem; font-weight: 600; }
.drop-zone .dz-sub   { font-size: .75rem; color: var(--gray); margin-top: 2px; }
.drop-zone .dz-fname { margin-top: 8px; font-size: .78rem; font-weight: 600; color: var(--green); }

/* ── Loading Bar ─────────────────────────────────────────────────────────────── */
.loading-bar {
  display: none;
  height: 3px;
  background: linear-gradient(90deg, var(--blue) 0%, #60a5fa 50%, var(--blue) 100%);
  background-size: 200%;
  animation: shimmer 1.2s infinite;
  border-radius: 2px;
  margin-top: 8px;
}
@keyframes shimmer {
  0%   { background-position: 200%; }
  100% { background-position: -200%; }
}

/* ── Preview Table ───────────────────────────────────────────────────────────── */
.preview-section { margin-top: 12px; }
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.preview-header .preview-label { font-size: .8rem; font-weight: 600; color: var(--gray); }
.preview-header .preview-count {
  font-size: .78rem;
  background: var(--lblue);
  color: var(--blue);
  padding: 2px 8px;
  border-radius: 12px;
}

.preview-wrap {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.preview-wrap table       { width: 100%; border-collapse: collapse; font-size: .75rem; }
.preview-wrap th          { background: var(--lgray); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.preview-wrap td          { padding: 5px 8px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.preview-wrap tr:last-child td { border-bottom: none; }
.preview-wrap tr:hover td { background: #fafafa; }
.preview-empty            { text-align: center; padding: 20px; color: var(--gray); font-size: .8rem; }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pill      { display: inline-block; padding: 1px 6px; border-radius: 10px; font-size: .68rem; font-weight: 600; }
.pill-in   { background: #dcfce7; color: #15803d; }
.pill-out  { background: #fee2e2; color: #b91c1c; }
.pill-ok   { background: #d1fae5; color: #059669; }
.pill-diff { background: var(--lamber); color: var(--amber); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary          { background: var(--blue); color: #fff; }
.btn-primary:hover    { opacity: .9; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-outline          { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover    { background: var(--lgray); }

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alert ───────────────────────────────────────────────────────────────────── */
.alert      { padding: 10px 14px; border-radius: 8px; font-size: .83rem; display: none; margin-top: 12px; }
.alert-err  { background: var(--lred);  color: var(--red);  border: 1px solid #fecaca; display: block; }
.alert-info { background: var(--lblue); color: var(--blue); border: 1px solid #bfdbfe; display: block; }

/* ── Summary Cards ───────────────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card          { border-radius: 8px; padding: 14px 16px; }
.stat-card .s-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.stat-card .s-val   { font-size: 1.4rem; font-weight: 700; }
.stat-card .s-sub   { font-size: .72rem; margin-top: 2px; }
.card-matched { background: var(--lgreen); color: var(--green); border: 1px solid #bbf7d0; }
.card-gl      { background: var(--lamber); color: var(--amber); border: 1px solid #fde68a; }
.card-bs      { background: var(--lred);   color: var(--red);   border: 1px solid #fecaca; }
.card-total   { background: var(--lblue);  color: var(--blue);  border: 1px solid #bfdbfe; }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 7px 16px;
  border: none;
  background: none;
  font-size: .83rem;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab.active             { color: var(--blue); border-bottom-color: var(--blue); }
.tab-badge              { background: var(--border); border-radius: 12px; padding: 1px 6px; font-size: .68rem; margin-left: 3px; }
.tab.active .tab-badge  { background: var(--lblue); color: var(--blue); }
.tab-panel              { display: none; }
.tab-panel.active       { display: block; }

/* ── Result Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.main-tbl           { width: 100%; border-collapse: collapse; font-size: .78rem; }
table.main-tbl th        { background: var(--lgray); font-weight: 600; text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.main-tbl td        { padding: 6px 9px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
table.main-tbl tr:hover td { background: #fafafa; }

.empty-state     { text-align: center; padding: 36px 20px; color: var(--gray); font-size: .85rem; }
.empty-state .ei { font-size: 2rem; margin-bottom: 6px; }

/* ── Results Section ─────────────────────────────────────────────────────────── */
#results { display: none; }

/* ── COA Reconciliation ─────────────────────────────────────────────────────── */
.coa-search {
  width: 100%;
  max-width: 320px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .8rem;
  margin-bottom: 10px;
  font-family: inherit;
}
.coa-search:focus { outline: none; border-color: var(--blue); }

.sel-type {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .76rem;
  font-family: inherit;
  background: #fff;
  cursor: pointer;
}
.sel-type.type-ar  { border-color: #93c5fd; color: #1d4ed8; background: var(--lblue);  }
.sel-type.type-ap  { border-color: #fcd34d; color: #b45309; background: var(--lamber); }
.sel-type.type-rev { border-color: #86efac; color: #15803d; background: var(--lgreen); }
.sel-type.type-exp { border-color: #fca5a5; color: #b91c1c; background: var(--lred);   }

.pill-ar  { background: var(--lblue);  color: var(--blue);  }
.pill-ap  { background: var(--lamber); color: var(--amber); }
.pill-rev { background: var(--lgreen); color: var(--green); }
.pill-exp { background: var(--lred);   color: var(--red);   }

.ref-link { color: var(--blue); text-decoration: none; font-weight: 600; cursor: pointer; }
.ref-link:hover { text-decoration: underline; }

/* ── Journal Detail Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2,6,23,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 840px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(2,6,23,.35);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title    { font-size: 1rem; font-weight: 700; }
.modal-subtitle { font-size: .8rem; color: var(--gray); margin-top: 2px; }
.modal-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.modal-print-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.modal-print-btn:hover { background: var(--lgray); }
.modal-close {
  background: none;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  color: var(--gray);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--lgray); color: var(--text); }
.modal-body   { padding: 16px 20px; overflow-y: auto; }
.modal-totals { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 18px; font-size: .84rem; font-weight: 600; justify-content: flex-end; }

.jm-pair-a td { background: #f0fdf4; }
.jm-pair-b td { background: #ecfdf5; }
.jm-pair-a:hover td, .jm-pair-b:hover td { background: #dcfce7; }
.jm-unmatched td { background: var(--lamber); }
.jm-unmatched:hover td { background: #fef3c7; }

.jm-bill-a td { background: #eff6ff; }
.jm-bill-b td { background: #eef2ff; }
.jm-bill-a:hover td, .jm-bill-b:hover td { background: #dbeafe; }
.jm-subtotal td { background: var(--lgray); border-top: 1px solid var(--border); border-bottom: 2px solid var(--border); }
.pill-bill { background: var(--lblue); color: var(--blue); white-space: nowrap; }

/* ── Print: Detail Jurnal (Save as PDF via browser print dialog) ─────────────── */
@media print {
  body * { visibility: hidden; }
  #journal-modal, #journal-modal * { visibility: visible; }

  #journal-modal {
    position: absolute;
    inset: 0;
    background: #fff;
    padding: 0;
    display: block !important;
    z-index: auto;
  }
  #journal-modal .modal-box {
    max-width: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
  #journal-modal .modal-body { overflow: visible; }
  #journal-modal .modal-print-btn,
  #journal-modal .modal-close { display: none !important; }
}
