/* ================================================================
   Qazcontent AI Newsroom — Design System
   Modular, theme-aware, newsroom-grade
   ================================================================ */

/* ----------------------------------------------------------------
   1. CSS Custom Properties (Tokens)
   ---------------------------------------------------------------- */
:root {
  /* Colors — Light */
  --c-bg:          #f0f2f5;
  --c-surface:     #ffffff;
  --c-surface-2:   #f8fafc;
  --c-border:      #e2e8f0;
  --c-border-2:    #cbd5e1;
  --c-text:        #1a202c;
  --c-text-2:      #4a5568;
  --c-text-3:      #718096;
  --c-primary:     #3b82f6;
  --c-primary-dk:  #2563eb;
  --c-primary-bg:  #eff6ff;
  --c-success:     #10b981;
  --c-success-bg:  #d1fae5;
  --c-success-text:#065f46;
  --c-warning:     #f59e0b;
  --c-warning-bg:  #fef3c7;
  --c-warning-text:#92400e;
  --c-error:       #ef4444;
  --c-error-bg:    #fee2e2;
  --c-error-text:  #991b1b;

  /* Sidebar */
  --c-sidebar:     #1e293b;
  --c-sidebar-2:   #0f172a;
  --c-sidebar-txt: #94a3b8;
  --c-sidebar-act: #3b82f6;
  --sidebar-w:     244px;

  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* Misc */
  --radius:    8px;
  --radius-sm: 5px;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

[data-theme="dark"] {
  --c-bg:          #0f172a;
  --c-surface:     #1e293b;
  --c-surface-2:   #162032;
  --c-border:      #334155;
  --c-border-2:    #475569;
  --c-text:        #f1f5f9;
  --c-text-2:      #cbd5e1;
  --c-text-3:      #94a3b8;
  --c-primary-bg:  #1e3a8a;
  --c-success-bg:  #064e3b;
  --c-success-text:#6ee7b7;
  --c-warning-bg:  #78350f;
  --c-warning-text:#fde68a;
  --c-error-bg:    #7f1d1d;
  --c-error-text:  #fca5a5;
}

/* ----------------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul, ol { list-style: none; }

/* ----------------------------------------------------------------
   3. Layout
   ---------------------------------------------------------------- */
.app-wrapper   { display: flex; min-height: 100vh; }
.main-content  { flex: 1; padding: var(--sp-6) var(--sp-8); overflow-x: hidden;
                 min-width: 0; max-width: calc(100vw - var(--sidebar-w)); }

/* ----------------------------------------------------------------
   4. Sidebar
   ---------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--c-sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: thin;
}

.sidebar-brand {
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  border-bottom: 1px solid rgba(255,255,255,.07);
  letter-spacing: -.01em;
}
.brand-icon { font-size: 1.25rem; }

.sidebar-nav { flex: 1; padding: var(--sp-2) 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  color: var(--c-sidebar-txt);
  font-size: .85rem;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
  cursor: pointer;
}
.nav-item:hover {
  background: rgba(255,255,255,.05);
  color: #e2e8f0;
  text-decoration: none;
}
.nav-item.active {
  background: rgba(59,130,246,.15);
  color: #93c5fd;
  border-left-color: var(--c-sidebar-act);
}

.nav-divider     { height: 1px; background: rgba(255,255,255,.06); margin: var(--sp-2) 0; }
.nav-section-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.28);
  padding: var(--sp-2) var(--sp-4) 0;
  font-weight: 600;
}
.nav-admin { }

.sidebar-footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.user-info   { color: var(--c-sidebar-txt); font-size: .8rem; line-height: 1.5; }
.user-name   { display: block; color: #e2e8f0; font-weight: 600; font-size: .85rem; }
.logout-link { color: var(--c-sidebar-txt); font-size: .78rem; }
.logout-link:hover { color: #f87171; text-decoration: none; }

.sidebar-controls { display: flex; gap: var(--sp-2); align-items: center; }
.btn-icon {
  background: rgba(255,255,255,.06);
  border: none;
  cursor: pointer;
  color: var(--c-sidebar-txt);
  font-size: .82rem;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.btn-icon:hover { background: rgba(255,255,255,.12); color: #e2e8f0; }
.inline-form { display: inline; }

/* ----------------------------------------------------------------
   5. Page Header
   ---------------------------------------------------------------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.page-header-left { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.page-header h1   { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.page-subtitle    { color: var(--c-text-3); font-size: .875rem; margin-top: var(--sp-1); }
.btn-back {
  color: var(--c-text-3);
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
.btn-back:hover { color: var(--c-text); text-decoration: none; }

/* ----------------------------------------------------------------
   6. Cards
   ---------------------------------------------------------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: var(--sp-4); }

.card-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-3);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
}
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-4);
}
.card-title-row .card-title { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

/* ----------------------------------------------------------------
   7. Buttons
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .12s, opacity .12s, box-shadow .12s;
  white-space: nowrap;
  line-height: 1.4;
  font-family: var(--font);
}
.btn:hover { opacity: .9; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary   { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dk); opacity: 1; }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-surface-2); opacity: 1; }
.btn-danger    { background: var(--c-error); color: #fff; }
.btn-warning   { background: var(--c-warning); color: #fff; }
.btn-success   { background: var(--c-success); color: #fff; }
.btn-sm        { padding: 4px 9px; font-size: .78rem; }
.btn-full      { width: 100%; }
.btn-text      {
  background: none; border: none; cursor: pointer; color: var(--c-text-3);
  font-size: .82rem; padding: 0; font-family: var(--font);
  text-decoration: none;
}
.btn-text:hover { color: var(--c-text); text-decoration: none; }

/* ----------------------------------------------------------------
   8. Badges
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}

.badge-count     { background: var(--c-border); color: var(--c-text-3); }
.badge-success   { background: var(--c-success-bg); color: var(--c-success-text); }
.badge-warning   { background: var(--c-warning-bg); color: var(--c-warning-text); }
.badge-error     { background: var(--c-error-bg);   color: var(--c-error-text); }
.badge-gray      { background: var(--c-border);      color: var(--c-text-3); }

/* Language badges */
.badge-kk { background: #fef3c7; color: #92400e; }
.badge-ru { background: #dbeafe; color: #1e40af; }
[data-theme="dark"] .badge-kk { background: #451a03; color: #fbbf24; }
[data-theme="dark"] .badge-ru { background: #1e3a8a; color: #93c5fd; }

/* Role badges */
.badge-admin      { background: #fce7f3; color: #9d174d; }
.badge-journalist { background: #e0e7ff; color: #3730a3; }
[data-theme="dark"] .badge-admin      { background: #500724; color: #f9a8d4; }
[data-theme="dark"] .badge-journalist { background: #1e1b4b; color: #a5b4fc; }

/* Tool badges */
.badge-rewrite   { background: #eff6ff; color: #1d4ed8; }
.badge-translate { background: #f0fdf4; color: #15803d; }
.badge-article   { background: #fdf4ff; color: #6b21a8; }
.badge-smm       { background: #fff7ed; color: #c2410c; }
.badge-factcheck { background: #fefce8; color: #854d0e; }
[data-theme="dark"] .badge-rewrite   { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .badge-translate { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-article   { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .badge-smm       { background: #431407; color: #fdba74; }
[data-theme="dark"] .badge-factcheck { background: #422006; color: #fde68a; }

/* Log level badges */
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-warning { background: #fef3c7; color: #92400e; }
/* .badge-error — already defined */
[data-theme="dark"] .badge-info    { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .badge-warning { background: #78350f; color: #fde68a; }

/* ----------------------------------------------------------------
   9. Alerts / Flash messages
   ---------------------------------------------------------------- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  margin-bottom: var(--sp-4);
  font-size: .875rem;
  border-width: 1px;
  border-style: solid;
}
.alert-success { background: var(--c-success-bg); color: var(--c-success-text); border-color: #6ee7b7; }
.alert-error   { background: var(--c-error-bg);   color: var(--c-error-text);   border-color: #fca5a5; }
.alert-warning { background: var(--c-warning-bg); color: var(--c-warning-text); border-color: #fde68a; }
.error-list    { margin: var(--sp-2) 0 0 var(--sp-5); }
.error-list li { margin-bottom: var(--sp-1); }

/* ----------------------------------------------------------------
   10. Tables
   ---------------------------------------------------------------- */
.table-responsive { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.table th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  background: var(--c-surface-2);
  color: var(--c-text-3);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--c-border);
  white-space: nowrap;
}
.table td {
  padding: var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  color: var(--c-text);
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--c-surface-2); }
.table-compact th,
.table-compact td { padding: var(--sp-2) var(--sp-3); }
.row-inactive { opacity: .5; }

.action-buttons { display: flex; gap: var(--sp-1); align-items: center; }

/* Status dot */
.dot        { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green  { background: var(--c-success); }
.dot-red    { background: var(--c-error); }
.dot-gray   { background: var(--c-border-2); }

/* ----------------------------------------------------------------
   11. Forms
   ---------------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}
.form-span-2 { grid-column: span 2; }
.form-span-4 { grid-column: span 4; }

.form-row {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.form-row .form-group { flex: 1; min-width: 150px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.form-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--c-text-2);
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 11px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font);
  transition: border-color .12s, box-shadow .12s;
  line-height: 1.5;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--c-text-3); }

.form-group-checkbox {
  flex-direction: row;
  align-items: flex-end;
  padding-bottom: 2px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-text);
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--c-primary);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
}
.form-hint {
  display: block;
  margin-top: 2px;
  font-size: .75rem;
  color: var(--c-text-3);
}
.required { color: var(--c-error); margin-left: 2px; }

/* ----------------------------------------------------------------
   12. Filter bar
   ---------------------------------------------------------------- */
.filter-bar     { padding: var(--sp-3) var(--sp-4); }
.filter-form    { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.filter-group   { display: flex; align-items: center; }
.filter-search  { flex: 1; min-width: 180px; }

.input-search,
.select-filter {
  padding: 7px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font);
  width: 100%;
}
.input-search:focus,
.select-filter:focus { outline: none; border-color: var(--c-primary); }

/* ----------------------------------------------------------------
   13. Pagination
   ---------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--c-border);
}
.page-info { font-size: .84rem; color: var(--c-text-3); }

/* ----------------------------------------------------------------
   14. Empty state
   ---------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--c-text-3);
}
.empty-icon { font-size: 2.5rem; margin-bottom: var(--sp-3); }
.empty-state p { margin-bottom: var(--sp-4); font-size: .9rem; }

/* ----------------------------------------------------------------
   15. Dashboard stats grid
   ---------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  position: relative;
  box-shadow: var(--shadow);
}
.stat-card-warning { border-left: 3px solid var(--c-warning); }
.stat-icon  { font-size: 1.5rem; flex-shrink: 0; margin-top: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: -.02em; }
.stat-label { font-size: .78rem; color: var(--c-text-3); margin-top: 2px; }
.stat-sub   { font-size: .75rem; margin-top: 2px; }
.stat-link  {
  position: absolute; top: var(--sp-3); right: var(--sp-3);
  color: var(--c-text-3); font-size: .9rem;
}
.stat-link:hover { color: var(--c-primary); text-decoration: none; }

/* History items on dashboard */
.history-list  { }
.history-item  {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-border);
}
.history-item:last-child { border-bottom: 0; }
.history-text  { flex: 1; font-size: .84rem; color: var(--c-text); }
.history-time  { font-size: .75rem; color: var(--c-text-3); }
.section       { margin-top: var(--sp-6); }
.section h2    { font-size: 1rem; font-weight: 600; margin-bottom: var(--sp-4); }

/* ----------------------------------------------------------------
   16. RSS Feed
   ---------------------------------------------------------------- */
.rss-feed  { display: flex; flex-direction: column; gap: var(--sp-3); }

.rss-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-5);
  transition: box-shadow .15s;
}
.rss-card:hover { box-shadow: var(--shadow-md); }

.rss-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-2);
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.rss-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.rss-source   { font-size: .75rem; font-weight: 600; color: var(--c-text-3); }
.rss-category {
  font-size: .69rem; color: var(--c-text-3);
  background: var(--c-surface-2); padding: 2px 7px;
  border-radius: 99px; border: 1px solid var(--c-border);
}
.rss-time { font-size: .75rem; color: var(--c-text-3); flex-shrink: 0; }

.rss-title   { font-size: .95rem; font-weight: 600; margin-bottom: var(--sp-2); line-height: 1.4; }
.rss-title a { color: var(--c-text); }
.rss-title a:hover { color: var(--c-primary); text-decoration: none; }
.rss-summary { font-size: .83rem; line-height: 1.55; color: var(--c-text-2); }

.rss-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--c-border);
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.rss-actions      { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.rss-source-link  { font-size: .75rem; color: var(--c-text-3); }

/* Quick action buttons */
.btn-action {
  padding: 4px 9px;
  font-size: .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  color: var(--c-text-2);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all .12s;
  font-family: var(--font);
  white-space: nowrap;
}
.btn-action:hover { text-decoration: none; border-color: var(--c-border-2); }
.btn-rewrite:hover   { background: var(--c-primary-bg);  border-color: #93c5fd; color: #1d4ed8; }
.btn-translate:hover { background: var(--c-success-bg);  border-color: #86efac; color: #15803d; }
.btn-article:hover   { background: #fdf4ff; border-color: #d8b4fe; color: #6b21a8; }
.btn-smm:hover       { background: #fff7ed; border-color: #fdba74; color: #c2410c; }
.btn-factcheck:hover { background: #fefce8; border-color: #fde047; color: #854d0e; }
[data-theme="dark"] .btn-action { background: var(--c-surface-2); border-color: var(--c-border); color: var(--c-text-2); }
[data-theme="dark"] .btn-rewrite:hover   { background: #1e3a8a; border-color: #3b82f6; color: #93c5fd; }
[data-theme="dark"] .btn-translate:hover { background: #064e3b; border-color: #10b981; color: #6ee7b7; }
[data-theme="dark"] .btn-article:hover   { background: #3b0764; border-color: #a855f7; color: #d8b4fe; }
[data-theme="dark"] .btn-smm:hover       { background: #431407; border-color: #f97316; color: #fdba74; }
[data-theme="dark"] .btn-factcheck:hover { background: #422006; border-color: #eab308; color: #fde68a; }

/* RSS item detail */
.content-layout { display: grid; grid-template-columns: 1fr 270px; gap: var(--sp-5); align-items: start; }
.content-main   { min-width: 0; }
.content-sidebar { position: sticky; top: var(--sp-4); }

.rss-item-meta  { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.rss-item-title { font-size: 1.25rem; font-weight: 700; line-height: 1.4; margin-bottom: var(--sp-4); }
.rss-item-summary { font-size: .9rem; line-height: 1.7; }
.rss-item-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--c-border);
  flex-wrap: wrap; gap: var(--sp-3);
}
.expires-info { font-size: .76rem; color: var(--c-text-3); }

/* AI action sidebar */
.ai-action-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.ai-action-btn {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface-2);
  text-decoration: none; color: var(--c-text);
  transition: all .12s;
}
.ai-action-btn:hover {
  border-color: var(--c-primary);
  background: var(--c-primary-bg);
  text-decoration: none;
}
[data-theme="dark"] .ai-action-btn:hover { background: #1e3a8a; }
.ai-action-icon { font-size: 1.1rem; flex-shrink: 0; }
.ai-action-text strong { display: block; font-size: .84rem; }
.ai-action-text small  { color: var(--c-text-3); font-size: .75rem; }
.source-info-card { margin-top: var(--sp-3); }
.source-info-card h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--c-text-3); margin-bottom: var(--sp-2); font-weight: 600;
}

/* ----------------------------------------------------------------
   17. AI Module
   ---------------------------------------------------------------- */
.ai-layout { display: flex; flex-direction: column; gap: var(--sp-4); }

/* Source block */
.source-block   { }
.source-block-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--sp-3); flex-wrap: wrap; gap: var(--sp-2);
}
.source-block-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--c-text-3);
}
.source-block-meta { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.source-block-title { font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: var(--sp-3); }
.source-block-text {
  font-size: .875rem; line-height: 1.65;
  max-height: 180px; overflow-y: auto;
  color: var(--c-text-2); padding-right: var(--sp-1);
}
.source-block-footer {
  display: flex; justify-content: space-between; margin-top: var(--sp-3);
  padding-top: var(--sp-3); border-top: 1px solid var(--c-border);
  flex-wrap: wrap; gap: var(--sp-2);
}

/* AI result block */
.result-block   { }
.result-success { border-left: 3px solid var(--c-success); }
.result-error   { border-left: 3px solid var(--c-error); }
.result-header  {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: var(--sp-4); flex-wrap: wrap; gap: var(--sp-2);
}
.result-title   { font-size: .9rem; font-weight: 600; display: flex; align-items: center; gap: var(--sp-2); }
.result-actions { display: flex; gap: var(--sp-2); }
.result-text    {
  font-size: .9rem; line-height: 1.7; white-space: pre-wrap;
  word-break: break-word; color: var(--c-text);
}
.result-meta {
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  border-top: 1px solid var(--c-border);
  font-size: .75rem; color: var(--c-text-3);
}
.result-error-msg { color: var(--c-error-text); font-size: .875rem; }

/* AI form */
.lang-display  { padding: 8px 0; display: flex; align-items: center; gap: var(--sp-2); font-size: .875rem; }
.lang-arrow    { display: flex; align-items: flex-end; padding-bottom: 8px; font-size: 1.1rem; color: var(--c-text-3); }
.btn-generate  { margin-top: var(--sp-2); }

.ai-note {
  font-size: .82rem; color: var(--c-text-3);
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
}
.ai-note-warning {
  background: var(--c-warning-bg); border-color: #fde68a;
  color: var(--c-warning-text); margin-bottom: var(--sp-4);
  font-size: .84rem;
}
[data-theme="dark"] .ai-note-warning { background: var(--c-warning-bg); border-color: #78350f; color: var(--c-warning-text); }

/* AI tools manual input */
.textarea-large { width: 100%; font-family: var(--font); resize: vertical; min-height: 200px; font-size: .875rem; }
.char-counter   { text-align: right; margin-top: var(--sp-1); font-size: .75rem; color: var(--c-text-3); }
.extra-options  { }

/* ----------------------------------------------------------------
   18. Admin module
   ---------------------------------------------------------------- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.breakdown-row { display: flex; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.breakdown-card { flex: 1; min-width: 170px; }
.breakdown-title {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--c-text-3); font-weight: 700; margin-bottom: var(--sp-3);
}
.breakdown-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-border);
  font-size: .84rem;
}
.breakdown-item:last-child { border-bottom: 0; }
.breakdown-item strong { font-weight: 700; }

/* Log context collapsible */
.log-message     { font-size: .84rem; }
.log-context     { margin-top: var(--sp-1); }
.log-context summary { font-size: .72rem; cursor: pointer; color: var(--c-text-3); }
.log-context-pre {
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); padding: var(--sp-2);
  font-family: var(--font-mono); font-size: .72rem;
  overflow-x: auto; margin-top: var(--sp-1);
  white-space: pre-wrap; word-break: break-word;
  color: var(--c-text-2);
}

/* Admin AI usage source indicator */
.source-tag { font-size: .75rem; color: var(--c-text-3); }

/* Meta list (AI show page) */
.meta-list    { }
.meta-list dt { font-weight: 600; color: var(--c-text-3); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; margin-top: var(--sp-3); }
.meta-list dd { margin: 2px 0 0; font-size: .85rem; }

/* ----------------------------------------------------------------
   19. Auth / Login
   ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
}
.login-container { width: 100%; max-width: 390px; padding: var(--sp-4); }
.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: var(--sp-8);
  box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: var(--sp-6); }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.login-logo h1 span { color: var(--c-primary); }
.login-logo p  { color: var(--c-text-3); font-size: .84rem; margin-top: var(--sp-1); }
.login-form .form-group { margin-bottom: var(--sp-4); }
.login-lang-toggle { text-align: center; margin-top: var(--sp-4); }
.login-lang-toggle .btn-text { color: var(--c-text-3); font-size: .82rem; }

/* ----------------------------------------------------------------
   20. Errors (403, 404)
   ---------------------------------------------------------------- */
.error-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-bg);
}
.error-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 12px; padding: var(--sp-8); text-align: center;
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow-md);
}
.error-icon  { font-size: 3rem; margin-bottom: var(--sp-4); }
.error-card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: var(--sp-3); }
.error-card p  { color: var(--c-text-3); font-size: .9rem; margin-bottom: var(--sp-5); line-height: 1.6; }

/* ----------------------------------------------------------------
   21. Typography utilities
   ---------------------------------------------------------------- */
.text-muted  { color: var(--c-text-3) !important; }
.text-small  { font-size: .78rem !important; }
.text-success{ color: var(--c-success) !important; }
.text-error  { color: var(--c-error) !important; }
.text-warning{ color: var(--c-warning) !important; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }

/* RSS source table specifics */
.source-title  { font-weight: 600; margin-bottom: 2px; }
.source-url    { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-error  { max-width: 240px; font-size: .75rem; }
.source-meta-info { padding: var(--sp-2) 0; font-size: .82rem; color: var(--c-text-3); }

/* ----------------------------------------------------------------
   22. Responsive
   ---------------------------------------------------------------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { padding: var(--sp-4); max-width: 100vw; }
  .content-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .breakdown-row { flex-direction: column; }
}
@media (max-width: 600px) {
  .form-grid   { grid-template-columns: 1fr; }
  .form-span-2 { grid-column: span 1; }
  .rss-actions { gap: 3px; }
  .btn-action  { font-size: .7rem; padding: 3px 6px; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .form-row    { flex-direction: column; }
  .lang-arrow  { display: none; }
}
