/* ================= Base ================= */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1c2433;
  --muted: #6b7688;
  --line: #e4e8f0;
  --brand: #1f6feb;
  --brand-d: #1657bd;
  --sales: #2563eb;
  --ar: #d97706;
  --faktur: #059669;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 6px 20px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
}
h1, h3 { margin: 0 0 .4rem; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.b { font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; }
code { background: #eef1f7; padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* ================= Buttons ================= */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .5rem .9rem; border-radius: 9px; cursor: pointer; font-size: 14px;
  font-weight: 600; transition: .12s; white-space: nowrap;
}
.btn:hover { border-color: #c7cede; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: .3rem .6rem; font-size: 13px; }
.btn.xs { padding: .15rem .45rem; font-size: 13px; line-height: 1; }

/* ================= Auth ================= */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { background: var(--panel); width: 100%; max-width: 420px; border-radius: 16px;
  box-shadow: var(--shadow); padding: 1.75rem; }
.brand { display: flex; gap: .9rem; align-items: center; margin-bottom: 1.2rem; }
.brand h1 { font-size: 1.25rem; }
.brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #4f9bff); color: #fff; font-weight: 800; font-size: 18px;
}
.brand-logo.sm { width: 34px; height: 34px; font-size: 14px; border-radius: 9px; }

.form { display: flex; flex-direction: column; gap: .85rem; margin-top: 1rem; }
.form label, .form-row label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: 13px; }
input, select {
  font: inherit; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(31,111,235,.25); border-color: var(--brand); }
.hint { color: var(--muted); font-size: 12px; margin: .2rem 0 0; }

.info-box { margin: 1rem 0; font-size: 13.5px; }
.info-box h3 { font-size: 1.05rem; }
.info-box ol { margin: .5rem 0; padding-left: 1.3rem; }
.info-box li { margin-bottom: .35rem; }
.info-box code { word-break: break-all; }

/* ================= Tabs ================= */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: .5rem; }
.tab {
  border: none; background: none; padding: .6rem .9rem; cursor: pointer; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.pill { background: var(--danger); color: #fff; border-radius: 20px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.page-tabs { margin-bottom: 1rem; }

/* ================= Topbar ================= */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); padding: .7rem 1.2rem; box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: .7rem; }
.topbar-left strong { display: block; }
.topbar-left .sub { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.who small { color: var(--muted); }
.badge { padding: .2rem .6rem; border-radius: 20px; font-size: 12px; font-weight: 700; color: #fff; }
.badge-sales { background: var(--sales); }
.badge-ar { background: var(--ar); }
.badge-faktur { background: var(--faktur); }

/* ================= Content / panels ================= */
.content { max-width: 1200px; margin: 1.4rem auto; padding: 0 1.2rem; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem; margin-bottom: 1.2rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 780px) { .grid-2, .form-row { grid-template-columns: 1fr; } }

/* ================= Item search ================= */
.search { margin-bottom: .6rem; }
.item-results { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.item-row {
  display: grid; grid-template-columns: 130px 1fr auto; gap: .6rem; align-items: center;
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: .45rem .6rem; cursor: pointer; font: inherit;
}
.item-row:hover { border-color: var(--brand); background: #f6f9ff; }
.ir-code { font-weight: 700; font-size: 12.5px; }
.ir-desc { color: var(--ink); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ir-price { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ================= Tables ================= */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.grid-table th, .grid-table td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
.grid-table th { background: #f7f9fc; color: var(--muted); font-size: 12px; white-space: nowrap; }
.grid-table .wide { min-width: 200px; }
.grid-table input { padding: .35rem .45rem; border-radius: 7px; }
.grid-table input.n { width: 96px; text-align: right; }
.grid-table input.s { width: 96px; }
.grid-table input.xs { width: 60px; text-align: right; }
.grid-table tfoot td { border: none; padding-top: .5rem; }
.total { color: var(--brand); font-size: 15px; }
.submit-row { margin-top: .9rem; text-align: right; }

.orders th, .orders td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.orders th { background: #f7f9fc; color: var(--muted); font-size: 12px; }
.orders tr.orow:hover { background: #fafbff; }

/* ================= Status ================= */
.status { padding: .18rem .55rem; border-radius: 20px; font-size: 11.5px; font-weight: 700; display: inline-block; }
.status-pending { background: #fef3c7; color: #92610a; }
.status-approved { background: #dbeafe; color: #1e40af; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-entered { background: #d1fae5; color: #065f46; }
.status-processing { background: #e0e7ff; color: #3730a3; }
.status-error { background: #fee2e2; color: #991b1b; }

/* ================= Banner status agent otomasi (layar Faktur) ================= */
.agent-banner {
  border-radius: 10px; padding: .7rem .9rem; margin-bottom: 1rem;
  font-size: 13px; line-height: 1.5; border: 1px solid transparent;
}
.agent-banner code { background: rgba(0,0,0,.06); padding: 0 .3rem; border-radius: 4px; }
.agent-banner.ok   { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.agent-banner.warn { background: #fffbeb; border-color: #fde68a; color: #92610a; }
.agent-banner.err  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ================= Detail ================= */
.detail-row td { background: #f8fafc; padding: 0; }
.detail { padding: 1rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 1.2rem; margin-bottom: .8rem; font-size: 13px; }
.detail-table { background: #fff; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: .9rem; }
.detail-actions .note { flex: 1; min-width: 220px; }
.history { margin-top: 1rem; font-size: 13px; }
.history ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.history li { margin-bottom: .2rem; }

/* ================= Toast ================= */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1c2433; color: #fff; padding: .7rem 1.1rem; border-radius: 10px;
  box-shadow: var(--shadow); opacity: 0; transition: .3s; z-index: 100; font-weight: 600; font-size: 13.5px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }

/* --- Penanda lingkungan (hanya tampil di STAGING / LAN) ------------------ */
.env-banner {
  padding: .5rem 1rem;
  font-size: .85rem;
  text-align: center;
  border-bottom: 1px solid transparent;
  /* garis diagonal: terbaca sebagai "bukan yang asli" bahkan dari sudut mata */
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 10px,
    rgba(0, 0, 0, .045) 10px, rgba(0, 0, 0, .045) 20px
  );
}
.env-banner b { letter-spacing: .06em; }
.env-banner.staging { background-color: #fef3c7; border-color: #fcd34d; color: #92610a; }
.env-banner.lan     { background-color: #e0f2fe; border-color: #7dd3fc; color: #075985; }
