/* AgentLab — Clean Light Theme Portal Styles */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-subtle: #f9fafb;
  --border: #e5e8ef;
  --border-strong: #d2d8e4;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #7c8798;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --rose: #e11d48;
  --rose-soft: #fff1f2;
  --slate: #475569;
  --slate-soft: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* Loading */
.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-secondary);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Auth / Setup Screens */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}

.auth-sub {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* Portal Layout */
.portal {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.dot.warn {
  background: #f59e0b;
}

/* Main Area */
.main {
  padding: 26px 32px 48px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-desc {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Alerts */
.banner {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.banner.warn {
  background: var(--amber-soft);
  border-color: #fde68a;
  color: #92400e;
}

.banner.info {
  background: var(--accent-soft);
  border-color: #bfdbfe;
  color: #1e40af;
}

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

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

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

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.kpi-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pos { color: var(--green); }
.neg { color: var(--rose); }
.muted { color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-garanti { background: var(--green-soft); color: var(--green); }
.badge-banko { background: var(--accent-soft); color: var(--accent); }
.badge-riskli { background: var(--rose-soft); color: var(--rose); }

.badge-pending { background: var(--amber-soft); color: var(--amber); border: 1px solid #fde68a; }
.badge-won { background: var(--green-soft); color: var(--green); border: 1px solid #a7f3d0; }
.badge-lost { background: var(--rose-soft); color: var(--rose); border: 1px solid #fecdd3; }
.badge-void { background: var(--slate-soft); color: var(--slate); border: 1px solid var(--border); }
.badge-soon { background: var(--slate-soft); color: var(--text-muted); font-size: 10.5px; }

.badge-high { background: var(--rose-soft); color: var(--rose); }
.badge-medium { background: var(--amber-soft); color: var(--amber); }
.badge-low { background: var(--slate-soft); color: var(--slate); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover { background: var(--surface-subtle); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

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

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--rose-soft);
  border-color: #fecdd3;
  color: var(--rose);
}

.btn-danger:hover {
  background: #ffe4e6;
}

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

/* Filters */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.pill-group {
  display: inline-flex;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.pill-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Coupons */
.coupon-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.coupon-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.coupon-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.coupon-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.coupon-title {
  font-weight: 650;
  font-size: 15px;
}

.coupon-numbers {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
}

.coupon-num-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.coupon-num-item strong {
  font-size: 14px;
}

.match-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0 12px;
}

.match-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.match-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.analysis-box {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 8px;
  white-space: pre-wrap;
}

.analysis-box.post {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.analysis-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.coupon-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

/* Equity Chart */
.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.table-scroll {
  overflow-x: auto;
}

/* Lessons */
.lesson-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lesson-item.archived {
  opacity: 0.62;
  background: var(--surface-subtle);
}

.lesson-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

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

.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.code-block {
  font-family: var(--mono);
  font-size: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
}

.secret-box {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--amber-soft);
  border: 1px solid #f59e0b;
  color: #78350f;
  padding: 12px;
  border-radius: var(--radius-sm);
  word-break: break-all;
  margin: 10px 0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 34px 18px;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.empty-state p {
  margin: 6px 0 0;
  font-size: 13px;
}

/* Toast */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1100;
}

.toast {
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  max-width: 340px;
}

.toast.error {
  background: #be123c;
}

/* Mobile Responsive */
@media (max-width: 920px) {
  .portal {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px;
    gap: 12px;
  }
  .nav-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-btn {
    width: auto;
    padding: 7px 10px;
  }
  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .main {
    padding: 18px 14px 36px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-2, .grid-3, .form-row {
    grid-template-columns: 1fr;
  }
}
