/* ═══════════════════════════════════════════════════════════
   PLOTZY OPS — Professional Meta Ads × Shopee Affiliate Dashboard
   Restrained, high-contrast, accessible, and surgical data interface.
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg-canvas: #090d16;
  --bg-sidebar: #0f1422;
  --bg-panel: #131929;
  --bg-panel-hover: #172033;
  --bg-subtle: #1a2338;
  --bg-input: #0c101a;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-focus: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --blue-subtle: rgba(59, 130, 246, 0.12);

  --emerald: #10b981;
  --emerald-subtle: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.25);

  --crimson: #ef4444;
  --crimson-subtle: rgba(239, 68, 68, 0.12);
  --crimson-border: rgba(239, 68, 68, 0.25);

  --amber: #f59e0b;
  --amber-subtle: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.25);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --sidebar-w: 240px;
  --header-h: 56px;
  --radius: 8px;
  --radius-sm: 6px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── Layout Shell ────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-canvas);
}

/* ─── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar-top {
  height: var(--header-h);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-indicator {
  width: 7px;
  height: 7px;
  background: var(--emerald);
  border-radius: 50%;
}

.brand-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 5px;
  border-radius: 4px;
}

.sidebar-menu {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

.menu-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.menu-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.menu-item.active {
  color: #fff;
  background: var(--blue);
  font-weight: 600;
}

.menu-item.active svg {
  opacity: 1;
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 6px;
}

.sidebar-bottom {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--blue);
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}

.user-info {
  min-width: 0;
  flex: 1;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-sub {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Main Content Canvas ─────────────────────────────── */
.main-canvas {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-canvas);
}

.top-navbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.navbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ─── View Panel Toggle ───────────────────────────────── */
.tab-view {
  display: none !important;
}

.tab-view.active {
  display: block !important;
}

/* ─── Card & Containers ───────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

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

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Metrics Grid ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.kpi-number {
  font-size: 19px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.kpi-subtext {
  font-size: 10.5px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ─── Honest Attribution Notice Banner ────────────────── */
.notice-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.notice-box svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--blue);
  margin-top: 2px;
}

/* ─── Tables ──────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  color: var(--text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover {
  background: var(--blue-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: var(--crimson-subtle);
  color: var(--crimson);
  border: 1px solid var(--crimson-border);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.btn-success {
  background: var(--emerald-subtle);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.22);
}

.btn-sm {
  padding: 3px 9px;
  font-size: 11px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.badge-active {
  background: var(--emerald-subtle);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.badge-paused {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
}

.badge-warning {
  background: var(--amber-subtle);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.badge-danger {
  background: var(--crimson-subtle);
  color: var(--crimson);
  border: 1px solid var(--crimson-border);
}

/* ─── Form Controls ───────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
}

.form-input::placeholder, .form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ─── File Upload Dropzone ────────────────────────────── */
.upload-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.upload-dropzone:hover {
  border-color: var(--blue);
  background: var(--blue-subtle);
}

.dropzone-icon {
  margin: 0 auto 10px;
  color: var(--blue);
}

/* ─── Recommendations & Approval Cards ────────────────── */
.rec-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rec-card.pause-rec {
  border-left: 3px solid var(--crimson);
}

.rec-card.scale-rec {
  border-left: 3px solid var(--emerald);
}

.rec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rec-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.rec-evidence {
  font-size: 12px;
  color: var(--text-secondary);
}

.rec-details-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
}

.rec-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* ─── Modal Dialog Shell ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-container {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
}

/* ─── Auth Lock Screen ────────────────────────────────── */
.auth-lock-overlay {
  position: fixed;
  inset: 0;
  background: #07090e;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.auth-lock-overlay.open {
  display: flex;
}

.auth-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
}

/* ─── Toast Shelf ─────────────────────────────────────── */
.toast-shelf {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  pointer-events: auto;
}

.toast-item.success { border-color: var(--emerald-border); }
.toast-item.error { border-color: var(--crimson-border); }

/* ─── Utilities ───────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-emerald { color: var(--emerald); }
.text-crimson { color: var(--crimson); }
.text-amber { color: var(--amber); }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-placeholder {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-tertiary);
}

/* ─── Recommendation Categories & Filter Pills ────────── */
.btn.active-rec-filter {
  background: var(--blue) !important;
  color: #fff !important;
  border-color: var(--blue) !important;
}

.rec-card.cat-review_cost {
  border-left: 3px solid var(--crimson);
}

.rec-card.cat-check_commission {
  border-left: 3px solid var(--amber);
}

.rec-card.cat-insufficient_data {
  border-left: 3px solid #64748b;
}

.rec-card.cat-test_change {
  border-left: 3px solid var(--emerald);
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 64px; min-width: 64px; }
  .brand-text-label, .menu-label, .user-info, .brand-tag { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .rec-details-grid { grid-template-columns: 1fr; }
}
