:root {
  --bg: #0d111a;
  --panel: #121722;
  --panel-2: #171d29;
  --panel-3: #1d2432;
  --line: rgba(255, 255, 240, 0.1);
  --line-strong: rgba(255, 255, 240, 0.17);
  --text: #fffff2;
  --muted: rgba(255, 255, 240, 0.62);
  --accent: #f40552;
  --accent-light: #ff3f83;
  --green: #31d58b;
  --orange: #ff9b52;
  --red: #ff5574;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: radial-gradient(circle at 80% -10%, rgba(244, 5, 82, .13), transparent 34%), var(--bg); }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.eyebrow { margin: 0 0 7px; color: var(--accent-light); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 17px; background: linear-gradient(145deg, var(--accent-light), #b6033e); box-shadow: 0 14px 35px rgba(244, 5, 82, .27); color: white; font-size: 25px; font-weight: 900; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 18px; box-shadow: none; }

.auth-page { display: grid; place-items: center; padding: 24px; }
.auth-shell { width: min(100%, 430px); }
.auth-card { padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(18, 23, 34, .92); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.auth-card .brand-mark { margin-bottom: 28px; }
.auth-card h1 { margin: 0; font-size: clamp(29px, 7vw, 38px); letter-spacing: -.04em; }
.auth-copy { margin: 11px 0 28px; color: var(--muted); line-height: 1.55; }
.auth-form { display: grid; gap: 17px; }
label { display: grid; gap: 8px; color: rgba(255,255,240,.82); font-size: 13px; font-weight: 650; }
input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; outline: none; background: #0d121b; color: var(--text); transition: border-color .16s, box-shadow .16s; }
input { height: 45px; padding: 0 13px; }
textarea { padding: 14px; resize: vertical; }
input:focus, textarea:focus { border-color: rgba(244,5,82,.72); box-shadow: 0 0 0 3px rgba(244,5,82,.12); }
.auth-foot { margin: 24px 0 0; color: rgba(255,255,240,.35); font-size: 12px; text-align: center; }
.alert { margin-bottom: 18px; padding: 11px 13px; border-radius: 9px; font-size: 13px; }
.alert.error { border: 1px solid rgba(255,85,116,.25); background: rgba(255,85,116,.09); color: #ff9eb1; }

.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 750; transition: transform .12s, background .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .42; transform: none; }
.button.full { width: 100%; min-height: 47px; }
.button.small { min-height: 32px; padding: 0 11px; font-size: 12px; }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: #ff145f; }
.button.neutral { border-color: var(--line); background: var(--panel-3); }
.button.neutral:hover { background: #272f40; }
.button.success { border-color: rgba(49,213,139,.28); background: rgba(49,213,139,.12); color: #66e5a9; }
.button.danger-soft { border-color: rgba(255,85,116,.22); background: rgba(255,85,116,.09); color: #ff8ca2; }
.button.danger { background: #c91f43; color: white; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; cursor: pointer; background: transparent; color: var(--muted); font-size: 18px; }
.icon-button:hover { background: rgba(255,255,240,.07); color: var(--text); }
.text-button { padding: 0; border: 0; cursor: pointer; background: transparent; color: var(--muted); font-size: 12px; }
.text-button:hover { color: var(--text); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; display: flex; flex-direction: column; padding: 21px 15px 15px; border-right: 1px solid var(--line); background: rgba(13,17,26,.94); backdrop-filter: blur(18px); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 5px 22px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand span { margin-top: 1px; color: var(--muted); font-size: 12px; }
.new-bot { width: 100%; margin-bottom: 16px; }
.bot-list { display: grid; gap: 4px; overflow-y: auto; }
.bot-nav-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; background: transparent; text-align: left; }
.bot-nav-item:hover { background: rgba(255,255,240,.045); }
.bot-nav-item.active { border-color: var(--line); background: var(--panel-2); }
.bot-nav-icon { width: 31px; height: 31px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 9px; background: rgba(244,5,82,.12); color: #ff79a5; font-weight: 850; }
.bot-nav-copy { min-width: 0; flex: 1; }
.bot-nav-copy strong, .bot-nav-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-nav-copy strong { font-size: 13px; }
.bot-nav-copy small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.nav-status { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #566071; }
.nav-status.running { background: var(--green); box-shadow: 0 0 0 4px rgba(49,213,139,.1); }
.sidebar-account { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 13px 6px 3px; border-top: 1px solid var(--line); }
.account-dot { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(145deg, #ff5791, #970331); }
.sidebar-account div { min-width: 0; flex: 1; }
.sidebar-account strong, .sidebar-account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: 12px; }
.sidebar-account span { margin-top: 2px; color: var(--muted); font-size: 10px; }

.workspace { min-width: 0; padding: 0 clamp(22px, 4vw, 58px) 58px; }
.topbar { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 23px; letter-spacing: -.03em; }
.connection-pill { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,240,.025); color: var(--muted); font-size: 11px; }
.connection-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }
.connection-pill.online span { background: var(--green); }
.empty-state { min-height: calc(100vh - 155px); display: grid; align-content: center; justify-items: center; padding: 40px; text-align: center; }
.empty-icon { width: 82px; height: 82px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 24px; background: var(--panel); color: var(--accent-light); font: 800 20px ui-monospace, monospace; }
.empty-state h2 { margin: 25px 0 8px; font-size: 25px; }
.empty-state p { max-width: 470px; margin: 0 0 23px; color: var(--muted); line-height: 1.55; }
.bot-workspace { padding-top: 28px; }
.card { border: 1px solid var(--line); border-radius: 14px; background: rgba(18,23,34,.86); box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.overview-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(330px, .9fr); gap: 14px; }
.status-card { min-height: 125px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 23px; }
.card-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.status-card h2 { margin: 7px 0 3px; font-size: 24px; }
.status-card p { margin: 0; color: var(--muted); font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.status-badge { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 750; }
.status-badge span { width: 8px; height: 8px; border-radius: 50%; background: #5a6575; }
.status-badge.running { border-color: rgba(49,213,139,.22); background: rgba(49,213,139,.07); color: #6be8ad; }
.status-badge.running span { background: var(--green); box-shadow: 0 0 0 4px rgba(49,213,139,.1); }
.stats-card { display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; min-height: 125px; padding: 18px; }
.stats-card div { min-width: 0; padding: 8px 18px; border-left: 1px solid var(--line); }
.stats-card div:first-child { border-left: 0; }
.stats-card span, .stats-card strong { display: block; }
.stats-card span { margin-bottom: 8px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.stats-card strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.action-bar { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 12px; }
.action-divider { width: 1px; height: 26px; margin: 0 2px; background: var(--line); }
.operation-state { margin-left: auto; color: var(--orange); font-size: 12px; }

.tabs { display: flex; gap: 25px; margin-top: 28px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { position: relative; padding: 0 1px 13px; border: 0; cursor: pointer; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; border-radius: 2px; background: var(--accent); }
.tab-panel { display: none; padding-top: 18px; }
.tab-panel.active { display: block; }
.console-card { overflow: hidden; }
.console-head, .editor-head, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.console-head { min-height: 44px; padding: 0 15px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.console-output { height: 390px; margin: 0; padding: 16px; overflow: auto; background: #090d14; color: #d8dfd9; font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.console-output .error { color: #ff7892; }
.console-input-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 13px; border-top: 1px solid var(--line); background: #0e131c; }
.console-input-row span { color: var(--green); font: 700 13px ui-monospace, monospace; }
.console-input-row input { height: 35px; padding: 0; border: 0; background: transparent; font: 12px ui-monospace, monospace; box-shadow: none; }
.console-input-row button { height: 31px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; background: var(--panel-3); font-size: 11px; font-weight: 700; }
.file-layout { min-height: 515px; display: grid; grid-template-columns: 245px minmax(0, 1fr); overflow: hidden; }
.file-layout > aside { border-right: 1px solid var(--line); }
.file-layout .section-head { min-height: 48px; padding: 0 13px; border-bottom: 1px solid var(--line); font-size: 12px; }
.file-list { height: 465px; padding: 8px; overflow: auto; }
.file-item { width: 100%; padding: 8px 9px; border: 0; border-radius: 7px; cursor: pointer; background: transparent; color: var(--muted); font: 11px ui-monospace, monospace; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item:hover, .file-item.active { background: rgba(255,255,240,.055); color: var(--text); }
.editor-pane { min-width: 0; }
.editor-head { height: 48px; padding: 0 13px; border-bottom: 1px solid var(--line); color: var(--muted); font: 11px ui-monospace, monospace; }
#file-editor { width: 100%; height: 465px; display: block; padding: 16px; border: 0; border-radius: 0; resize: none; background: #090d14; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; box-shadow: none; }
.form-card { padding: 23px; }
.form-card h3 { margin: 0 0 7px; font-size: 18px; }
.form-card p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.form-card .section-head { align-items: flex-start; }
.code-area { min-height: 330px; margin-top: 20px; background: #090d14; font: 12px/1.6 ui-monospace, monospace; }
code { padding: 2px 5px; border-radius: 5px; background: rgba(255,255,240,.06); color: #ff94b8; font: 11px ui-monospace, monospace; }
.notice { margin-top: 13px; padding: 11px 13px; border: 1px solid rgba(49,213,139,.16); border-radius: 8px; background: rgba(49,213,139,.05); color: #8adfba; font-size: 12px; }
.notice.warning { border-color: rgba(255,155,82,.17); background: rgba(255,155,82,.05); color: #eab184; }
.upload-zone { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; margin-top: 20px; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-zone label { min-height: 110px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; padding: 18px; border: 1px dashed rgba(255,255,240,.2); border-radius: 11px; cursor: pointer; background: rgba(255,255,240,.02); }
.upload-zone label:hover { border-color: rgba(244,5,82,.6); background: rgba(244,5,82,.035); }
.upload-zone small { color: var(--muted); font-weight: 400; }
.upload-icon { color: var(--accent-light); font-size: 25px; }
.settings-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 13px; margin-top: 20px; }
hr { height: 1px; margin: 28px 0; border: 0; background: var(--line); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.danger-zone strong { font-size: 14px; }
.danger-zone p { margin-top: 5px; }

dialog { width: min(92vw, 450px); padding: 0; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--panel-2); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5,8,13,.76); backdrop-filter: blur(4px); }
.dialog-card { display: grid; gap: 17px; padding: 23px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 23px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 5px; }
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; }
.toast { max-width: min(380px, calc(100vw - 40px)); padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #202838; box-shadow: 0 12px 35px rgba(0,0,0,.3); font-size: 13px; animation: toast-in .18s ease-out; }
.toast.error { border-color: rgba(255,85,116,.32); color: #ff9bb0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 950px) {
  .overview-grid { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr 1fr; }
  .settings-form .button { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .mobile-only { display: grid !important; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: 270px; transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.45); }
  .sidebar.open { transform: translateX(0); }
  .workspace { padding: 0 15px 35px; }
  .topbar { min-height: 78px; justify-content: flex-start; }
  .topbar .connection-pill { margin-left: auto; }
  .topbar h1 { font-size: 19px; }
  .overview-grid { grid-template-columns: 1fr; }
  .status-card { align-items: flex-start; flex-direction: column; }
  .stats-card div { padding: 8px 10px; }
  .action-bar { align-items: stretch; flex-wrap: wrap; }
  .action-bar .button { flex: 1 1 130px; }
  .action-divider { display: none; }
  .operation-state { width: 100%; margin: 4px 3px 0; }
  .file-layout { grid-template-columns: 1fr; }
  .file-layout > aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .file-list { height: 180px; }
  #file-editor { height: 390px; }
  .upload-zone { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 470px) {
  .auth-card { padding: 30px 22px; }
  .connection-pill b { display: none; }
  .stats-card { grid-template-columns: 1fr; }
  .stats-card div, .stats-card div:first-child { padding: 12px; border-top: 1px solid var(--line); border-left: 0; }
  .stats-card div:first-child { border-top: 0; }
}
