:root {
  --bg: #0e1115;
  --panel: #181c22;
  --panel2: #1f242c;
  --border: #2a313b;
  --text: #e6e9ef;
  --muted: #8a93a0;
  --accent: #4a9eff;
  --ok: #2ecc71;
  --warn: #f39c12;
  --err: #e74c3c;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; display: flex; flex-direction: column; }

/* Login */
#login { align-items: center; justify-content: center; }
#login .card { width: 360px; }
#login h1 { margin: 0 0 16px; font-size: 18px; }
#login label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
#login input { width: 100%; padding: 10px; background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; font-size: 14px; margin-top: 4px; }
#login button { width: 100%; }
.err { color: var(--err); margin: 8px 0 0; min-height: 18px; font-size: 12px; }

/* App layout */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.err { background: var(--err); box-shadow: 0 0 8px var(--err); }
.dot.warn { background: var(--warn); }

main { flex: 1; padding: 20px; max-width: 1100px; width: 100%; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.grid div { background: var(--panel2); padding: 10px 12px; border-radius: 6px; }
.k { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.v { font-family: var(--mono); font-size: 13px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 6px 10px; }
button { background: var(--panel2); color: var(--text); border: 1px solid var(--border); padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background 0.15s; }
button:hover { background: var(--border); }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { background: #3a8be0; }
button.danger { background: var(--err); border-color: var(--err); color: white; }
button.danger:hover { background: #c0392b; }
button.ghost { background: transparent; }

.logs { background: #0a0d11; border: 1px solid var(--border); border-radius: 6px; padding: 12px; font-family: var(--mono); font-size: 12px; line-height: 1.5; max-height: 480px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin: 0 0 12px; color: #c8cdd4; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--muted); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

footer { padding: 12px 20px; text-align: center; border-top: 1px solid var(--border); }
.muted { color: var(--muted); }
.small { font-size: 11px; }

/* Main tabs (Send/Templates/Bots/Files) */
.main-tabs { margin-bottom: 16px; }
.main-tabs .tab { font-size: 13px; padding: 10px 16px; }

.section { display: block; }
.section.hidden { display: none; }
.section h3 { margin: 0 0 12px; font-size: 14px; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
label.full { display: block; }
label.checkbox-label { display: flex; align-items: center; gap: 6px; padding-top: 18px; }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; background: var(--panel2);
  border: 1px solid var(--border); color: var(--text); border-radius: 6px;
  font-size: 13px; margin-top: 4px; font-family: inherit;
}
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 100px; }
.row { display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 140px; margin-bottom: 0; }
.row.between { justify-content: space-between; align-items: center; }

/* Quick-Send-Bar in Status-Card */
.quick-bar { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.quick-bar:empty { display: none; }
.quick-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px; }
button.quick { background: var(--panel2); border-color: var(--border); padding: 6px 12px; font-size: 12px; }
button.quick:hover { background: var(--accent); border-color: var(--accent); color: white; }

/* List items (bots / templates) */
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.list-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; background: var(--panel2); padding: 12px; border-radius: 6px; border: 1px solid var(--border); }
.li-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.li-main strong { font-size: 14px; }
.li-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.li-actions button { padding: 6px 12px; font-size: 12px; }
.preview { background: #0a0d11; padding: 8px; border-radius: 4px; font-family: var(--mono); font-size: 11px; color: #c8cdd4; margin: 4px 0 0; max-height: 100px; overflow: auto; white-space: pre-wrap; }
.badge { background: var(--warn); color: #000; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: bold; }

/* Editors */
.editor { background: var(--panel2); padding: 16px; border-radius: 6px; border: 1px solid var(--border); margin-top: 12px; }
.editor h3 { margin-top: 0; }

code { background: var(--panel2); padding: 1px 6px; border-radius: 3px; font-family: var(--mono); font-size: 12px; }

/* Settings */
.settings-group { background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; margin-bottom: 12px; }
.settings-group h4 { margin: 0 0 10px; font-size: 13px; color: var(--accent); font-weight: 600; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; }
.rule-item { display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: var(--panel); border-radius: 4px; }
.rule-item .checkbox-label { padding-top: 0; flex: 0 0 auto; }
.rule-item input[type=text] { flex: 1; margin-top: 0; padding: 4px 8px; font-size: 12px; }
.target-item { padding: 6px 10px; background: var(--panel); border-radius: 4px; padding-top: 6px !important; }
.settings-raw { margin-top: 16px; }
.settings-raw summary { cursor: pointer; font-size: 12px; color: var(--muted); padding: 4px 0; }
input[type=time], input[type=number] { font-family: var(--mono); }
