/* === VexCores - спокойная палитра === */
:root {
  /* Основа: тёплый off-white + графит */
  --bg: #f7f6f3;
  --bg-card: #ffffff;
  --bg-soft: #f1efea;
  --border: #e5e2db;
  --border-soft: #ebe8e2;
  
  /* Текст */
  --text: #2c2a26;
  --text-soft: #6b665e;
  --text-muted: #9a948a;
  
  /* Акцент: приглушённый сине-зелёный (teal) */
  --accent: #2d6a6a;
  --accent-hover: #245555;
  --accent-soft: #e8f0ef;
  
  /* Статусы */
  --status-ok: #4a7c59;
  --status-ok-bg: #e8f0ea;
  --status-warn: #b08545;
  --status-warn-bg: #f5ecd9;
  --status-error: #a04848;
  --status-error-bg: #f5e0e0;
  --status-info: #4a6a8a;
  --status-info-bg: #e3ebf2;
  
  --shadow-sm: 0 1px 2px rgba(44, 42, 38, 0.04);
  --shadow: 0 2px 8px rgba(44, 42, 38, 0.06);
  --shadow-lg: 0 6px 24px rgba(44, 42, 38, 0.08);
  
  --radius: 10px;
  --radius-sm: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --bg-card: #232220;
    --bg-soft: #2a2826;
    --border: #3a3833;
    --border-soft: #2f2d2a;
    --text: #e8e5df;
    --text-soft: #aca69a;
    --text-muted: #7a756c;
    --accent: #5fa0a0;
    --accent-hover: #76b5b5;
    --accent-soft: #2a3a3a;
    --status-ok: #7ab095;
    --status-ok-bg: #2a3a30;
    --status-warn: #d4ac6e;
    --status-warn-bg: #3a3025;
    --status-error: #c97878;
    --status-error-bg: #3a2828;
    --status-info: #7da0c4;
    --status-info-bg: #2a3340;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent); text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--accent-hover); }

.layout {
  max-width: 760px; margin: 0 auto; padding: 32px 20px 80px;
}

.layout.wide { max-width: 1080px; }

/* === Header / Nav === */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; margin-bottom: 24px;
  border-bottom: 1px solid var(--border-soft);
}
.brand {
  font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
  color: var(--text); text-decoration: none;
}
.brand .dot { color: var(--accent); }
.nav-links { display: flex; gap: 24px; }
.nav-links a {
  color: var(--text-soft); font-size: 14px; font-weight: 500;
}

/* === Карточки === */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }

h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }
h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
p { margin: 0 0 12px; color: var(--text-soft); }
.lead { font-size: 16px; color: var(--text-soft); margin-bottom: 24px; }

/* === Формы === */
label {
  display: block; margin: 14px 0 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.hint {
  font-size: 12px; font-weight: normal; color: var(--text-muted);
  margin-left: 6px;
}

input, textarea, select {
  width: 100%; padding: 11px 13px;
  font-size: 14px; font-family: inherit;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 90px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; font-size: 14px; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-soft); }

.btn-danger { background: var(--status-error); color: #fff; }
.btn-danger:hover { background: #8a3838; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn-row button { flex: 0 1 auto; }

/* === Алерты === */
.alert {
  padding: 14px 16px; border-radius: var(--radius-sm);
  margin: 16px 0; font-size: 14px;
  border: 1px solid;
}
.alert-success { background: var(--status-ok-bg); border-color: var(--status-ok); color: var(--status-ok); }
.alert-error { background: var(--status-error-bg); border-color: var(--status-error); color: var(--status-error); }
.alert-info { background: var(--status-info-bg); border-color: var(--status-info); color: var(--status-info); }

/* === Status page === */
.status-overall {
  text-align: center; padding: 32px 20px;
  border-radius: var(--radius); margin-bottom: 24px;
}
.status-overall.all-ok { background: var(--status-ok-bg); }
.status-overall.degraded { background: var(--status-warn-bg); }
.status-overall.outage { background: var(--status-error-bg); }

.status-overall .icon { font-size: 36px; margin-bottom: 8px; }
.status-overall .title { font-size: 18px; font-weight: 600; }
.status-overall.all-ok .title { color: var(--status-ok); }
.status-overall.degraded .title { color: var(--status-warn); }
.status-overall.outage .title { color: var(--status-error); }

.server-list { display: flex; flex-direction: column; gap: 10px; }

.server-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; background: var(--bg-card);
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius-sm);
}
.server-item.operational { border-left-color: var(--status-ok); }
.server-item.degraded { border-left-color: var(--status-warn); }
.server-item.outage { border-left-color: var(--status-error); }

.server-flag { font-size: 28px; line-height: 1; }
.server-info { flex: 1; min-width: 0; }
.server-name { font-weight: 600; font-size: 15px; }
.server-msg { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

.server-badge {
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: 0.3px;
  white-space: nowrap;
}
.server-badge.operational { background: var(--status-ok-bg); color: var(--status-ok); }
.server-badge.degraded { background: var(--status-warn-bg); color: var(--status-warn); }
.server-badge.outage { background: var(--status-error-bg); color: var(--status-error); }

/* === Тикеты — переписка === */
.thread {
  display: flex; flex-direction: column; gap: 10px;
  margin: 20px 0;
}
.bubble {
  padding: 12px 16px; border-radius: 14px;
  max-width: 78%; word-wrap: break-word;
  font-size: 14px; line-height: 1.45;
}
.bubble.client {
  background: var(--bg-soft); color: var(--text);
  border-bottom-left-radius: 4px;
  margin-right: auto;
}
.bubble.admin {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
.bubble .meta {
  font-size: 11px; opacity: 0.7;
  margin-bottom: 4px; font-weight: 500;
}
.bubble .text { white-space: pre-wrap; }

/* === Статусы тикетов === */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px;
}
.status-pill.open { background: var(--status-error-bg); color: var(--status-error); }
.status-pill.in_progress { background: var(--status-warn-bg); color: var(--status-warn); }
.status-pill.answered { background: var(--status-info-bg); color: var(--status-info); }
.status-pill.closed { background: var(--bg-soft); color: var(--text-muted); }

.status-pill::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

.ticket-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  padding: 12px 16px; background: var(--bg-soft);
  border-radius: var(--radius-sm); margin: 12px 0 20px;
  font-size: 13px; color: var(--text-soft);
}
.ticket-meta b { color: var(--text); margin-right: 4px; }

/* === Админка — список === */
.admin-tickets { display: flex; flex-direction: column; gap: 8px; }
.admin-ticket {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.admin-ticket:hover { background: var(--bg-soft); border-color: var(--accent); }
.admin-ticket .id { 
  font-family: ui-monospace, "SF Mono", monospace;
  color: var(--text-muted); font-size: 13px; width: 50px;
}
.admin-ticket .name {
  font-weight: 600; min-width: 100px; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-ticket .preview {
  flex: 1; min-width: 0; color: var(--text-soft); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-ticket .time {
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
}

/* === Admin server controls === */
.admin-servers { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.admin-server {
  padding: 14px 16px; background: var(--bg-soft);
  border-radius: var(--radius-sm);
}
.admin-server-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.admin-server-row .name { font-weight: 600; flex: 1; }
.admin-server select { width: auto; }
.admin-server input[type="text"] { margin-top: 8px; }

/* === Кнопка-toggle тёмная/светлая === */
.theme-toggle {
  background: transparent; color: var(--text-soft);
  border: 1px solid var(--border); padding: 6px 10px;
  border-radius: var(--radius-sm); font-size: 18px;
  cursor: pointer;
}

/* === Login === */
.login-box {
  max-width: 380px; margin: 80px auto;
}

/* === Footer === */
.footer {
  text-align: center; margin-top: 40px;
  font-size: 12px; color: var(--text-muted);
}

/* === Утилиты === */
.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; }
.center { text-align: center; }

@media (max-width: 600px) {
  .layout { padding: 20px 14px 60px; }
  .card { padding: 20px; }
  .nav-links { gap: 14px; }
  .admin-ticket { flex-wrap: wrap; }
  .admin-ticket .preview { width: 100%; }
}
