:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e3e3e8;
  --accent: #b3261e;
  --accent-soft: #fbeae9;
  --green: #1f7a3d;
  --blue: #1d5fd1;
  --radius: 12px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
[hidden] { display: none !important; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: #1d1d1f; color: #fff; padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .brand { font-weight: 700; font-size: 16px; padding: 0 10px 16px; }
.sidebar .section { color: #8e8e93; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 16px 10px 6px; }
.sidebar a, .sidebar button { color: #e5e5ea; padding: 8px 10px; border-radius: 8px; text-align: left; background: none; border: 0; font: inherit; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar a:hover, .sidebar button:hover { background: #2c2c2e; }
.sidebar a.active { background: var(--accent); color: #fff; }
.main { padding: 28px 32px; max-width: 1000px; width: 100%; }

.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field .label { font-weight: 600; font-size: 13px; }
.hint, small.hint { color: var(--muted); font-size: 12.5px; }
p.hint { background: #fff8e6; border: 1px solid #f3e1b0; padding: 10px 12px; border-radius: 10px; margin: 0 0 16px; }
input, textarea, select { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--text); width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 38px; width: 80px; }
textarea { resize: vertical; }
.check { flex-direction: row; align-items: center; gap: 8px; }

button { font: inherit; cursor: pointer; border-radius: 9px; padding: 9px 16px; border: 1px solid var(--line); background: #fff; color: var(--text); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: #b00020; border-color: #f0c2c8; background: #fff; }
button.small { padding: 5px 10px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eee; }
.badge.green { background: #e3f4e8; color: var(--green); }
.badge.grey { background: #eee; color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; background: #f0f0f3; margin-left: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
tr.link { cursor: pointer; }
tr.link:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.preview { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat { background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.msg.guest { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.msg.bot { align-self: flex-end; background: #f1f1f4; }
.msg.admin { align-self: flex-end; background: #e8f1ff; }

pre.code { background: #1d1d1f; color: #f5f5f7; padding: 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; margin: 0 0 10px; }
details { margin: 6px 0 12px; }
summary { cursor: pointer; color: var(--muted); }

.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.error { color: #b00020; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1d1d1f; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 10; max-width: 420px; }
.toast.err { background: #b00020; }
.stat { font-size: 22px; font-weight: 700; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .sidebar .section, .sidebar .brand { display: none; }
  .main { padding: 20px 16px; }
  .two { grid-template-columns: 1fr; }
  .msg { max-width: 92%; }
}
