:root {
  --bg: #0a0c14; --surface: #111520; --surface2: #181d2e; --border: #1c2240; --border-light: #252d50;
  --text: #e2e8f0; --text-muted: #5a6285; --text-soft: #8892b0;
  --accent: #6366f1; --accent-hover: #818cf8; --accent-dim: rgba(99,102,241,.1);
  --success: #22c55e; --error: #ef4444; --warn: #f59e0b; --info: #38bdf8;
  --radius: 12px; --shadow: 0 4px 20px rgba(0,0,0,.4);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; display: flex; min-height: 100vh; }
::-webkit-scrollbar { width: 5px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ── Sidebar ── */
.sidebar { width: 260px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 0; display: flex; flex-direction: column; overflow-y: auto; }
.sidebar-brand { padding: 1.5rem 1.5rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.sidebar-brand .logo { width: 36px; height: 36px; background: linear-gradient(135deg,#6366f1,#818cf8); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; color: #fff; flex-shrink:0; box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.sidebar-brand h1 { font-size: 1rem; font-weight: 600; letter-spacing:-.01em; }
.sidebar-brand small { display: block; font-size: .68rem; color: var(--text-muted); font-weight: 400; margin-top:.1rem; }

.sidebar-section { padding: 1.25rem 1.25rem .75rem; }
.sidebar-section-title { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: .6rem; font-weight: 600; }

.status-row { display: flex; align-items: center; gap: .5rem; padding: .5rem .75rem; border-radius: 8px; background: var(--surface2); border: 1px solid var(--border); font-size: .82rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink:0; }
.dot.idle { background: var(--text-muted); }
.dot.running { background: var(--accent); animation: pulse 1s infinite; }
.dot.done { background: var(--success); }
.dot.error { background: var(--error); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.tenant-panel { padding: 0 1.25rem 1rem; }
.tenant-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.tenant-panel-title { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }

.history-list { display: flex; flex-direction: column; gap: .3rem; }
.history-item { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .55rem .75rem; cursor: pointer; transition: .15s; }
.history-item:hover { border-color: var(--border-light); background: var(--surface2); }
.history-item.active { border-color: var(--accent); background: var(--accent-dim); }
.history-item .hi-file { font-size: .75rem; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .hi-meta { font-size: .65rem; color: var(--text-muted); margin-top: .15rem; display: flex; justify-content: space-between; align-items:center; gap:.5rem; }
.hi-badge { font-size: .62rem; padding: .1rem .35rem; border-radius: 4px; font-weight: 600; flex-shrink:0; }
.hi-badge.ok { background: rgba(34,197,94,.15); color: var(--success); }
.hi-badge.warn { background: rgba(245,158,11,.15); color: var(--warn); }
.hi-badge.err { background: rgba(239,68,68,.15); color: var(--error); }

.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid var(--border); font-size: .7rem; color: var(--text-muted); }

/* ── Main ── */
.main { flex: 1; padding: 2rem; min-width: 0; }
.page-header { margin-bottom: 1.75rem; }
.page-header h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.page-header p { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.card-title { font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card-badge { font-size: .65rem; font-weight: 500; padding: .15rem .5rem; border-radius: 4px; background: var(--border); color: var(--text-muted); }

/* ── Form ── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-label { font-size: .72rem; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.form-control { width: 100%; padding: .65rem .9rem; border-radius: 8px; border: 1px solid var(--border-light); background: var(--bg); color: var(--text); font-size: .875rem; font-family: inherit; transition: border-color .15s, box-shadow .15s; outline: none; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.form-control option { background: var(--surface); }
.form-hint { font-size: .72rem; color: var(--text-muted); }

.file-drop { border: 1.5px dashed var(--border-light); border-radius: 8px; padding: 1.25rem; text-align: center; cursor: pointer; transition: .15s; position: relative; background: var(--bg); }
.file-drop:hover, .file-drop.drag { border-color: var(--accent); background: var(--accent-dim); }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-drop .fd-icon { font-size: 1.5rem; margin-bottom: .25rem; }
.file-drop .fd-text { font-size: .82rem; color: var(--text-muted); }
.file-drop .fd-text strong { color: var(--accent); }
.file-drop.has-file { border-color: var(--success); background: rgba(34,197,94,.05); }
.file-drop.has-file .fd-text { color: var(--success); }

/* ── Buttons ── */
.btn { padding: .6rem 1.2rem; border: none; border-radius: 8px; font-size: .85rem; font-weight: 500; cursor: pointer; transition: .15s; font-family: inherit; display: inline-flex; align-items: center; gap: .4rem; white-space:nowrap; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 12px rgba(99,102,241,.4); transform:translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text-soft); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); color: var(--text); }
.btn-danger { background: rgba(239,68,68,.1); color: var(--error); border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,.2); }
.btn-success { background: rgba(34,197,94,.1); color: var(--success); border: 1px solid rgba(34,197,94,.2); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,.2); }
.btn-sm { padding: .4rem .85rem; font-size: .78rem; border-radius: 6px; }
.btn-xs { padding: .2rem .55rem; font-size: .7rem; border-radius: 5px; }
.btn-icon { padding: .4rem .5rem; }

/* ── Status Badge ── */
.status-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem; border-radius: 20px; font-size: .75rem; font-weight: 500; }
.status-badge.idle { background: rgba(90,98,133,.12); color: var(--text-muted); }
.status-badge.running { background: var(--accent-dim); color: var(--accent); }
.status-badge.done { background: rgba(34,197,94,.12); color: var(--success); }
.status-badge.error { background: rgba(239,68,68,.12); color: var(--error); }

/* ── Progress ── */
.progress-bar { width: 100%; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 1rem; }
.progress-bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 2px; transition: width .3s ease; width: 0%; }

/* ── Log ── */
.log-container { background: #060810; border: 1px solid var(--border); border-radius: 8px; font-family: 'JetBrains Mono', monospace; font-size: .76rem; line-height: 1.65; max-height: 400px; overflow-y: auto; padding: 1rem; }
.log-container .line { white-space: pre-wrap; word-break: break-all; padding: .05rem 0; }
.line .ll-info { color: var(--info); } .line .ll-success { color: var(--success); } .line .ll-error { color: var(--error); } .line .ll-warn { color: var(--warn); } .line .ll-muted { color: var(--text-muted); }

/* ── Stats Row ── */
.stats-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; text-align: center; transition: .15s; }
.stat-card:hover { border-color: var(--border-light); }
.stat-card.success { border-color: rgba(34,197,94,.25); background: rgba(34,197,94,.05); }
.stat-card.error   { border-color: rgba(239,68,68,.25); background: rgba(239,68,68,.05); }
.stat-card.warn    { border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.05); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: .3rem; font-weight: 500; }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.error .stat-value   { color: var(--error); }
.stat-card.warn .stat-value    { color: var(--warn); }

/* ── Takip Result Card ── */
.result-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: .75rem; }
.result-card-header { padding: .85rem 1.1rem; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; gap: .75rem; }
.result-card-header:hover { background: rgba(255,255,255,.02); }
.result-card-title { display: flex; align-items: center; gap: .6rem; font-size: .85rem; font-weight: 600; }
.result-card-title .rc-status { font-size: .9rem; }
.result-card-meta { display: flex; align-items: center; gap: .75rem; font-size: .78rem; color: var(--text-muted); }
.result-card-amount { font-size: .9rem; font-weight: 700; color: var(--text); }
.result-card-body { border-top: 1px solid var(--border); padding: 1rem 1.1rem; display: none; }
.result-card-body.open { display: block; }

.comparison-table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.comparison-table th { padding: .4rem .75rem; font-size: .65rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--surface); text-align:left; }
.comparison-table th:not(:first-child) { text-align: right; }
.comparison-table td { padding: .45rem .75rem; border-bottom: 1px solid var(--border); }
.comparison-table tr:last-child td { border-bottom: none; }
.comparison-table td:not(:first-child) { text-align: right; font-family: 'JetBrains Mono', monospace; font-size: .75rem; }
.comparison-table tr.mismatch td { background: rgba(239,68,68,.04); }
.check-ok { color: var(--success); font-weight: 600; }
.check-no { color: var(--error); font-weight: 600; }

/* ── Detail Tables ── */
.detail-section { margin-bottom: 1.25rem; }
.detail-section-title { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap:wrap; }
.detail-section-title .ds-icon { font-size: .95rem; }
.detail-section-title .ds-label { font-size: .8rem; font-weight: 600; }
.detail-section-title .ds-table { font-size: .65rem; color: var(--text-muted); background: var(--border); padding: .1rem .4rem; border-radius: 4px; font-family: monospace; }
.detail-section-title .ds-count { font-size: .72rem; color: var(--accent); margin-left: auto; }
.detail-data-table { width: 100%; border-collapse: collapse; font-size: .73rem; }
.detail-data-table th { padding: .35rem .6rem; font-size: .62rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--surface); white-space:nowrap; font-family:monospace; font-weight:500; }
.detail-data-table td { padding: .35rem .6rem; border-bottom: 1px solid var(--border); font-family: monospace; white-space:nowrap; }
.detail-data-table tr:last-child td { border-bottom: none; }
.detail-data-table tr:nth-child(even) td { background: rgba(255,255,255,.015); }
.td-null { color: var(--border-light); font-style: italic; }
.td-num  { text-align: right; }
.td-long { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; width: 480px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,.5); transform: translateY(16px) scale(.97); transition: transform .2s; }
.modal-overlay.open .modal { transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.05rem; font-weight: 700; letter-spacing:-.01em; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; padding: .2rem; transition: color .15s; line-height:1; }
.modal-close:hover { color: var(--text); }
.modal-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }
.modal-alert { padding: .6rem .9rem; border-radius: 8px; font-size: .8rem; margin-top: .5rem; }
.modal-alert.success { background: rgba(34,197,94,.1); color: var(--success); border: 1px solid rgba(34,197,94,.2); }
.modal-alert.error   { background: rgba(239,68,68,.1); color: var(--error); border: 1px solid rgba(239,68,68,.2); }

/* ── Tabs ── */
.tab-bar { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab-btn { padding: .55rem 1rem; font-size: .8rem; font-weight: 500; background: none; border: none; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: .15s; font-family: inherit; border-radius: 6px 6px 0 0; }
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,.03); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Divider ── */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── REC Indicator ── */
.rec-badge { display: none; align-items: center; gap: .35rem; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.28); border-radius: 6px; padding: .18rem .55rem .18rem .42rem; font-size: .7rem; font-weight: 700; color: #ef4444; letter-spacing: .07em; user-select: none; flex-shrink: 0; }
.rec-badge.visible { display: inline-flex; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; flex-shrink: 0; animation: rec-blink 1s ease-in-out infinite; box-shadow: 0 0 5px rgba(239,68,68,.9), 0 0 10px rgba(239,68,68,.4); }
@keyframes rec-blink { 0%,100% { opacity:1; box-shadow: 0 0 5px rgba(239,68,68,.9), 0 0 12px rgba(239,68,68,.4); } 50% { opacity:.12; box-shadow: none; } }

@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; max-height: 260px; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(3,1fr); }
}
