/* ===== Локальный шрифт Inter (без Google Fonts CDN) ===== */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/inter-700.woff2') format('woff2');
}

/* ===== Design System: Notion-inspired Government Registry ===== */
/* Palette: Notion warmth + Airtable blue + Stripe tnum + Intercom statuses */

:root {
  --bg-page: #f6f5f4;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f1f0ef;
  --bg-chat: #fafaf9;
  --border: rgba(0,0,0,0.08);
  --border-subtle: rgba(0,0,0,0.04);
  --text-primary: #1f1f1f;
  --text-secondary: #6b6b6b;
  --text-tertiary: #9b9b9b;
  --accent: #1b61c9;
  --accent-hover: #1550a8;
  --accent-light: #e8f0fe;
  --status-active-bg: #ddf4e4;
  --status-active-text: #2ea043;
  --status-inactive-bg: #f1f0ef;
  --status-inactive-text: #9b9b9b;
  --status-processing-bg: #fef3c7;
  --status-processing-text: #d97706;
  --danger: #d1242f;
  --danger-light: #ffebe9;
  --chat-user-bg: #1b61c9;
  --chat-ai-bg: #f1f0ef;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tnum { font-feature-settings: "tnum"; }
.text-display { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
.text-heading { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.text-body { font-size: 13px; color: var(--text-secondary); }
.text-small { font-size: 11px; color: var(--text-tertiary); }

.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 500; padding: 6px 14px;
  border-radius: 6px; border: none; cursor: pointer; transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text-secondary);
  font-size: 13px; font-weight: 500; padding: 6px 12px;
  border-radius: 6px; border: 1px solid var(--border); cursor: pointer; transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; color: var(--text-tertiary);
  font-size: 12px; padding: 4px 8px; border-radius: 4px;
  border: none; cursor: pointer; transition: all 0.15s;
}
.btn-ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }

.btn-danger {
  display: inline-flex; align-items: center;
  background: none; color: var(--danger); padding: 4px;
  border-radius: 4px; border: none; cursor: pointer; transition: background 0.15s;
}
.btn-danger:hover { background: var(--danger-light); }

.badge-active { display: inline-block; background: var(--status-active-bg); color: var(--status-active-text); font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }
.badge-inactive { display: inline-block; background: var(--status-inactive-bg); color: var(--status-inactive-text); font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }
.badge-processing { display: inline-block; background: var(--status-processing-bg); color: var(--status-processing-text); font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 4px; }

.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; width: 100%; display: block; transition: border-color .15s, transform .1s; }
button.stat-card { font: inherit; color: inherit; appearance: none; text-align: left; }
button.stat-card:hover { border-color: var(--accent); cursor: pointer; }
button.stat-card:active { transform: scale(0.99); }
.stat-card .stat-value { font-size: 22px; font-weight: 600; font-feature-settings: "tnum"; color: var(--text-primary); }
.stat-card .stat-label { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

.table-row-hover:hover { background: var(--bg-surface-hover); }
.table-header { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 16px; }

.input-field {
  width: 100%; padding: 6px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-surface); color: var(--text-primary); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.input-field::placeholder { color: var(--text-tertiary); }

.nav-tab {
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; transition: all 0.15s;
  color: var(--text-secondary); background: transparent;
}
.nav-tab:hover { background: var(--bg-surface-hover); }
.nav-tab.active { background: var(--accent-light); color: var(--accent); }

#ai-chat-panel { transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease; }
#ai-chat-panel.collapsed { width: 0 !important; min-width: 0 !important; overflow: hidden; opacity: 0; border-left: none; }

.chat-fab {
  position: fixed; right: 16px; bottom: 24px;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: none; align-items: center; justify-content: center; z-index: 40;
  transition: transform 0.2s;
}
.chat-fab:hover { transform: scale(1.08); }
.chat-fab.visible { display: flex; }

.chat-bubble-user { background: var(--chat-user-bg); color: #fff; border-radius: 16px 16px 4px 16px; padding: 8px 14px; font-size: 13px; max-width: 85%; }
.chat-bubble-ai { background: var(--chat-ai-bg); color: var(--text-primary); border-radius: 16px 16px 16px 4px; padding: 8px 14px; font-size: 13px; max-width: 85%; white-space: pre-wrap; }

/* ===== Tailwind CDN fallback ===== */
/* Если cdn.tailwindcss.com не загрузился (нет интернета в LAN),
   эти правила обеспечивают базовую работоспособность layout */
.flex { display: flex; }
.flex-1 { flex: 1 1 0%; }
.flex-col { flex-direction: column; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-1\.5 { gap: 6px; } .gap-2 { gap: 8px; }
.gap-2\.5 { gap: 10px; } .gap-3 { gap: 12px; }
.hidden { display: none !important; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }
.h-screen { height: 100vh; }
.min-h-screen { min-height: 100vh; }
.w-full { width: 100%; }
.p-2 { padding: 8px; } .p-2\.5 { padding: 10px; } .p-3 { padding: 12px; }
.p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; }
.px-2\.5 { padding-left: 10px; padding-right: 10px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-2\.5 { padding-top: 10px; padding-bottom: 10px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.mt-0\.5 { margin-top: 2px; }
.ml-auto { margin-left: auto; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }
.min-w-full { min-width: 100%; }
.max-w-sm { max-width: 24rem; }
.text-sm { font-size: 13px; } .text-xs { font-size: 11px; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; }
.rounded-md { border-radius: 6px; } .rounded-lg { border-radius: 8px; }
.text-center { text-align: center; } .text-right { text-align: right; }
.text-left { text-align: left; }
.whitespace-nowrap { white-space: nowrap; }
.inline { display: inline; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.gap-4 { gap: 16px; }
.w-2 { width: 8px; } .h-2 { height: 8px; } .w-3 { width: 12px; }
.w-8 { width: 32px; } .h-8 { height: 32px; }
.h-40 { height: 160px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-5 { margin-top: 20px; } .ml-2 { margin-left: 8px; }
.pb-1 { padding-bottom: 4px; } .pb-4 { padding-bottom: 16px; }
.pt-2 { padding-top: 8px; } .pt-5 { padding-top: 20px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-12 { padding-top: 48px; padding-bottom: 48px; }
.pl-2\.5 { padding-left: 10px; } .pb-2\.5 { padding-bottom: 10px; }
.p-8 { padding: 32px; }
.rounded-full { border-radius: 9999px; }
.opacity-0 { opacity: 0; }
.border { border: 1px solid var(--border); }
.divide-y > * + * { border-top: 1px solid var(--border-subtle); }
.max-w-md { max-width: 28rem; } .max-w-lg { max-width: 32rem; }
.max-w-3xl { max-width: 48rem; } .max-w-7xl { max-width: 80rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.pointer-events-none { pointer-events: none; }
.appearance-none { appearance: none; }
.outline-none { outline: none; }
.bottom-4 { bottom: 16px; } .right-4 { right: 16px; }
.left-0 { left: 0; } .inset-y-0 { top: 0; bottom: 0; }
.z-10 { z-index: 10; } .z-40 { z-index: 40; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.z-50 { z-index: 50; }
.transition { transition: all 0.15s; }
.cursor-pointer { cursor: pointer; }
input[type="file"].hidden { display: none !important; }

/* Stats grid fallback */
#stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 768px) { #stats-row { grid-template-columns: repeat(2, 1fr); } }

/* Flex layout fallback for the main split */
body > .flex { display: flex !important; }
body > .flex > .flex-1 { flex: 1 1 0%; overflow-y: auto; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }

.modal-bg { background-color: rgba(0, 0, 0, 0.4); backdrop-filter: blur(2px); }
