@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:          #F4F6F8;
  --bg2:         #FFFFFF;
  --surface:     #FFFFFF;
  --surface2:    #F0F3F7;
  --accent:      #0057D9;
  --accent-dark: #003D99;
  --accent-bg:   rgba(0,87,217,0.08);
  --ink:         #0A0A0A;
  --muted:       #5A6470;
  --border:      #E2E8F0;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.12);
  --sidebar-w:   240px;
  --f-display:   'Inter', system-ui, sans-serif;
  --f-body:      'Inter', system-ui, sans-serif;
  --f-mono:      'JetBrains Mono', monospace;
  --success:     #0D7A4E;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

/* PORTAL */
.portal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background:
    linear-gradient(135deg, rgba(0,87,217,0.04) 0%, transparent 50%),
    var(--bg);
}

.portal-ornament {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.3em;
  margin-bottom: 20px;
  opacity: 0.7;
}

.portal-title {
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  text-align: center;
}

.portal-subtitle {
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
  margin-bottom: 40px;
}

.portal-rule {
  width: 48px;
  height: 3px;
  background: var(--accent);
  margin: 0 auto 40px;
  border-radius: 2px;
}

.portal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  width: min(600px, 100%);
  margin-bottom: 40px;
}

.portal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  display: block;
}

.portal-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.portal-card-icon { font-size: 2rem; margin-bottom: 12px; }

.portal-card h2 {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  margin-bottom: 8px;
}

.portal-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.portal-footer { color: var(--muted); font-size: 0.85rem; }
.portal-footer a { color: var(--accent); text-decoration: none; }
.portal-footer a:hover { text-decoration: underline; }

/* LOGIN */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  width: min(440px, 100%);
  padding: 40px 36px;
}

.login-crest { text-align: center; margin-bottom: 28px; }
.login-crest h1 { font-weight: 700; font-size: 1.4rem; color: var(--ink); }
.login-crest p { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

.field-label, .form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-input, .form-input {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--f-body);
  font-size: 0.95rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s;
}
.field-input:focus, .form-input:focus { border-color: var(--accent); }

.telegram-widget-wrap {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.login-hint, .login-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
  text-align: center;
  margin-top: 12px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  text-align: center;
}
.btn-primary:hover { background: var(--accent-dark); }

.form-error { color: #C41E3A; font-size: 0.88rem; margin-top: 10px; min-height: 1.2em; }

.login-back { text-align: center; margin-top: 24px; }
.login-back a { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.login-back a:hover { text-decoration: underline; }

/* ADMIN LAYOUT */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform 0.24s ease;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-logo {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  line-height: 1.3;
}

.sidebar-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.45);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.55);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.13s, background 0.13s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  border-left: 3px solid transparent;
}

.nav-item:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-item.active { color: #fff; background: rgba(0,87,217,0.25); border-left-color: var(--accent); }
.nav-icon { width: 18px; text-align: center; flex-shrink: 0; opacity: 0.8; }

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.nav-item.logout { color: rgba(255,255,255,0.35); font-size: 0.85rem; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}

.topbar-status { color: var(--muted); font-size: 0.85rem; }

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--ink);
  font-size: 1.3rem;
}

.content-area { flex: 1; padding: 24px 28px; }
.content-section { display: none; }
.content-section.active { display: block; }

/* CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title { font-weight: 600; font-size: 1rem; color: var(--ink); }
.card-body { padding: 20px 22px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* BUTTONS */
.btn-secondary {
  padding: 8px 14px;
  font-weight: 500;
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.13s, background 0.13s;
  white-space: nowrap;
  text-decoration: none;
}
.btn-secondary:hover { border-color: var(--accent); background: var(--accent-bg); }
.btn-secondary:disabled { opacity: 0.4; cursor: default; }
.btn-secondary.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

.btn-danger {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  background: transparent;
  color: #C41E3A;
  border: 1px solid #FECDD3;
  border-radius: 6px;
  cursor: pointer;
}
.btn-danger:hover { background: #FFF1F2; }

.btn-view {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.btn-view:hover { border-color: var(--accent); }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: var(--surface2); }
th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-bg); }

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 4px;
}
.badge-active { color: var(--success); background: rgba(13,122,78,0.1); }
.badge-inactive { color: var(--muted); background: var(--surface2); }
.badge-online { color: var(--accent); background: var(--accent-bg); }

/* FORMS */
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--f-body);
  font-size: 0.95rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  outline: none;
  resize: vertical;
}
.form-field input:focus,
.form-field textarea:focus { border-color: var(--accent); }

.image-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.image-preview-grid img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.mat-form-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.mat-inline-img {
  max-width: 100%;
  width: min(280px, 100%);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.db-table-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.db-table-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.13s;
}
.db-table-card:hover, .db-table-card.selected { border-color: var(--accent); background: var(--accent-bg); }
.db-table-name { font-weight: 600; font-size: 0.9rem; }
.db-table-rows { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.db-viewer-data { display: none; }
.db-viewer-data.visible { display: block; }

.material-fullscreen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--surface);
  overflow-y: auto;
}
.material-fullscreen.visible { display: block; }
.material-fullscreen-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  min-height: 100vh;
}
.material-fullscreen-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.material-fullscreen-header h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.material-fullscreen-gallery {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}
.mat-fullscreen-img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.material-fullscreen-body {
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 1rem;
  color: var(--ink);
}
.tpl-msg {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.tpl-msg-head {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.tpl-msg-body {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.92rem;
}
.actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.admin-dialogs-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-dialog-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s;
}
.admin-dialog-card:hover { border-color: var(--accent); }
.admin-dialog-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.admin-dialog-body { flex: 1; min-width: 0; }
.admin-dialog-name { font-weight: 600; }
.admin-dialog-assistant { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.admin-dialog-preview {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-dialog-time { font-size: 0.78rem; color: var(--muted); flex-shrink: 0; }

/* Chat thread (admin + shared) */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}
.dialog-fs-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.dialog-fs-thread {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  max-height: min(60vh, 520px);
  overflow-y: auto;
}
.chat-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.92rem;
  word-break: break-word;
}
.chat-bubble.them {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.me .chat-bubble-sender { color: rgba(255,255,255,0.8); }
.chat-bubble-text { white-space: pre-wrap; }
.chat-bubble-sender {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* SETTINGS FORM */
.settings-form { max-width: 640px; }
.settings-section { margin-bottom: 28px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; }
.settings-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 16px;
}
.settings-field { margin-bottom: 16px; }
.settings-field:last-child { margin-bottom: 0; }
.settings-field label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 6px;
}
.settings-field .field-key {
  font-family: var(--f-mono);
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.settings-field .field-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}
.settings-field input[type="text"],
.settings-field input[type="url"],
.settings-field input[type="number"] {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  font-size: 0.92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.settings-field input[type="number"] { max-width: 140px; }
.settings-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.settings-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}

/* Legacy setting-row (if used elsewhere) */
.setting-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; }
.setting-name { font-weight: 600; font-size: 0.95rem; }
.setting-key { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.setting-input {
  width: 100px;
  padding: 7px 10px;
  font-family: var(--f-mono);
  font-size: 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: right;
  outline: none;
}
.setting-input:focus { border-color: var(--accent); }

.key-display {
  background: var(--ink);
  color: #7DD3FC;
  font-family: var(--f-mono);
  font-size: 0.95rem;
  padding: 14px;
  border-radius: 8px;
  text-align: center;
  word-break: break-all;
  margin-bottom: 6px;
}

pre {
  background: var(--surface2);
  font-family: var(--f-mono);
  font-size: 0.85rem;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.visible { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}

.modal-body { padding: 20px 22px; }
.modal-body .material-content {
  white-space: pre-wrap;
  line-height: 1.7;
  margin-bottom: 16px;
}

.modal-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.modal-gallery img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  max-width: 340px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: #C41E3A; }

/* AUTH GATE */
.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.auth-gate-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* RESPONSIVE */
@media (max-width: 800px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar { padding: 0 16px; }
  .content-area { padding: 16px; }
  .portal-cards { grid-template-columns: 1fr; }
  .login-box { padding: 28px 22px; }
}

@media (max-width: 480px) {
  .topbar-status { display: none; }
  .toast { right: 12px; bottom: 12px; left: 12px; max-width: none; }
}

/* ASSISTANT CABINET */
.cabinet-app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 32px;
}
.cabinet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.cabinet-brand { font-weight: 700; font-size: 1.05rem; }
.cabinet-user { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.cabinet-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.cabinet-tab {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
}
.cabinet-tab.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}
.cabinet-main { padding: 16px 12px; }
.cabinet-section { display: none; }
.cabinet-section.active { display: block; }

.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.mat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
}
.mat-card:hover { border-color: var(--accent); }
.mat-card-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: var(--surface2);
}
.mat-card-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.mat-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 12px 4px;
}
.mat-card-tags {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0 12px 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.stat-val { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

.cal-status { font-size: 0.88rem; color: var(--muted); margin-bottom: 12px; }
.cal-status.error { color: #C41E3A; }
.cal-day { margin-bottom: 16px; }
.cal-day-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.cal-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}
.cal-slot {
  padding: 10px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface2);
}
.cal-slot.free {
  background: rgba(0,87,217,0.1);
  border-color: var(--accent);
  color: var(--accent);
}
.cal-slot.busy {
  opacity: 0.45;
  cursor: not-allowed;
}
.cal-slot.selected {
  outline: 2px solid var(--accent);
  background: rgba(0,87,217,0.18);
}
.book-form-inline {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
}
.book-form-inline h3 { font-size: 0.95rem; margin-bottom: 12px; }
.book-form-inline input,
.book-form-inline textarea {
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.95rem;
}
