/* crm/static/css/main.css */

/* ── Design tokens ─────────────────────────────── */
:root {
  --bg:        #0b1220;
  --paper:     #0f1629;
  --paper-2:   #111c30;
  --line:      #1a2440;
  --muted:     #9aa6bd;
  --text:      #e6ebf3;
  --brand:     #38bdf8;
  --brand-dim: #1a4a66;
  --ok:        #22c55e;
  --ok-bg:     #0d2e1a;
  --ok-line:   #1a4a2a;
  --warn:      #ef4444;
  --warn-bg:   #2a0d0e;
  --warn-line: #4a1a1c;
  --amber:     #f59e0b;
  --amber-bg:  #2a1e08;
  --amber-line:#4a3510;

  --radius-sm: 8px;
  --radius:    10px;
  --radius-lg: 14px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;

  --sidebar-w:      64px;
  --sidebar-w-open: 220px;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, button { outline: none; }

/* ── Layout ─────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .2s ease;
}
.layout.open { grid-template-columns: var(--sidebar-w-open) 1fr; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  background: #080e1a;
  border-right: 1px solid var(--line);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.sb-logo-icon {
  width: 32px; height: 32px;
  background: var(--brand);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: #000; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.sb-logo-text { font-weight: 600; font-size: 15px; white-space: nowrap; opacity: 0; display: none; }
.layout.open .sb-logo-text { opacity: 1; display: block; }

.sb-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 40px; padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.sb-item:hover { background: var(--paper); border-color: var(--line); color: var(--text); }
.sb-item.active { background: var(--paper-2); border-color: var(--line); color: var(--text); }
.sb-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sb-label { font-size: 13px; white-space: nowrap; opacity: 0; display: none; }
.layout.open .sb-label { opacity: 1; display: block; }
.sb-spacer { flex: 1; }
.sb-section {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: #54637f; padding: 15px 10px 5px; white-space: nowrap;
}
/* свёрнутый сайдбар: вместо текста секции — тонкий разделитель */
.layout:not(.open) .sb-section {
  height: 0; padding: 0; margin: 8px 6px; border-top: 1px solid var(--line);
  font-size: 0; color: transparent; overflow: hidden;
}

/* ── Main area ───────────────────────────────────── */
.main { display: flex; flex-direction: column; min-height: 100vh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 60px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 10;
}
.topbar-toggle {
  width: 36px; height: 36px;
  background: none; border: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: color .15s;
}
.topbar-toggle:hover { color: var(--text); }
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 24px; flex: 1; }

/* ── Cards ───────────────────────────────────────── */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-weight: 500;
}
.card-body { padding: 18px; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--muted);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--paper-2); color: var(--text); }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #000; font-weight: 600;
}
.btn-primary:hover { background: #4ecffe; border-color: #4ecffe; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }

/* ── Inputs ──────────────────────────────────────── */
.input {
  height: 36px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-size: 13px; font-family: var(--font);
  transition: border-color .15s;
  width: 100%;
}
.input:focus { border-color: var(--brand); }
.input::placeholder { color: var(--muted); }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }

/* ── Badges ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: 999px; border: 1px solid;
  font-size: 11px; font-weight: 500;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line);   }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-occ  { background: var(--amber-bg);color: var(--amber);border-color: var(--amber-line);}
.badge-muted{ background: #111a2e; color: var(--muted); border-color: var(--line); }

/* ── Table ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid #111a2e;
  font-size: 13px;
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #0d1525; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Pagination ──────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.pagination-info { font-size: 12px; color: var(--muted); margin-right: auto; }

/* ── Search bar ──────────────────────────────────── */
.search-bar { position: relative; }
.search-bar .input { padding-left: 36px; }
.search-bar-icon { position: absolute; left: 10px; top: 0; bottom: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); pointer-events: none; }

/* ── Auth page ───────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 36px 32px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-mark {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--brand); color: #000;
  font-size: 22px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.auth-logo h1 { font-size: 20px; font-weight: 600; }
.auth-logo p  { font-size: 13px; color: var(--muted); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-error {
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  color: var(--warn); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px;
}
