/* Warna merek Tetra (dari logo): biru cyan, oranye, kuning */
:root {
  --brand: #0e86c2;
  --brand-2: #19a6da;
  --brand-3: #3ac6f3;
  --brand-dark: #0a5f8f;
  --accent: #f68620;
  --accent-2: #f9b21c;
  --bg: #f1f8fc;
  --card: #ffffff;
  --text: #1c2730;
  --muted: #64727d;
  --line: #dde3e8;
  --ok: #1e8a4c;
  --ok-bg: #e5f5ec;
  --warn: #b26b00;
  --warn-bg: #fdf1dc;
  --bad: #c0392b;
  --bad-bg: #fbe7e5;
  --info-bg: #e6f0f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 2px 8px rgba(16, 32, 48, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 105% -8%, rgba(58, 198, 243, .22), transparent 62%),
    radial-gradient(800px 460px at -12% 108%, rgba(246, 134, 32, .14), transparent 60%),
    radial-gradient(600px 380px at 55% 115%, rgba(249, 178, 28, .12), transparent 62%),
    linear-gradient(180deg, #f3fafe 0%, #eef6fb 100%);
  background-attachment: fixed;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
small, .muted { color: var(--muted); }
img { max-width: 100%; }

/* ---------- layout */
.topbar {
  position: sticky; top: 0; z-index: 20; color: #fff;
  background: linear-gradient(100deg, var(--brand-dark) 0%, var(--brand) 45%, var(--brand-2) 100%);
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 60%, var(--brand-3) 100%) 1;
  box-shadow: 0 2px 10px rgba(10, 95, 143, .25);
  display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; color: #fff; letter-spacing: .2px; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand img { width: 30px; height: 30px; background: #fff; border-radius: 8px; padding: 2px; }
.topbar .brand span { color: var(--accent-2); }
.topbar nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: #e3f4fc; padding: .35rem .6rem; border-radius: 6px; font-size: .92rem; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255, 255, 255, .2); color: #fff; text-decoration: none; }
.topbar nav a.active { box-shadow: inset 0 -2px 0 var(--accent-2); }
.topbar .who { font-size: .85rem; color: #e3f4fc; display: flex; align-items: center; gap: .5rem; }
.topbar .who button { background: transparent; border: 1px solid rgba(255, 255, 255, .4); color: #fff; padding: .2rem .55rem; border-radius: 6px; cursor: pointer; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
main.narrow { max-width: 640px; }

@media (max-width: 720px) {
  .topbar { padding: .5rem .75rem; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .topbar nav a { white-space: nowrap; }
  .topbar .who .name { display: none; }
  main { padding: .75rem; }
}

/* ---------- cards & grid */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; border: 1px solid rgba(25, 166, 218, .08); }
h1 { color: var(--brand-dark); }
.card.tight { padding: .75rem; }
.grid { display: grid; gap: .75rem; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpi .tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem .9rem; border-top: 4px solid var(--brand-2); }
.kpi .tile:nth-child(4n+2) { border-top-color: var(--accent); }
.kpi .tile:nth-child(4n+3) { border-top-color: var(--accent-2); }
.kpi .tile:nth-child(4n+4) { border-top-color: #2bb673; }
.kpi .tile .label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .tile .value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; }
.kpi .tile .sub { font-size: .82rem; color: var(--muted); }
.kpi .tile.bad .value { color: var(--bad); }
.kpi .tile.ok .value { color: var(--ok); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.right { text-align: right; }
.hide { display: none !important; }

/* ---------- forms */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }
input[type=checkbox], input[type=radio] { width: auto; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; align-items: end; }
.filters .actions { display: flex; gap: .4rem; }
.field { margin-bottom: .7rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .55rem .95rem; border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover { background: var(--info-bg); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; padding: .85rem; font-size: 1.05rem; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); background: #fafbfc; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr:hover td { background: #fafcfd; }

/* ---------- badges & alerts */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--info-bg); color: var(--brand); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.grey { background: #eceff1; color: #546e7a; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--info-bg); }
.alert.warn { background: var(--warn-bg); color: #6b4400; }
.alert.bad { background: var(--bad-bg); color: #7b1d13; }
.alert.ok { background: var(--ok-bg); color: #145c33; }
.flags { list-style: none; padding: 0; margin: 0; }
.flags li { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.flags li:last-child { border-bottom: 0; }

.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.chips a { padding: .3rem .7rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: .88rem; }
.chips a.active { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; border-color: var(--brand); }

/* ---------- mobile frontliner */
.list-item { display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .75rem .9rem; margin-bottom: .55rem; color: var(--text); border-left: 4px solid var(--brand-2); }
.list-item:hover { text-decoration: none; background: #fbfdfe; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: .84rem; color: var(--muted); }
.gps-status { padding: .6rem .8rem; border-radius: 8px; background: #eceff1; font-size: .9rem; margin-bottom: .7rem; }
.gps-status.ok { background: var(--ok-bg); color: #145c33; }
.gps-status.warn { background: var(--warn-bg); color: #6b4400; }
.gps-status.bad { background: var(--bad-bg); color: #7b1d13; }
.photo-input { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; background: #fafbfc; }
.photo-input img { max-height: 220px; border-radius: 8px; margin-top: .5rem; }
.stock-row { display: grid; grid-template-columns: 1fr 80px; gap: .5rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.stock-row .oos { grid-column: 1 / -1; display: flex; gap: .5rem; align-items: center; }
.stock-row .oos select { flex: 1; }
.stock-row.is-oos .pname { color: var(--bad); }
.sticky-bottom { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 25%); padding: 1rem 0 .5rem; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
.photos figure { margin: 0; }
.photos img { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photos figcaption { font-size: .78rem; color: var(--muted); }

.chart-box { position: relative; height: 280px; }
.pager { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; margin-top: .8rem; }

#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 50; max-width: 92vw;
  background: #263238; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--shadow); display: none; }
#toast.bad { background: var(--bad); }
#toast.ok { background: var(--ok); }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; position: relative; overflow: hidden;
  background: linear-gradient(150deg, var(--brand-dark) 0%, var(--brand) 42%, var(--brand-2) 72%, var(--brand-3) 100%);
}
/* Bentuk tegas ala logo Tetra: blok oranye & kuning, panel biru muda miring */
.login-wrap::before, .login-wrap::after { content: ""; position: absolute; pointer-events: none; }
.login-wrap::before {
  width: 340px; height: 340px; right: -110px; top: -110px; border-radius: 48px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--accent) 0 50%, var(--accent-2) 50% 100%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
}
.login-wrap::after {
  width: 520px; height: 520px; left: -260px; bottom: -300px; border-radius: 64px; transform: rotate(45deg);
  background: rgba(58, 198, 243, .45);
}
.login-card { position: relative; z-index: 1; width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 1.6rem; box-shadow: 0 18px 50px rgba(6, 50, 80, .35); border-top: 5px solid var(--accent); }
.login-card .logo { font-size: 1.4rem; font-weight: 800; color: var(--brand-dark); display: flex; align-items: center; gap: .6rem; }
.login-card .logo img { width: 52px; height: 52px; }
.login-card .logo span { color: var(--accent); }

.qr-print { text-align: center; padding: 2rem; }
.qr-print img { width: 320px; height: 320px; }
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
