:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-hover: #f0f0f0;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #888;
  --accent: #6c9fff;
  --accent-hover: #5a8fee;
  --success: #4caf50;
  --error: #ef5350;
  --warning: #ffa726;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "Fira Code", "Consolas", monospace;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Header ──────────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.portfolio-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

select, input, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

select:focus, input:focus, textarea:focus {
  border-color: var(--accent);
}

select { cursor: pointer; min-width: 180px; }

/* ─── Buttons ─────────────────────────────────────────────────── */

button, .btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button:hover { background: var(--surface-hover); border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger { border-color: var(--error); color: var(--error); }
.btn-danger:hover { background: var(--error); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ─── Main layout ─────────────────────────────────────────────── */

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 12px;
}

.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.empty-state h2 { font-size: 20px; margin-bottom: 12px; color: var(--text); }
.empty-state p { margin-bottom: 20px; }

/* ─── Summary cards ───────────────────────────────────────────── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--mono);
}

.card-detail { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.pnl-positive { color: var(--success); }
.pnl-negative { color: var(--error); }

.pnl-pct {
  font-size: 14px;
  font-weight: 500;
  margin-left: 6px;
  opacity: 0.85;
}

/* ─── Sync section ────────────────────────────────────────────── */

.header-sync {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.header-sync .sync-message {
  display: none;
}

.sync-section {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.sync-btn { position: relative; padding: 6px 12px; font-size: 13px; }
.sync-btn .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-idle { background: var(--text-muted); }
.status-running { background: var(--warning); animation: pulse 1s infinite; }
.status-done { background: var(--success); }
.status-error { background: var(--error); }
.status-pending_confirmation { background: var(--warning); animation: pulse 1s infinite; }
.status-pending_code { background: var(--warning); animation: pulse 1s infinite; }
.status-otp_required { background: var(--warning); animation: pulse 1s infinite; }

.sync-fresh { background: var(--success); }
.sync-stale { background: var(--warning); }
.sync-old { background: var(--error); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.sync-message {
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
  min-height: 18px;
}

/* ─── TR Code input ──────────────────────────────────────────── */

.tr-code-box {
  background: var(--surface);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  width: 100%;
}

.tr-code-box p {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 12px;
}

.tr-code-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.code-input {
  width: 80px;
  text-align: center;
  font-size: 20px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 6px;
  padding: 8px 12px;
}

/* ─── Chart ───────────────────────────────────────────────────── */

.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-header {
  margin-bottom: 8px;
}

.chart-value {
  font-size: 32px;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1.2;
}

.chart-change {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}

.chart-change-abs {
  font-weight: 400;
  opacity: 0.8;
}

.chart-date {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.45;
  margin-left: 6px;
}

/* Custom chart tooltip */
.custom-tooltip {
  position: absolute;
  background: #1a1a1a;
  color: #f5f5f5;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--mono);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease, left 0.1s ease, top 0.1s ease;
  z-index: 20;
  min-width: 200px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
.tooltip-date {
  font-size: 11px;
  color: #999;
  margin-bottom: 8px;
  font-weight: 500;
}
.tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tooltip-label {
  flex: 1;
  color: #bbb;
  font-size: 12px;
}
.tooltip-value {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.tooltip-profit {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #333;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}
.tooltip-profit-positive { color: #22c55e; }
.tooltip-profit-negative { color: #ef4444; }

.chart-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-range-buttons, .chart-platform-buttons {
  display: flex;
  gap: 2px;
}

.range-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.range-btn:hover { color: var(--text); background: var(--bg); }
.range-btn.active { background: var(--text); color: var(--surface); }

.chart-container {
  height: 280px;
  position: relative;
}

/* ─── Allocation row (donut + target side by side) ────────────── */

.allocation-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: stretch;
}

.allocation-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  flex: 2;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.allocation-chart-wrapper {
  height: 350px;
  width: 350px;
  position: relative;
}

/* ─── Target allocation ───────────────────────────────────────── */

.target-allocation-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  flex: 3;
  min-width: 0;
  overflow-x: auto;
}

.target-allocation-section h3 {
  font-size: 15px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.target-total {
  font-size: 13px;
  font-family: var(--mono);
  font-weight: 400;
}

.target-total.valid { color: var(--success); }
.target-total.invalid { color: var(--error); }

.target-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.target-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.target-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.target-table tr:last-child td { border-bottom: none; }
.target-table tr:hover td { background: var(--surface-hover); }

.target-input {
  width: 70px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: var(--mono);
  text-align: right;
}

.target-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
  min-width: 120px;
}

.target-bar-actual {
  height: 100%;
  border-radius: 4px 0 0 4px;
  transition: width 0.3s;
}

.target-bar-target {
  position: absolute;
  top: 0;
  height: 100%;
  width: 2px;
  background: #fff;
}

.target-bar-wrapper {
  position: relative;
}

.diff-ok { color: var(--success); }
.diff-warn { color: var(--warning); }
.diff-bad { color: var(--error); }

/* Row accents by action */
.target-table tr.row-buy td { background: rgba(34, 197, 94, 0.06); }
.target-table tr.row-buy td:first-child { box-shadow: inset 3px 0 0 var(--success); }
.target-table tr.row-sell td { background: rgba(239, 68, 68, 0.06); }
.target-table tr.row-sell td:first-child { box-shadow: inset 3px 0 0 var(--error); }
.target-table tr.row-ok td { background: transparent; }
.target-table tr.row-ok td:first-child { box-shadow: inset 3px 0 0 #ddd; }

.target-table tr.row-buy:hover td { background: rgba(34, 197, 94, 0.12); }
.target-table tr.row-sell:hover td { background: rgba(239, 68, 68, 0.12); }

/* Action badges */
.rebalance-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.rebalance-badge.action-buy {
  background: var(--success);
  color: #fff;
}
.rebalance-badge.action-sell {
  background: var(--error);
  color: #fff;
}
.rebalance-badge.action-ok {
  background: #e8e8e8;
  color: #999;
}

/* ─── Top movers (winners / losers) ──────────────────────────── */

.top-movers-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.top-movers-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
  overflow-x: auto;
}

.top-movers-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.top-movers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.top-movers-table th {
  padding: 6px 12px;
  font-size: 11px;
}

.top-movers-table td {
  padding: 8px 12px;
}

.mover-name {
  font-weight: 600;
}

@media (max-width: 640px) {
  .top-movers-row { flex-direction: column; }
  .mover-name {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ─── Assets breakdown ────────────────────────────────────────── */

.assets-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow-x: auto;
}

.assets-header {
  display: grid;
  grid-template-columns: 3.5fr 1fr 1fr 1fr 1fr 1fr 1fr;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.asset-row {
  display: grid;
  grid-template-columns: 3.5fr 1fr 1fr 1fr 1fr 1fr 1fr;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.asset-row:last-child { border-bottom: none; }
.asset-row:hover { background: var(--surface-hover); }

.asset-name { font-weight: 600; }
.asset-qty { font-weight: 400; font-size: 11px; color: var(--text-muted); font-family: var(--mono); margin-left: 6px; }
.asset-invested, .asset-avgbuy, .asset-value, .asset-avgprice, .asset-pnl, .asset-pnlpct { font-family: var(--mono); font-size: 13px; }

/* ─── Filters ─────────────────────────────────────────────────── */

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filters label { font-size: 13px; color: var(--text-muted); }

/* ─── Operations table ────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--surface);
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  color: var(--text);
}
th.sortable::after {
  content: '⇅';
  margin-left: 4px;
  opacity: 0.3;
  font-size: 10px;
}
th.sortable.sort-asc::after {
  content: '↑';
  opacity: 0.8;
}
th.sortable.sort-desc::after {
  content: '↓';
  opacity: 0.8;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-hover); }

.type-buy { color: var(--success); }
.type-sell { color: var(--error); }
.type-dividend { color: var(--accent); }
.type-deposit { color: var(--success); }
.type-withdrawal { color: var(--error); }

.text-right { text-align: right; }
.text-mono { font-family: var(--mono); font-size: 12px; }

/* ─── Pagination ─────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 0;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ─── Modal ───────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h2 { font-size: 18px; margin-bottom: 20px; }

.modal .form-group { margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.modal input { width: 100%; }

.modal .platform-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.modal .platform-section h3 {
  font-size: 14px;
  margin-bottom: 12px;
  color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 900px) {
  .allocation-row { flex-direction: column; }
  .allocation-section { flex: none; }
}

@media (max-width: 640px) {
  header { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  main { padding: 16px 8px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .modal { width: 95%; padding: 20px; }
  .assets-header, .asset-row { grid-template-columns: 100px repeat(6, 1fr); font-size: 11px; padding: 8px 10px; }

  /* Cards & sections: reduce padding */
  .card { padding: 14px; }
  .chart-section { padding: 16px; }
  .allocation-section { padding: 14px; }
  .target-allocation-section { padding: 14px; }
  .top-movers-card { padding: 14px; }

  /* Empty state: reduce vertical padding */
  .empty-state { padding: 40px 16px; }

  /* Chart: reduce height */
  .chart-container { height: 220px; }
  .chart-value { font-size: 26px; }
  .chart-change { font-size: 13px; }

  /* Allocation donut: scale down */
  .allocation-chart-wrapper { height: 260px; width: 260px; }

  /* Tables: reduce font & padding */
  table { font-size: 12px; }
  th { padding: 8px 10px; font-size: 10px; }
  td { padding: 8px 10px; }
  .target-table { font-size: 12px; }
  .target-table th { padding: 6px 8px; }
  .target-table td { padding: 6px 8px; }
  .top-movers-table { font-size: 12px; }
  .top-movers-table th { padding: 4px 8px; }
  .top-movers-table td { padding: 6px 8px; }

  /* Buttons: bigger touch targets */
  button, .btn { padding: 10px 16px; }
  .btn-sm { padding: 6px 12px; }
  .sync-btn { padding: 8px 12px; }
  .range-btn { padding: 8px 12px; font-size: 12px; }

  /* Select: remove min-width */
  select { min-width: 0; width: 100%; }

  /* Target bar: reduce min-width */
  .target-bar { min-width: 80px; }

  /* Card values: slightly smaller */
  .card-value { font-size: 20px; }

  /* Gaps */
  .summary-grid { gap: 10px; }
  .allocation-row { gap: 12px; }
  .top-movers-row { gap: 10px; }
}

@media (max-width: 380px) {
  .summary-grid { grid-template-columns: 1fr; }
  .card-value { font-size: 18px; }
  .chart-container { height: 180px; }
  .chart-value { font-size: 22px; }
  .allocation-chart-wrapper { height: 200px; width: 200px; }
  .card { padding: 12px; }
  .chart-section { padding: 12px; }
  header { padding: 10px 12px; }
  main { padding: 12px 6px; }
}

/* ─── Compras programadas ────────────────────────────────────── */

.scheduled-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}

.scheduled-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.scheduled-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.scheduled-log-header {
  margin-top: 24px;
  margin-bottom: 12px;
}

.scheduled-log-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.scheduled-empty {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 0;
}

.scheduled-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.scheduled-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.scheduled-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.scheduled-table th.text-right,
.scheduled-table td.text-right {
  text-align: right;
  font-family: var(--mono);
}

.scheduled-table tbody tr:hover {
  background: var(--surface-hover);
}

.scheduled-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.mode-real { background: #e3f2fd; color: #1565c0; }
.mode-info { background: #fff3e0; color: #e65100; }
.freq-daily { background: #fce4ec; color: #c62828; }
.freq-weekly { background: #e8eaf6; color: #283593; }
.freq-monthly { background: #f3e5f5; color: #6a1b9a; }
.freq-detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.scheduled-summary { display: flex; justify-content: flex-end; padding: 12px 10px 0; font-size: 13px; color: var(--text-muted); }
.scheduled-summary strong { color: var(--text); font-family: var(--mono); margin-left: 4px; }
.status-active { background: #e8f5e9; color: #2e7d32; }
.status-inactive { background: #f5f5f5; color: #9e9e9e; }
.status-executed { background: #e8f5e9; color: #2e7d32; }
.status-registered { background: #fff3e0; color: #e65100; }
.status-error { background: #ffebee; color: #c62828; }

.scheduled-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--text);
  transition: background 0.15s;
}

.btn-icon:hover { background: var(--surface-hover); }
.btn-icon.btn-danger { border-color: var(--error); color: var(--error); }
.btn-icon.btn-danger:hover { background: var(--error); color: #fff; }

.log-table { margin-top: 8px; }
.log-message { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scheduled purchase form (modal) */
.scheduled-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scheduled-form label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.scheduled-form select,
.scheduled-form input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.scheduled-form-inline {
  display: flex;
  gap: 12px;
}

.scheduled-form-inline > div {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scheduled-form-inline select,
.scheduled-form-inline input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.scheduled-form-inline input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.scheduled-form-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.sched-mode-hint {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 0;
}

.sched-mode-hint.hint-real,
.sched-mode-hint:not(.hint-info) {
  background: #e3f2fd;
  color: #1565c0;
}

.sched-mode-hint.hint-info {
  background: #fff3e0;
  color: #e65100;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-secondary:hover { background: var(--surface-hover); }

@media (max-width: 640px) {
  .scheduled-section { padding: 14px; }

  /* Hide table header, convert rows to cards */
  .scheduled-table thead { display: none; }

  .scheduled-table,
  .scheduled-table tbody {
    display: block;
    width: 100%;
  }

  /* Card layout with 2-column grid (35/65) */
  .scheduled-table tr {
    display: grid;
    grid-template-columns: 35% 1fr;
    gap: 2px 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 10px;
  }

  .scheduled-table td {
    display: flex;
    flex-direction: column;
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .scheduled-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin-bottom: 1px;
  }

  .scheduled-table td.text-right {
    text-align: left;
  }

  /* Actions row spans full width */
  .scheduled-table td.scheduled-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
  }

  .scheduled-table td.scheduled-actions::before {
    display: none;
  }

  /* Log table: message spans full width */
  .log-table td.log-message {
    grid-column: 1 / -1;
  }

  .btn-icon {
    padding: 8px 12px;
    font-size: 16px;
  }

  .scheduled-summary {
    font-size: 12px;
    padding: 8px 4px 0;
  }

  .log-message {
    max-width: none;
    white-space: normal;
    word-break: break-word;
  }

  /* Form inline fields: stack vertically */
  .scheduled-form-inline {
    flex-direction: column;
    gap: 10px;
  }

  .scheduled-form-row {
    flex-direction: column;
    gap: 8px;
  }

  .scheduled-form-row button {
    width: 100%;
  }
}
