/* Phase 1 - Admin & Login styling */

* { box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #6b7280;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; margin-top: 20px; }

.hidden { display: none !important; }

/* ──────── AUTH PAGE ──────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 380px;
}

.auth-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
}

.auth-card label {
  display: block;
  margin-bottom: 16px;
  font-weight: 500;
  font-size: 13px;
}

.auth-card input,
.auth-card select,
.modal input,
.modal select,
.modal textarea {
  width: 100%;
  padding: 9px 12px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}

.auth-card input:focus,
.modal input:focus,
.modal select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-card button {
  width: 100%;
  padding: 11px;
  margin-top: 8px;
}

/* ──────── BUTTONS ──────── */
button {
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  transition: background 0.15s;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary, .auth-card button {
  background: var(--primary);
  color: white;
  font-weight: 500;
}

.btn-primary:hover:not(:disabled), .auth-card button:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #f9fafb;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
}

.error-box {
  background: #fef2f2;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-top: 16px;
  font-size: 13px;
  border: 1px solid #fecaca;
}

/* ──────── TOPBAR ──────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-left strong { font-size: 16px; }

.topbar-subtitle {
  color: var(--text-muted);
  margin-left: 8px;
  font-size: 13px;
}

.topbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

#userBadge {
  background: #eef2ff;
  color: #3730a3;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* ──────── TABS ──────── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 12px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ──────── MAIN ──────── */
.main-content {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

/* ──────── DATA LIST ──────── */
.data-list {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.data-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.data-row:last-child { border-bottom: none; }

.data-row-info { min-width: 0; }
.data-row-name { font-weight: 500; }
.data-row-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.data-row-actions {
  display: flex;
  gap: 6px;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  margin-left: 6px;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-muted { background: #e5e7eb; color: #4b5563; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ──────── INFO CARD ──────── */
.info-card {
  background: var(--surface);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.info-card .big-number {
  font-size: 28px;
  font-weight: 600;
}

.info-card .label {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 4px;
}

/* ──────── MODAL ──────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 500;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ──────── TOAST ──────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 200;
  font-size: 13px;
  max-width: 320px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ──────── AUDIT LOG ──────── */
.audit-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.audit-row pre {
  background: #f9fafb;
  padding: 8px;
  border-radius: 4px;
  font-size: 11px;
  margin: 6px 0 0;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Mobile */
@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .panel-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .data-row { grid-template-columns: 1fr; }
}

/* ADD THESE STYLES to the END of your existing /web/public/css/style.css file.
   Do NOT replace the existing CSS — just append these new rules. */

/* ──────── FILTER BAR ──────── */
.filter-bar {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  margin: 0;
  color: var(--text-muted);
}

.filter-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--text);
  cursor: pointer;
}

.filter-bar select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* ──────── BRAND CHIPS (for media buyer cards) ──────── */
.brand-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.brand-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.brand-chip.chip-active {
  background: #d1fae5;
  color: #065f46;
}

.brand-chip.chip-inactive {
  background: #f3f4f6;
  color: #6b7280;
  text-decoration: line-through;
}

/* ──────── ASSIGNMENT ROW (in edit modal) ──────── */
.assignment-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}

.assignment-row span {
  font-weight: 500;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin: 0;
  font-weight: normal;
  font-size: 12px;
  color: var(--text-muted);
}

.toggle-switch input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin: 0;
}

.toggle-label {
  font-size: 12px;
}

/* ──────── CHECKBOX ROW (multi-select brands in modal) ──────── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  font-weight: normal;
  cursor: pointer;
  margin: 0;
}

.checkbox-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  margin: 0;
}

/* Mobile: stack filter bar items */
@media (max-width: 600px) {
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar label {
    width: 100%;
    justify-content: space-between;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   Phase 2A.4 Tasks 7+8 additions
   ═══════════════════════════════════════════════════════════════════════ */

/* ──────── COLLAPSIBLE SECTIONS (brand modal) ──────── */
.modal-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  background: #f9fafb;
}

.modal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: #f3f4f6;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.modal-section-header:hover {
  background: #e5e7eb;
}

.modal-section.open .modal-section-header {
  border-bottom-color: var(--border);
}

.modal-section-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-section-title .section-icon {
  font-size: 14px;
}

.modal-section-chevron {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
}

.modal-section.open .modal-section-chevron {
  transform: rotate(180deg);
}

.modal-section-body {
  display: none;
  padding: 14px;
  background: white;
}

.modal-section.open .modal-section-body {
  display: block;
}

.modal-section-body label {
  margin-bottom: 14px;
}

.modal-section-body label:last-child {
  margin-bottom: 0;
}

.help-text {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: normal;
}

/* Section-level required-marker placement */
.required-marker {
  color: var(--danger);
  margin-left: 2px;
}

/* ──────── SCRAPER STATUS TAB ──────── */
.status-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-meta {
  font-size: 12px;
  color: var(--text-muted);
}

#statusList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.status-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.status-card-name {
  font-size: 16px;
  font-weight: 600;
}

.status-card-actions {
  display: flex;
  gap: 6px;
}

.status-health {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-health.health-ok       { background: #d1fae5; color: #065f46; }
.status-health.health-warning  { background: #fef3c7; color: #92400e; }
.status-health.health-error    { background: #fee2e2; color: #991b1b; }
.status-health.health-disabled { background: #f3f4f6; color: #4b5563; }

.status-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

.status-label {
  color: var(--text-muted);
  font-weight: 500;
}

.status-value {
  color: var(--text);
}

.status-value.value-muted {
  color: var(--text-muted);
}

/* Mobile: stack the status grid */
@media (max-width: 600px) {
  .status-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .status-label {
    margin-top: 6px;
  }
  .status-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Loading spinner for Run Now */
.btn-running {
  position: relative;
  padding-left: 28px;
}

.btn-running::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ═══════════════════════════════════════════════════════════════════════
   Live Data tab (Phase 2A.4 follow-up)
   ═══════════════════════════════════════════════════════════════════════ */

#liveDataList {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.livedata-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.livedata-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.livedata-card-name {
  font-size: 17px;
  font-weight: 600;
}

.livedata-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.livedata-card-meta-main {
  display: flex;
  gap: 12px;
  align-items: center;
}

.livedata-card-meta-note {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.8;
}

.livedata-report-time {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, monospace;
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.livedata-card-meta .freshness-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.livedata-card-meta .freshness-fresh { background: #d1fae5; color: #065f46; }
.livedata-card-meta .freshness-stale { background: #fef3c7; color: #92400e; }
.livedata-card-meta .freshness-old   { background: #fee2e2; color: #991b1b; }

.livedata-prominent {
  display: grid;
  /* Exactly 3 columns × 2 rows on desktop/tablet (per user-specified layout).
     Mobile falls back to 1 column via the @media rule below. */
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

/* Tablet: drop to 2 columns at narrow widths to keep stats readable */
@media (max-width: 720px) {
  .livedata-prominent {
    grid-template-columns: repeat(2, 1fr);
  }
}

.livedata-stat {
  background: #f9fafb;
  border-radius: 6px;
  padding: 12px 14px;
  border-left: 3px solid var(--primary);
}

.livedata-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.livedata-stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.livedata-stat-value.value-currency {
  font-size: 18px; /* slightly smaller for long Rp numbers */
}

.livedata-stat-value.value-empty {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 18px;
  font-style: italic;
}

.livedata-details-toggle {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  margin-top: 4px;
}

.livedata-details-toggle:hover {
  background: #f9fafb;
  color: var(--text);
}

.livedata-details {
  display: none;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.livedata-details.open {
  display: block;
}

.livedata-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 16px;
  font-size: 13px;
}

.livedata-details-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.livedata-details-item:last-child {
  border-bottom: none;
}

.livedata-details-label {
  color: var(--text-muted);
}

.livedata-details-value {
  color: var(--text);
  font-weight: 500;
}

.livedata-details-section {
  margin-bottom: 14px;
}

.livedata-details-section:last-child {
  margin-bottom: 0;
}

.livedata-details-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.livedata-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-style: italic;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  .livedata-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .livedata-card-meta {
    align-items: flex-start;
  }
  .livedata-prominent {
    grid-template-columns: 1fr;
  }
  .livedata-stat-value {
    font-size: 20px;
  }
  .livedata-stat-value.value-currency {
    font-size: 16px;
  }
}
/* ═════════════════════════════════════════════════════════════
   PERMISSIONS TAB (Phase 2B.0 Flavor A)
   Append this block to web/public/css/style.css
   ═════════════════════════════════════════════════════════════ */

.permissions-intro {
  color: var(--text-muted, #6b7280);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.5;
}

.permissions-intro code {
  background: var(--bg-subtle, #f3f4f6);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
}

.perm-section {
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.perm-section-locked {
  background: var(--bg-subtle, #f9fafb);
}

.perm-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text, #111827);
}

.perm-section-help {
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  margin: 0 0 14px;
  line-height: 1.5;
}

.perm-section-help code {
  background: var(--bg-subtle, #f3f4f6);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.perm-row {
  padding: 8px 10px;
  border-radius: 5px;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.perm-row:hover {
  background: var(--bg-subtle, #f3f4f6);
}

.perm-row-locked {
  opacity: 0.6;
}

.perm-row-locked:hover {
  background: transparent;
}

.perm-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.perm-row-locked .perm-checkbox-label {
  cursor: not-allowed;
}

.perm-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary, #3b82f6);
}

.perm-row-label {
  font-weight: 500;
  color: var(--text, #111827);
}

.perm-row-key {
  color: var(--text-muted, #9ca3af);
  font-size: 12px;
}

.perm-row-key code {
  background: transparent;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}

.perm-locked-badge {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted, #6b7280);
  background: var(--bg-card, #fff);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border, #e5e7eb);
}

/* ═════════════════════════════════════════════════════════════
   SUBMIT SPENDING TAB (Phase 2B.3b)
   ═════════════════════════════════════════════════════════════ */

/* ──────── PICKER ROW ──────── */
.submit-pickers {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.submit-pickers label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0;
}

.submit-pickers select,
.submit-pickers input[type=date] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--text);
  min-width: 130px;
}

.submit-pickers select:focus,
.submit-pickers input[type=date]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.submit-pickers button {
  align-self: flex-end;
}

/* ──────── STATUS BANNER (locked / pending / fresh) ──────── */
.submit-status-banner {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.submit-status-banner.banner-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.submit-status-banner.banner-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.submit-status-banner.banner-locked {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.submit-status-banner.banner-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* ──────── GIGA DATA CARD ──────── */
.submit-giga-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.submit-giga-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.submit-giga-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.submit-giga-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.submit-giga-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 16px;
}

.submit-giga-stat {
  display: flex;
  flex-direction: column;
}

.submit-giga-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.submit-giga-stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.submit-giga-stat-value.value-empty {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.submit-giga-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ──────── ENTRIES CARD ──────── */
.submit-entries-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.submit-entries-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.submit-entries-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.submit-rate-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 6px;
}

.submit-rate-info strong {
  color: var(--text);
}

.submit-entries-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}

.submit-entries-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.submit-entries-table tbody td {
  padding: 8px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.submit-entries-table tbody tr:last-child td {
  border-bottom: none;
}

.submit-entries-table select,
.submit-entries-table input[type=number] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
}

.submit-entries-table select:focus,
.submit-entries-table input[type=number]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Mode toggle (USD / IDR pill buttons) */
.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  font-size: 12px;
}

.mode-toggle button {
  padding: 6px 10px;
  background: white;
  color: var(--text-muted);
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.1s;
}

.mode-toggle button:hover:not(.active) {
  background: #f3f4f6;
}

.mode-toggle button.active {
  background: var(--primary);
  color: white;
}

.mode-toggle button + button {
  border-left: 1px solid var(--border);
}

.mode-toggle button.active + button {
  border-left: 1px solid var(--primary);
}

/* Read-only (auto-calculated) amount input */
.submit-entries-table input.amount-locked {
  background: #f3f4f6;
  color: var(--text-muted);
  cursor: not-allowed;
}

.submit-entries-table input.amount-locked:focus {
  border-color: var(--border);
  box-shadow: none;
}

/* Remove row button */
.btn-remove-row {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-remove-row:hover {
  background: #fee2e2;
}

/* Column widths */
.submit-entries-table th.col-buyer,
.submit-entries-table td.col-buyer    { width: 18%; }
.submit-entries-table th.col-platform,
.submit-entries-table td.col-platform { width: 14%; }
.submit-entries-table th.col-mode,
.submit-entries-table td.col-mode     { width: 14%; }
.submit-entries-table th.col-usd,
.submit-entries-table td.col-usd      { width: 22%; }
.submit-entries-table th.col-rp,
.submit-entries-table td.col-rp       { width: 24%; }
.submit-entries-table th.col-action,
.submit-entries-table td.col-action   { width: 8%; text-align: center; }

.submit-add-row {
  background: white;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
}

.submit-add-row:hover {
  background: #f9fafb;
  color: var(--text);
  border-color: var(--primary);
}

.submit-entries-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}

/* ──────── PREVIEW CARD ──────── */
.submit-preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.submit-preview-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.submit-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.submit-preview-block {
  background: #f9fafb;
  border-radius: 6px;
  padding: 12px;
  border-left: 3px solid var(--primary);
}

.submit-preview-block.preview-organic {
  border-left-color: var(--success);
}

.submit-preview-block-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 600;
}

.submit-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 4px;
  min-height: 18px;  /* ensure consistent row height so left/right rows align */
}

.submit-preview-row:last-child {
  margin-bottom: 0;
}

/* Empty spacer row — used in LEFT block to pad to same row count as RIGHT block,
   so the 4 cost rows align horizontally between the two blocks. */
.submit-preview-spacer {
  /* keep min-height + margin-bottom from .submit-preview-row */
  visibility: hidden;
  pointer-events: none;
}
.submit-preview-spacer::before {
  /* zero-width space so the row reserves vertical space even when empty */
  content: '\00a0';
}

.submit-preview-label {
  color: var(--text-muted);
}

.submit-preview-value {
  font-weight: 600;
  color: var(--text);
}

.submit-preview-value.value-null {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.submit-preview-disabled {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
}

/* ──────── ACTIONS BAR ──────── */
.submit-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  bottom: 0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
  z-index: 10;
}

.submit-draft-status {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.submit-draft-status.status-saving {
  color: var(--warning);
  font-style: normal;
}

.submit-draft-status.status-saved {
  color: var(--success);
  font-style: normal;
}

.submit-draft-status.status-error {
  color: var(--danger);
  font-style: normal;
}

.submit-action-buttons {
  display: flex;
  gap: 8px;
}

/* Mobile */
@media (max-width: 720px) {
  .submit-pickers {
    flex-direction: column;
    align-items: stretch;
  }
  .submit-pickers label {
    width: 100%;
  }
  .submit-pickers select,
  .submit-pickers input[type=date] {
    width: 100%;
    min-width: 0;
  }
  .submit-giga-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .submit-preview-grid {
    grid-template-columns: 1fr;
  }
  .submit-entries-table {
    font-size: 12px;
  }
  .submit-entries-table thead {
    display: none;
  }
  .submit-entries-table,
  .submit-entries-table tbody,
  .submit-entries-table tr,
  .submit-entries-table td {
    display: block;
    width: 100%;
  }
  .submit-entries-table tr {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
  }
  .submit-entries-table td {
    border-bottom: none;
    padding: 4px 0;
  }
  .submit-entries-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
  }
  .submit-actions-bar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
}

/* ═════════════════════════════════════════════════════════════
   Phase 2B.4 — RECAP DASHBOARD STYLES
   ═════════════════════════════════════════════════════════════ */

/* Header bar inside the Recap Dashboard tab — brand/date pickers + actions */
.recap-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.recap-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.recap-controls select,
.recap-controls input[type="date"] {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-width: 150px;
}

.recap-controls select:focus,
.recap-controls input[type="date"]:focus {
  outline: none;
  border-color: var(--primary);
}

.recap-controls-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.recap-range-error {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
}

.recap-range-error.hidden {
  display: none;
}

/* Loading and empty states */
.recap-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.recap-summary-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.recap-summary-bar strong {
  color: var(--text);
  font-weight: 600;
}

/* Scrollable wrapper for the wide table */
.recap-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  /* Lock max height so totals row's sticky bottom positioning has something
     to "stick" against. ~70vh is enough room for ~25 rows visible at once. */
  max-height: 70vh;
  overflow-y: auto;
}

/* The recap table itself */
.recap-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  min-width: 1800px;  /* forces horizontal scroll on narrow screens */
}

.recap-table thead {
  background: #f3f4f6;
  position: sticky;
  top: 0;
  z-index: 3;
}

.recap-table th {
  padding: 10px 12px;
  text-align: right;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.recap-table th:first-child {
  text-align: left;
}

.recap-table td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;  /* monospace digits for clean column alignment */
}

.recap-table td:first-child {
  text-align: left;
  font-weight: 500;
}

.recap-table tbody tr:hover {
  background: #f9fafb;
}

/* Sticky DATE column (first column) — stays visible on horizontal scroll */
.recap-table th:first-child,
.recap-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
  border-right: 2px solid var(--border);
}

.recap-table thead th:first-child {
  background: #f3f4f6;
  z-index: 4;  /* higher than other thead cells so it wins on both axes */
}

.recap-table tbody tr:hover td:first-child {
  background: #f9fafb;
}

/* Greyed-out empty rows (days with no submitted recap) */
.recap-table tr.recap-row-empty td {
  color: var(--text-muted);
  background: #fafafa;
  font-style: italic;
}

.recap-table tr.recap-row-empty:hover td {
  background: #f3f4f6;
}

.recap-table tr.recap-row-empty td:first-child {
  background: #fafafa;
}

.recap-table tr.recap-row-empty:hover td:first-child {
  background: #f3f4f6;
}

/* Negative DP - WD values (red) */
.recap-cell-negative {
  color: var(--danger);
}

.recap-cell-positive {
  color: var(--success);
}

/* GIGA source badge — small icon next to the date */
.recap-source-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.7;
  cursor: help;
}

/* Sticky totals row at the bottom of the table */
.recap-table tr.recap-totals-row {
  position: sticky;
  bottom: 0;
  background: #eff6ff;  /* light blue tint to distinguish from data rows */
  z-index: 3;
  font-weight: 600;
  border-top: 2px solid var(--primary);
}

.recap-table tr.recap-totals-row td {
  border-bottom: none;
  background: #eff6ff;
}

.recap-table tr.recap-totals-row td:first-child {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 700;
}

.recap-table tr.recap-totals-row:hover td,
.recap-table tr.recap-totals-row:hover td:first-child {
  background: #dbeafe;
}

/* Mobile responsive — recap table */
@media (max-width: 700px) {
  .recap-controls {
    padding: 10px;
    gap: 8px;
  }
  .recap-controls label {
    flex: 1 1 100%;
  }
  .recap-controls select,
  .recap-controls input[type="date"] {
    width: 100%;
    min-width: 0;
  }
  .recap-controls-actions {
    margin-left: 0;
    width: 100%;
    justify-content: stretch;
  }
  .recap-controls-actions button {
    flex: 1;
  }
  /* Keep the table horizontally scrollable on mobile — don't collapse to
     vertical layout like submit-entries-table does. The wide dashboard
     fundamentally needs horizontal scroll to be useful. */
  .recap-table {
    font-size: 12px;
    min-width: 1600px;
  }
  .recap-table th,
  .recap-table td {
    padding: 6px 8px;
  }
  .recap-table-wrap {
    max-height: 60vh;
  }
}
/* ═════════════════════════════════════════════════════════════
   Phase 2B.4d-4b — RECAP DASHBOARD COMPACT MODE
   Triggered by .recap-table-compact class on .recap-table-wrap.
   In compact mode: smaller font, tighter padding, no min-width,
   and the dashboard panel breaks out of the .main-content 1100px
   max-width so the table can use the full viewport width.
   ═════════════════════════════════════════════════════════════ */

/* When compact mode is on, lift the min-width restriction and let the
   table fill the available width. */
.recap-table-wrap.recap-table-compact .recap-table {
  font-size: 11px;
  min-width: 0;          /* override the default 1800px from base styles */
  width: 100%;           /* fill the wrapper */
  table-layout: auto;    /* let browser size columns to content */
}

.recap-table-wrap.recap-table-compact .recap-table th {
  padding: 4px 6px;
  font-size: 9px;
  letter-spacing: 0.3px;
}

.recap-table-wrap.recap-table-compact .recap-table td {
  padding: 3px 6px;
}

/* Drop the wrapper's horizontal scrolling in compact mode — content fits */
.recap-table-wrap.recap-table-compact {
  overflow-x: hidden;
}

/* Slightly shrink the source badge too */
.recap-table-wrap.recap-table-compact .recap-source-badge {
  font-size: 9px;
}

/* ─────────────────────────────────────────────────────────────
   FULL-VIEWPORT BREAKOUT
   .main-content has max-width:1100px + margin:auto, which centers
   it in a narrow column. When the recap panel contains a compact
   table, escape that container by anchoring to the viewport edges.
   This trick uses position:relative on .main-content (implicit
   from being a block element) plus negative margins to "break out".
   ───────────────────────────────────────────────────────────── */

/* If the recap panel contains a compact-mode table, let the panel
   itself stretch beyond .main-content's 1100px constraint. */
.tab-panel#tab-recap:has(.recap-table-wrap.recap-table-compact) {
  width: calc(100vw - 48px);  /* full viewport minus a small breathing margin */
  max-width: none;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}

/* Fallback for browsers without :has() support — applied via JS in
   recap-dashboard.js by toggling a class on the panel itself. */
.tab-panel#tab-recap.recap-fullwidth {
  width: calc(100vw - 48px);
  max-width: none;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
}
/* ═════════════════════════════════════════════════════════════
   Phase 2B.5 — LOCKED FORM STATE
   Visual cue when status='locked' and form interactions are disabled.
   The disabled HTML attribute does the real protection; this just
   dims the entries card so the user sees they can't interact.
   ═════════════════════════════════════════════════════════════ */

#submit_entriesCard.locked-form {
  opacity: 0.55;
  pointer-events: none;  /* defensive — disabled attribute is the real protector */
  position: relative;
}

#submit_entriesCard.locked-form::after {
  content: "🔒 Locked — click Unlock above to enable editing";
  position: absolute;
  top: 8px;
  right: 16px;
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #fecaca;
  pointer-events: auto;
}

/* ═════════════════════════════════════════════════════════════
   Phase 2B.6 — MANAGE PLATFORMS MODAL
   Per-brand platform toggle list. Lives inside the standard
   #modal showModal() helper, so only needs row-level styling.
   ═════════════════════════════════════════════════════════════ */

.platform-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface);
}

.platform-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
}

.platform-toggle-row:hover {
  background: var(--bg);
}

.platform-toggle-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
}

.platform-toggle-name {
  font-size: 14px;
  font-weight: 500;
}