* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, sans-serif; background: #f5f6f8; color: #1c2733; }
.hidden { display: none !important; }
.error { color: #b3261e; min-height: 1em; white-space: pre-wrap; }

/* login */
#login-view { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { background: #fff; padding: 32px; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,.08); width: 320px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 18px; margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.login-card input { padding: 8px 10px; border: 1px solid #c6cfd9; border-radius: 6px; }

/* header + toolbar */
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: #14304f; color: #fff; }
header h1 { font-size: 16px; margin: 0; }
.header-right { display: flex; gap: 8px; align-items: center; }
#summary-bar { padding: 8px 20px; background: #e8edf3; font-size: 13px; }
#summary-bar .sep { color: #9fb0c1; margin: 0 4px; }
/* tabs */
.tabs { display: flex; gap: 0; padding: 12px 20px 0; border-bottom: 2px solid #d9e1ea; }
.tab { background: transparent; color: #51606f; border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 10px 22px; font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: -2px; }
.tab.active { color: #14304f; border-bottom-color: #14304f; }
.tab:hover:not(.active) { color: #1c2733; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 20px; align-items: center; }
.toolbar input:not([type="checkbox"]), .toolbar select { padding: 6px 10px; border: 1px solid #c6cfd9; border-radius: 6px; }
#f-search { min-width: 220px; }
.chk { display: flex; align-items: center; gap: 4px; }

/* buttons */
button, .file-btn { padding: 7px 14px; border: 0; border-radius: 6px; background: #14304f; color: #fff; cursor: pointer; font-size: 13px; }
button.secondary, .file-btn.secondary { background: #e2e8f0; color: #1c2733; }
button.danger { background: #b3261e; }
button:disabled { opacity: .4; cursor: default; }
.file-btn { display: inline-block; }

/* admin visibility */
.admin-only { display: none; }
body.is-admin .admin-only { display: inline-block; }

/* table */
#companies { width: calc(100% - 40px); margin: 0 20px 12px; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
#companies th, #companies td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #eef1f5; }
#companies th { background: #f0f3f7; font-weight: 600; }
#companies tbody tr { cursor: pointer; }
#companies tbody tr:hover { background: #f6f9fc; }
.badge { background: #e2e8f0; border-radius: 10px; padding: 2px 8px; font-size: 12px; }
.badge.customer { background: #d1e7dd; color: #0f5132; }
.badge.personal { background: #fdebd0; color: #7a4a06; }
.badge.toko { background: #d6e4ff; color: #1d4e9e; }
.badge.dormant { background: #f8d7da; color: #842029; }

/* contact links */
a.mini { display: inline-block; background: #e2e8f0; border-radius: 6px; padding: 1px 6px; font-size: 11px; text-decoration: none; color: #14304f; font-weight: 600; }
a.mini:hover { background: #cbd7e4; }
.ro-value { padding: 6px 0; font-size: 13px; }
.ro-value a { color: #14304f; }

/* pager */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding-bottom: 24px; }

/* modals */
dialog { border: 0; border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.2); width: min(720px, 92vw); padding: 20px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #51606f; }
.grid input, .grid select, .grid textarea { padding: 6px 10px; border: 1px solid #c6cfd9; border-radius: 6px; font: inherit; }
.grid textarea { min-height: 56px; grid-column: span 2; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.modal-actions .spacer { flex: 1; }
#users-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
#users-table th, #users-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eef1f5; }
#user-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#user-form input, #user-form select { padding: 6px 10px; border: 1px solid #c6cfd9; border-radius: 6px; }

/* mobile */
@media (max-width: 760px) {
  header { padding: 10px 12px; }
  header h1 { font-size: 14px; }
  #summary-bar { padding: 6px 12px; font-size: 12px; }
  .tabs { padding: 8px 12px 0; }
  .tab { padding: 8px 14px; font-size: 13px; }
  .toolbar { padding: 10px 12px; gap: 6px; }
  #f-search { min-width: 0; flex: 1 1 100%; }
  .toolbar select { flex: 1 1 45%; min-width: 0; }
  #companies { display: block; width: auto; margin: 0 8px 12px; overflow-x: auto; white-space: nowrap; }
  #companies th, #companies td { padding: 6px 8px; font-size: 13px; }
  /* hide lower-priority columns on small screens: Sektor(2), Wilayah(3), Proyek Terakhir(7) */
  #companies th:nth-child(2), #companies td:nth-child(2),
  #companies th:nth-child(3), #companies td:nth-child(3),
  #companies th:nth-child(7), #companies td:nth-child(7) { display: none; }
  .grid { grid-template-columns: 1fr; }
  .grid textarea { grid-column: span 1; }
  dialog { width: 96vw; padding: 14px; }
}
