:root {
  --bg: #0f1117;
  --card: #181b23;
  --border: #2a2e3a;
  --text: #e6e8ee;
  --muted: #8a91a5;
  --accent: #4f8cff;
  --green: #3ecf8e;
  --red: #ff5d5d;
  --yellow: #e0b341;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }

/* ---- lucide-style inline icons ---- */
.ic {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -3px; flex-shrink: 0;
}
.ic-xs { width: 13px; height: 13px; vertical-align: -2px; }
.ic-sm { width: 15px; height: 15px; }
h2 .ic { margin-right: 6px; }
h3 .ic { margin-right: 5px; }
.side-icon { width: 17px; height: 17px; }
.side-link .ic { color: var(--muted); }
.side-link.active .ic { color: #9db9ff; }
.btn .ic { margin-right: 4px; }

.screen { max-width: 960px; margin: 0 auto; padding: 24px; }

/* ---- loading screen ---- */
.loading-screen {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .3s ease;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; }
.loading-spinner {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border: 4px solid #232837; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 16px; font-weight: 600; color: var(--text); }
.loading-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---- login ---- */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }

/* ---- dashboard layout ---- */
.dashboard { max-width: 1400px; min-height: 100vh; padding: 0; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
  width: 230px; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand { font-size: 15px; font-weight: 700; padding: 0 8px 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-size: 13.5px; transition: background .15s, color .15s;
}
.side-link:hover { background: #232837; color: var(--text); }
.side-link.active { background: #1d2740; color: #9db9ff; font-weight: 600; }
.side-icon { font-size: 15px; width: 20px; text-align: center; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); }

.main { margin-left: 230px; padding: 20px 24px; min-width: 0; }
.section { display: none; }
.section.active { display: block; }

/* ---- API docs ---- */
.doc-table td { font-size: 13px; }
.m-get, .m-post, .m-del {
  display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 5px;
}
.m-get { background: #163425; color: var(--green); }
.m-post { background: #1d2a4a; color: #7fb0ff; }
.m-del { background: #3a2424; color: var(--red); }
.code-block {
  background: #12151d; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; margin: 8px 0 14px;
}
.code-block code { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; color: #c9d4f0; }
.doc-notes { padding-left: 20px; color: var(--muted); font-size: 13px; }
.doc-notes li { margin-bottom: 6px; }

@media (max-width: 800px) {
  .sidebar {
    position: static; width: 100%; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 12px; border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar-brand { border-bottom: none; padding: 0 8px 0 0; margin: 0; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .side-link { padding: 6px 10px; font-size: 12.5px; }
  .side-icon { display: none; }
  .sidebar-footer { border-top: none; padding: 0; }
  .main { margin-left: 0; padding: 14px; }
}

/* ---- topbar ---- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; margin-bottom: 16px;
}
.brand { font-size: 18px; font-weight: 600; }

/* ---- stats ---- */
.stats-strip {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px; text-align: center;
}
.stat-val { font-size: 26px; font-weight: 700; font-family: var(--mono); }
.stat-val.green { color: var(--green); }
.stat-val.red { color: var(--red); }
.stat-lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.hint { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

/* ---- inputs & buttons ---- */
input, select {
  background: #12151d; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 9px 12px; font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.btn {
  background: #232837; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 9px 16px; cursor: pointer; font-size: 13px;
  transition: background .15s;
}
.btn:hover { background: #2d3345; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3d7ae8; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: #3a2424; }
.btn-ghost { background: transparent; }
.btn-small { padding: 4px 10px; font-size: 12px; }

.row-form { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.row-form input { flex: 1; min-width: 140px; }

/* ---- master key ---- */
.masterkeys td { font-size: 13px; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; color: var(--muted); font-size: 12px;
  font-weight: 500; padding: 8px; border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .04em;
}
td { padding: 10px 8px; border-bottom: 1px solid #22262f; vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.badge {
  background: #232837; border-radius: 6px; padding: 3px 10px;
  font-size: 12px; font-family: var(--mono); color: var(--muted);
}
.badge-ban { background: #3a2424; color: var(--red); }
.badge-ok { background: #163425; color: var(--green); }
.badge-off { background: #2a2424; color: var(--yellow); }

.key-cell { font-family: var(--mono); color: var(--muted); }
.toggle-btn { font-size: 12px; padding: 3px 8px; }
.action-row { display: flex; gap: 6px; justify-content: flex-end; }

.eye-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 13px; }
.acc-actions { display: flex; gap: 6px; }

/* ---- commandcode model list ---- */
.model-list { display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip {
  background: #1d2230; border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font-family: var(--mono); font-size: 12.5px; color: var(--text);
}
.model-chip .ctx { color: var(--muted); font-size: 11px; margin-left: 6px; }
#exposed-list .model-chip { cursor: pointer; user-select: none; }
#exposed-list .model-chip:hover { border-color: var(--accent); }
.model-chip.chip-on { background: #163425; border-color: var(--green); color: var(--green); }

/* ---- istatistikler ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-box { background: #1d2230; border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; }
.mini-bar { display: flex; gap: 4px; align-items: flex-end; height: 70px; margin-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.bar-wrap { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; }
.bar { width: 45%; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar-ok { background: var(--green); }
.bar-err { background: var(--red); }
.bar-lbl { font-size: 10px; color: var(--muted); }
#daily-chart-hint { margin-top: 8px; }

/* ---- token istatistikleri ---- */
.token-grid { grid-template-columns: repeat(3, 1fr); margin-bottom: 8px; }
.token-in { color: #4fa8ff; }
.token-out { color: #ffa94d; }
.token-bar { height: 80px; }
.token-bar .bar-wrap { gap: 3px; }
.token-bar .bar { width: 100%; }
.bar-in { background: #4fa8ff; }
.bar-out { background: #ffa94d; }
.token-chip { font-size: 11px; color: var(--muted); font-family: var(--mono); }

/* ---- log tablosu ---- */
.log-table-wrap { overflow-x: auto; }
.logtable th { font-size: 11px; }
.logtable td { font-size: 12.5px; padding: 6px 8px; }
.small { font-size: 12px; }
.status-chip { font-family: var(--mono); font-size: 11.5px; padding: 2px 8px; border-radius: 5px; font-weight: 600; }
.st-ok { background: #163425; color: var(--green); }
.st-err { background: #3a2424; color: var(--red); }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #232837; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 20px; font-size: 14px; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

.error { color: var(--red); margin-top: 10px; font-size: 13px; }

@media (max-width: 700px) {
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .row-form { flex-direction: column; }
}
