/* Font lokal (tidak butuh internet) - Plus Jakarta Sans, lisensi SIL OFL */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/plus-jakarta-sans-latin.woff2") format("woff2");
  font-weight: 400 800; font-style: normal; font-display: swap;
}
:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-l: #eef2ff;
  --danger: #dc2626;
  --sidebar: #0f172a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* ---------- Buttons & form ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

label { display: block; font-weight: 600; font-size: 12px; color: #334155; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
input[readonly] { background: #f8fafc; color: var(--muted); }
textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.req::after { content: " *"; color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Status badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-belum-dikerjakan { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.st-otw-lokasi       { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.st-proses-instalasi { background: #ede9fe; color: #6d28d9; border-color: #ddd6fe; }
.st-kendala          { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.st-pending          { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.st-selesai          { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.st-cancel           { background: #e5e7eb; color: #374151; border-color: #d1d5db; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--primary-l); color: var(--primary); font-weight: 700; }
.role-badge.admin { background: #fef3c7; color: #92400e; }
.off-badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #fee2e2; color: #b91c1c; font-weight: 700; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #c7d2fe 0, transparent 40%), radial-gradient(circle at 90% 90%, #ddd6fe 0, transparent 45%), var(--bg);
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px; }
.login-card .logo { width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: #fff; display: grid; place-items: center; margin-bottom: 16px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 4px 0 22px; }
.login-card .field { margin-bottom: 14px; }
.alert { padding: 10px 12px; border-radius: 8px; background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; margin-bottom: 14px; font-size: 13px; }

/* ---------- Admin layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #cbd5e1; padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 22px; color: #fff; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.brand b { display: block; font-size: 14px; }
.brand span { font-size: 11px; color: #94a3b8; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin-bottom: 4px; border: 0;
  border-radius: 8px; background: transparent; color: #cbd5e1; font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav button.active { background: var(--primary); color: #fff; }
.nav svg, .ico { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .me { margin-top: auto; padding: 12px; border-radius: 10px; background: rgba(255, 255, 255, .05); font-size: 12px; }
.sidebar .me b { color: #fff; display: block; font-size: 13px; }
.sidebar .me .row { display: flex; gap: 6px; margin-top: 10px; }
.sidebar .me .btn { background: transparent; color: #cbd5e1; border-color: rgba(255, 255, 255, .15); flex: 1; }
.sidebar .me .btn:hover { background: rgba(255, 255, 255, .08); }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 28px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; }
.content { padding: 24px 28px 40px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: #15803d; background: #dcfce7; padding: 5px 11px; border-radius: 999px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; animation: pulse 1.6s infinite; }
.live.off { color: #b91c1c; background: #fee2e2; }
.live.off i { background: #dc2626; animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .6); } 70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }
.menu-toggle { display: none; }

/* ---------- Cards & tables ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 16px 18px; }
/* ---------- Kartu ringkasan dashboard ---------- */
.stats, .aging-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.aging-row { margin-bottom: 22px; }
.stat, .aging-tile {
  --c: var(--primary);
  position: relative; display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 12px 14px 11px; border-radius: 12px; background: #fff; border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04); cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.stat:hover, .aging-tile:hover { transform: translateY(-2px); border-color: #d6dcf5; box-shadow: 0 8px 22px rgba(15, 23, 42, .08); }
.stat .label, .aging-tile .label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .dot, .aging-tile .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.stat .val, .aging-tile .val { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.zero .val, .aging-tile.zero .val { color: #cbd5e1; }
.stat .meta, .aging-tile .meta { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.share { height: 3px; border-radius: 99px; background: #f1f5f9; overflow: hidden; margin-top: 6px; }
.share i { display: block; height: 100%; border-radius: 99px; background: var(--c); transition: width .4s; }

.stat.total { grid-row: span 2; justify-content: space-between; color: #fff; border: 0; padding: 18px 20px;
  background: radial-gradient(circle at 100% 0, rgba(255, 255, 255, .18), transparent 45%), linear-gradient(140deg, #4f46e5, #7c3aed); box-shadow: 0 10px 24px rgba(79, 70, 229, .28); }
.stat.total .label { color: #e0e7ff; font-size: 13px; }
.stat.total .val { color: #fff; font-size: 36px; margin-top: 4px; }
.stat.total .split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.stat.total .split div { background: rgba(255, 255, 255, .14); border-radius: 10px; padding: 7px 10px; font-size: 11.5px; color: #e0e7ff; }
.stat.total .split b { display: block; color: #fff; font-size: 15px; font-variant-numeric: tabular-nums; }
.stat.total .share { background: rgba(255, 255, 255, .2); }
.stat.total .share i { background: #a7f3d0; }
.stat.today { background: #f8fafc; border-style: dashed; }
.stat.today .val { color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 20px; }
#mitraRekap th, #mitraRekap td { padding: 10px 8px; }
#mitraRekap th:first-child, #mitraRekap td:first-child { padding-left: 16px; }
#mitraRekap .progress { width: 56px; min-width: 50px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
tbody tr:hover { background: #fafbff; }
td.num, th.num { text-align: center; }
td .sub { font-size: 12px; color: var(--muted); }
.ket-cell { max-width: 240px; font-size: 12.5px; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
tr.flash { animation: flash 2.5s ease-out; }
@keyframes flash { 0%, 30% { background: #fef9c3; } 100% { background: transparent; } }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }
.progress { height: 6px; border-radius: 99px; background: #e2e8f0; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; background: #16a34a; }

.seg { display: inline-flex; background: #f1f5f9; border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 6px; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.tim-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 5px; background: #ecfeff; color: #0e7490; border: 1px solid #cffafe; margin: 1px 2px 1px 0; }

/* ---------- Aging ---------- */
.aging { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 6px; white-space: nowrap; border: 1px solid transparent; }
.aging.ag-0 { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.aging.ag-1 { background: #fef9c3; color: #a16207; border-color: #fde68a; }
.aging.ag-2 { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.aging.ag-3 { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.aging-row .title { display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 2px; min-width: 0; }
.aging-row .title .ico-box { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #fff7ed; color: #ea580c; flex-shrink: 0; }
.aging-row .title .ico-box svg { width: 16px; height: 16px; }
.aging-row .title b { display: block; font-size: 14px; }
.aging-row .title span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
.aging-tile.ag-0 { --c: #16a34a; } .aging-tile.ag-1 { --c: #ca8a04; }
.aging-tile.ag-2 { --c: #ea580c; } .aging-tile.ag-3 { --c: #dc2626; }
.aging-tile:not(.zero) .val { color: var(--c); }
.aging-tile.ag-3:not(.zero) { background: #fffafa; border-color: #fecaca; }

@media (max-width: 1150px) {
  .stats, .aging-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat.total { grid-row: auto; grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 360px); justify-content: start; align-items: center; column-gap: 28px; padding: 14px 18px; }
  .stat.total .label, .stat.total .val { grid-column: 1; }
  .stat.total .split { grid-column: 2; grid-row: 1 / span 2; margin-top: 0; }
  .stat.total .share { grid-column: 1 / -1; }
  .aging-row .title { grid-column: 1 / -1; padding: 0; }
}
@media (max-width: 640px) {
  .stats, .aging-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat.total { display: flex; align-items: stretch; }
  .stat.total .val { font-size: 32px; }
  .stat .val, .aging-tile .val { font-size: 22px; }
}

/* ---------- Feed / timeline ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-l); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.feed .txt { flex: 1; min-width: 0; }
.feed .txt p { margin: 3px 0 0; font-size: 13px; word-wrap: break-word; }
.feed .time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.feed li.new { animation: flash 2.5s ease-out; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); }
.timeline .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.timeline p { margin: 5px 0 0; font-size: 13px; background: #f8fafc; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; word-wrap: break-word; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.info-grid > div > span:first-child { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.info-grid div b { font-weight: 600; word-wrap: break-word; }
.info-grid .full { grid-column: 1 / -1; }
.section-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 12px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); animation: pop .18s; }
.modal.lg { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 14px 14px; }
.x { border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 36px); }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-size: 13px; width: 340px; max-width: 100%; animation: slide .25s; border-left: 4px solid var(--primary); }
.toast.ok { border-left-color: #22c55e; }
.toast.err { border-left-color: #ef4444; }
.toast.warn { border-left-color: #f59e0b; }
.toast b { display: block; margin-bottom: 2px; }
@keyframes slide { from { opacity: 0; transform: translateX(30px); } }

/* ---------- Tombol ikon (Detail / Edit / Hapus) ---------- */
.icon-btn { position: relative; width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #475569; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--primary-l); border-color: #c7d2fe; color: var(--primary); }
.icon-btn.danger { color: #dc2626; }
.icon-btn.danger:hover { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.icon-btn.warn:hover { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.icon-btn.ok { color: #16a34a; }
.icon-btn.ok:hover { background: #f0fdf4; border-color: #bbf7d0; }
.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
/* tooltip */
.icon-btn[data-tip]::after { content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); background: #0f172a; color: #fff; font-size: 11.5px; font-weight: 600; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s; z-index: 6; }
.icon-btn[data-tip]:hover::after, .icon-btn[data-tip]:focus-visible::after { opacity: 1; transform: none; }
th.c-act { text-align: right; }
td.c-act { width: 1%; white-space: nowrap; vertical-align: middle; }

/* ---------- Tabel Data PA ---------- */
.nowrap { white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pa-table tr.row-click { cursor: pointer; }
.pa-table tbody tr:hover td { background: #f8faff; }
.pa-table .no-pa { font-weight: 800; white-space: nowrap; letter-spacing: .01em; }
.pa-table .c-plg { min-width: 180px; max-width: 280px; }
.pa-table .plg-nama { font-weight: 600; }
.pa-table .disp { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.pa-table .st-aging { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.pa-table .ket-cell { min-width: 170px; max-width: 260px; }
.pa-table .ket-cell .sub { margin-top: 3px; }

/* HP / tablet kecil: tiap PA tampil sebagai kartu */
@media (max-width: 820px) {
  .pa-table thead { display: none; }
  .pa-table, .pa-table tbody { display: block; }
  .pa-table tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .pa-table td { display: block; border: 0; padding: 0; max-width: none; min-width: 0; white-space: normal; }
  .pa-table td.c-no { grid-column: 1; grid-row: 1; }
  .pa-table td.c-act { grid-column: 2; grid-row: 1; width: auto; }
  .pa-table td[data-label] { grid-column: 1 / -1; display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
  .pa-table td[data-label]::before { content: attr(data-label); font-size: 11.5px; font-weight: 700; color: var(--muted); padding-top: 2px; }
  .pa-table td[data-label] > * { grid-column: 2; justify-self: start; max-width: 100%; }
  .pa-table td[data-label] .sub { margin-top: 0; }
  .pa-table td.empty { grid-column: 1 / -1; display: block; }
  .pa-table tbody tr:hover td { background: transparent; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn[data-tip]::after { display: none; }
}

/* ---------- Teknisi (mobile-first) ---------- */
.tk-body { -webkit-tap-highlight-color: transparent; }
.tk-header { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; padding: calc(14px + env(safe-area-inset-top)) 16px 60px; }
.tk-header .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; max-width: 1096px; margin: 0 auto; }
.tk-header .who { min-width: 0; }
.tk-header h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-header .sub { font-size: 12.5px; color: #e0e7ff; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.tk-header .live { background: rgba(255, 255, 255, .18); color: #fff; }
.tk-header .live.off { background: #fee2e2; color: #b91c1c; }
.tk-avatar { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); background: rgba(255, 255, 255, .18); color: #fff; font: inherit; font-weight: 800; font-size: 14px; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.tk-avatar.big { width: 56px; height: 56px; font-size: 19px; background: var(--primary-l); color: var(--primary); border: 0; }
.tk-wrap { max-width: 1120px; margin: -46px auto 0; padding: 0 12px calc(40px + env(safe-area-inset-bottom)); }

/* ringkasan (3 kartu) */
.tk-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 4px; }
.sum { --tone: var(--primary); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: #fff; box-shadow: 0 4px 14px rgba(15, 23, 42, .08); cursor: pointer; font: inherit; color: var(--text); transition: transform .1s, border-color .15s, box-shadow .15s; min-width: 0; }
.sum:active { transform: scale(.98); }
.sum .sum-ico { grid-row: 1 / span 2; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: #f1f5f9; }
.sum .sum-n { font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--tone); }
.sum .sum-l { font-size: 12px; font-weight: 600; color: var(--muted); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.sum.tone-blue { --tone: #4f46e5; } .sum.tone-blue .sum-ico { background: #eef2ff; }
.sum.tone-red { --tone: #dc2626; } .sum.tone-red .sum-ico { background: #fef2f2; }
.sum.tone-green { --tone: #16a34a; } .sum.tone-green .sum-ico { background: #f0fdf4; }
.sum.tone-muted { --tone: #94a3b8; }
.sum.active { border-color: var(--tone); box-shadow: 0 0 0 2px color-mix(in srgb, var(--tone) 25%, transparent), 0 4px 14px rgba(15, 23, 42, .08); }

/* cari + filter status (menempel di atas saat scroll) */
.tk-search-wrap { position: sticky; top: 0; z-index: 4; padding: 10px 0 8px; background: var(--bg); }
.tk-search { margin: 0; padding: 11px 14px; border-radius: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.tk-pills { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; scrollbar-width: none; }
.tk-pills::-webkit-scrollbar { display: none; }
.pill { --c: #334155; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font: inherit; font-size: 12.5px; font-weight: 600; color: #334155; cursor: pointer; white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.pill b { font-size: 11.5px; font-weight: 700; color: var(--muted); background: #f1f5f9; padding: 0 6px; border-radius: 99px; }
.pill.active { background: #0f172a; border-color: #0f172a; color: #fff; }
.pill.active b { background: rgba(255, 255, 255, .15); color: #fff; }
.tk-list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 6px 2px 10px; }
.tk-list-head b { font-size: 14px; }
.tk-list-head span { font-size: 12px; color: var(--muted); }
.tk-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .tk-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }
.tk-empty { grid-column: 1 / -1; }

/* kartu PA */
.pa-card { display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); border: 1px solid var(--border); padding: 14px 14px 12px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s; position: relative; overflow: hidden; }
.pa-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: #16a34a; }
.pa-card.agb-1::before { background: #ca8a04; } .pa-card.agb-2::before { background: #ea580c; } .pa-card.agb-3::before { background: #dc2626; }
.pa-card.agb-closed::before { background: #cbd5e1; }
.pa-card.agb-closed { opacity: .85; }
@media (hover: hover) { .pa-card:hover { box-shadow: 0 8px 22px rgba(15, 23, 42, .08); border-color: #d6dcf5; } }
.pa-card.flash { animation: flash 2.5s ease-out; }
.pa-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pa-card .min0 { min-width: 0; }
.pa-card .no { font-size: 12px; font-weight: 700; color: var(--primary); letter-spacing: .02em; }
.pa-card h3 { font-size: 15.5px; font-weight: 700; margin-top: 2px; word-wrap: break-word; line-height: 1.3; }
.pa-card .addr { font-size: 13px; color: #475569; margin: 6px 0 8px; }
.pa-card .addr.empty-v { color: #94a3b8; font-style: italic; }
.pa-card .tags { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.pa-card .tags span { background: #f1f5f9; padding: 2px 8px; border-radius: 6px; color: #475569; }
.pa-card .tags .who { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.pa-card .ket { margin-top: 10px; font-size: 13px; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 10px; padding: 8px 10px; color: #334155; word-wrap: break-word; }
.pa-card .ket b { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 1px; }

/* umur: didispatch & aging progres */
.pa-age { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.age-cell { --c: #16a34a; border-radius: 10px; padding: 8px 10px; background: #f8fafc; border: 1px solid #eef2f7; min-width: 0; }
.age-cell .age-k { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.age-cell b { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); line-height: 1.3; }
.age-cell small { display: block; font-size: 11.5px; color: var(--muted); }
.age-cell.ag-0 { background: #f0fdf4; border-color: #dcfce7; } .age-cell.ag-0 b { color: #15803d; }
.age-cell.ag-1 { background: #fefce8; border-color: #fef08a; } .age-cell.ag-1 b { color: #a16207; }
.age-cell.ag-2 { background: #fff7ed; border-color: #fed7aa; } .age-cell.ag-2 b { color: #c2410c; }
.age-cell.ag-3 { background: #fef2f2; border-color: #fecaca; } .age-cell.ag-3 b { color: #b91c1c; }
.dt-top .pa-age { margin-top: 12px; }

/* tombol aksi cepat: telepon / WA / maps / update */
.pa-actions { display: flex; gap: 8px; margin-top: 12px; }
.act { flex: 1 1 0; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: center; min-width: 0; white-space: nowrap; }
.act i { font-style: normal; font-size: 15px; line-height: 1; }
.act:active { transform: scale(.97); }
.act-primary { flex: 1.6 1 0; background: var(--primary); border-color: var(--primary); color: #fff; }
@media (max-width: 420px) {
  .act { flex-direction: column; gap: 2px; font-size: 11px; min-height: 50px; }
  .act-primary span { white-space: normal; }
}
@media (max-width: 520px) {
  .tk-summary { gap: 8px; }
  .sum { grid-template-columns: 1fr; grid-template-rows: auto auto auto; padding: 10px 11px; row-gap: 2px; }
  .sum .sum-ico { grid-row: auto; width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
  .sum .sum-n { font-size: 20px; }
  .sum .sum-l { font-size: 11px; }
}

/* detail PA */
.dt-top { text-align: left; }
.dt-top h2 { font-size: 19px; margin: 4px 0 8px; word-wrap: break-word; }
.dt-no { border: 0; background: var(--primary-l); color: var(--primary); font: inherit; font-weight: 800; font-size: 13px; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.dt-no small { font-weight: 600; opacity: .75; }
.dt-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dt-note { margin-top: 12px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 10px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; }
.dt-note b { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.dt-info { margin-top: 18px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; }
.dt-info summary { cursor: pointer; font-weight: 800; font-size: 13px; padding: 12px 0; color: #334155; }
.dt-info[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.dt-info .info-grid { padding-bottom: 12px; }

.status-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.status-pick button { --c: var(--primary); display: flex; align-items: center; gap: 8px; border: 2px solid var(--border); background: #fff; border-radius: 12px; padding: 12px 10px; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; text-align: left; color: var(--text); min-height: 48px; }
.status-pick button::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.status-pick button.sel { border-color: var(--c); color: var(--c); background: #f8fafc; box-shadow: inset 0 0 0 1px var(--c); }
.ket-tpl { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; scrollbar-width: none; }
.ket-tpl::-webkit-scrollbar { display: none; }
.ket-tpl button { flex-shrink: 0; border: 1px solid var(--border); background: #f1f5f9; color: #334155; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.ket-tpl button:active { background: var(--primary-l); border-color: var(--primary); color: var(--primary); }

/* akun */
.acct { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.acct b { display: block; font-size: 16px; }
.acct span { display: block; font-size: 12.5px; color: var(--muted); }
.acct-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.acct-list button { text-align: left; border: 1px solid var(--border); background: #fff; border-radius: 12px; padding: 14px; font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--text); }
.acct-list button.danger { color: var(--danger); }

/* layar HP: detail jadi layar penuh, tombol Kirim selalu terlihat di bawah */
@media (max-width: 640px) {
  .modal-bg.sheet-bg { padding: 0; background: #fff; }
  .modal.sheet { max-width: none; min-height: 100%; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; animation: none; }
  .modal.sheet .modal-head { position: sticky; top: 0; z-index: 3; background: #fff; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
  .modal.sheet .modal-body { flex: 1; padding: 16px; }
  .modal.sheet .modal-foot { position: sticky; bottom: 0; z-index: 3; border-radius: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(15, 23, 42, .08); }
  .modal.sheet .btn-close { display: none; }
  .modal.sheet .btn-send { flex: 1; justify-content: center; padding: 14px; font-size: 15px; border-radius: 12px; }
  .modal.sheet .info-grid { grid-template-columns: 1fr 1fr; }
  .modal.sheet .info-grid .full { grid-column: 1 / -1; }
  /* cegah zoom otomatis iOS saat fokus input */
  .tk-body input, .tk-body textarea, .tk-body select { font-size: 16px; }
  #toasts { left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: none; }
  .toast { width: auto; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1440px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > * { min-width: 0; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .menu-toggle { display: inline-flex; }
  .topbar, .content { padding-left: 14px; padding-right: 14px; }
  .form-grid, .info-grid { grid-template-columns: 1fr; }
  .modal-bg { padding: 12px 8px; }
  .toolbar input[type=search], .toolbar select { max-width: none; width: 100%; }
  .toolbar select { width: calc(50% - 5px); }
}

/* ===== Mode lihat-saja (role manager) ===== */
body.ro [data-edit-pa], body.ro [data-del-pa],
body.ro [data-edit-mitra], body.ro [data-del-mitra],
body.ro [data-edit-tim], body.ro [data-del-tim],
body.ro [data-edit-user], body.ro [data-del-user],
body.ro [data-add-tim-mitra], body.ro [data-toggle-user],
body.ro #btnAddPA, body.ro #btnImport, body.ro #btnAddTim,
body.ro #btnAddMitra, body.ro #btnAddUser,
body.ro #admProg, body.ro #admProgTitle, body.ro #admProgSave,
body.ro #dlTpl, body.ro #impGo,
body.ro .c-act { display: none !important; }
body.ro .ro-note { display: flex; }
.ro-note {
  display: none; align-items: center; gap: 8px;
  padding: 10px 14px; margin: 0 0 14px; border-radius: 10px;
  background: #eef2ff; border: 1px solid #c7d2fe;
  color: #3730a3; font-size: 13px; font-weight: 600;
}
.role-badge.manager { background: #eef2ff; color: #3730a3; }
