:root {
  --sidebar: #0d1b2a;
  --accent: #1e6fff;
  --border: #e2e8f0;
  --bg: #f1f5f9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: system-ui, sans-serif; background: var(--bg); color: #1a1a1a; }

.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 220px;
  background: var(--sidebar);
  color: #fff;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.admin-logo { font-size: 1.1rem; margin-bottom: .25rem; }
.admin-subtitle { font-size: .75rem; color: #64748b; margin-bottom: 1.25rem; line-height: 1.35; }

.admin-sidebar nav { display: flex; flex-direction: column; gap: .5rem; }
.admin-sidebar a { color: #94a3b8; text-decoration: none; padding: .4rem .5rem; border-radius: 4px; }
.admin-sidebar a:hover { color: #fff; background: rgba(255,255,255,.08); }

.admin-main { flex: 1; padding: 2rem; max-width: 1100px; }

h1 { margin-bottom: .5rem; }
.subtitle { color: #64748b; margin-bottom: 1.5rem; }

.btn {
  display: inline-block;
  padding: .45rem .9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  color: #1a1a1a;
  text-decoration: none;
  font-size: .9rem;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-secondary { background: #e2e8f0; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.card .domain { color: #64748b; font-size: .85rem; margin: .25rem 0 .75rem; }
.card .stats { list-style: none; font-size: .9rem; margin-bottom: 1rem; }
.card .stats li { padding: .2rem 0; }
.card-actions { display: flex; gap: .5rem; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 1rem 0;
}

.data-table th, .data-table td {
  padding: .65rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

.data-table th { background: #f8fafc; font-weight: 600; }

.data-table--sortable .sortable-th { padding: 0; white-space: nowrap; }
.data-table--sortable .sort-link {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .65rem .85rem;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}
.data-table--sortable .sort-link:hover { background: #eef2f7; color: var(--primary, #2563eb); }
.data-table--sortable .sort-link.is-active { color: var(--primary, #2563eb); }
.data-table--sortable .sort-link::after {
  content: "⇅";
  font-size: .72rem;
  color: #94a3b8;
  line-height: 1;
}
.data-table--sortable .sort-link.is-active.sort-asc::after { content: "▲"; color: var(--primary, #2563eb); }
.data-table--sortable .sort-link.is-active.sort-desc::after { content: "▼"; color: var(--primary, #2563eb); }
.data-table .date-cell { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .85rem; }

.page-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin: .75rem 0 1rem;
  padding: .5rem .75rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.bulk-select-all { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; cursor: pointer; }
.col-check { width: 2.25rem; text-align: center; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:disabled { opacity: .45; cursor: not-allowed; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters select, .filters input { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 4px; }

.tab-bar {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  color: #64748b;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.tab:hover { color: var(--accent); }
.tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-count {
  font-size: .75rem;
  background: #e2e8f0;
  color: #475569;
  padding: .1rem .45rem;
  border-radius: 999px;
}
.tab-active .tab-count {
  background: #dbeafe;
  color: var(--accent);
}

.badge {
  display: inline-block;
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-weight: 600;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #fee2e2; color: #991b1b; }
.badge-archive { background: #fef3c7; color: #92400e; margin-left: .35rem; }

.archive-fieldset {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: .75rem 1rem 1rem;
  margin: 0 0 1rem;
}
.archive-fieldset legend { font-weight: 600; padding: 0 .25rem; }
.archive-fieldset .checkbox-label { align-items: flex-start; }
.archive-fieldset .hint { margin: .25rem 0 0; font-size: .8rem; }

.indexnow-fieldset {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: .75rem 1rem 1rem;
  margin: 0 0 1rem;
}
.indexnow-fieldset legend { font-weight: 600; padding: 0 .25rem; }
.indexnow-status-list { margin: .5rem 0 0; padding-left: 1.25rem; }
.indexnow-status-list li { margin: .35rem 0; }
.indexnow-cell .badge { white-space: nowrap; }

.seo-fieldset {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: .75rem 1rem 1rem;
  margin: 0 0 1rem;
}
.seo-fieldset legend { font-weight: 600; padding: 0 .25rem; }
.seo-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: flex-end;
  margin-bottom: .5rem;
}
.seo-row label { margin: 0; }
.seo-row .seo-keyword { min-width: 280px; }
.seo-auto-label { padding-bottom: .45rem; }

.hint { color: #64748b; margin-bottom: 1rem; }
.card-form {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.card-form h2 { font-size: 1rem; margin: 0 0 .75rem; }
.mail-form label { display: block; margin-bottom: 1rem; }
.mail-form input[type=text],
.mail-form select,
.mail-form textarea {
  display: block;
  width: 100%;
  margin-top: .25rem;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}
.mail-form textarea { min-height: 16rem; line-height: 1.45; }
.proxy-url { font-size: .8rem; word-break: break-all; }
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
}

.actions { white-space: nowrap; }
.inline-form { display: inline; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; text-decoration: underline; font-size: inherit; }
.link-btn.danger { color: #dc2626; }

.flash-messages { margin-bottom: 1rem; }
.flash { padding: .75rem 1rem; border-radius: 4px; margin-bottom: .5rem; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.article-form label { display: block; margin-bottom: 1rem; }
.article-form input[type=text],
.article-form input[type=url],
.article-form input[type=datetime-local],
.article-form textarea,
.article-form select {
  display: block;
  width: 100%;
  margin-top: .25rem;
  padding: .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }

fieldset { border: 1px solid var(--border); border-radius: 4px; padding: 1rem; margin-bottom: 1rem; }
.checkbox-label { display: inline-flex !important; align-items: center; gap: .5rem; margin-right: 1rem; }

.lang-tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .75rem;
}
.lang-tab-btn {
  border: 1px solid var(--border);
  background: #f5f5f5;
  border-radius: 6px 6px 0 0;
  padding: .45rem .85rem;
  font-weight: 600;
  cursor: pointer;
}
.lang-tab-btn.is-active {
  background: #fff;
  border-bottom-color: #fff;
  color: var(--primary, #1a5fb4);
}
.lang-tabs { margin-top: -.75rem; }

.lang-panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.lang-panel label {
  display: block;
  margin-bottom: 1rem;
}
.lang-panel input[type=text],
.lang-panel input[type=url],
.lang-panel textarea,
.lang-panel select {
  display: block;
  width: 100%;
  margin-top: .25rem;
}
.lang-panel .excerpt-field {
  min-height: 6.5rem;
  resize: vertical;
  line-height: 1.45;
}
.lang-panel .excerpt-label { margin-bottom: 1.25rem; }

.inline-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem; align-items: end; }

.help-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 2rem;
}

.help-box ol { margin: .75rem 0 0 1.25rem; }
.help-box code { background: #f1f5f9; padding: .15rem .4rem; border-radius: 3px; }

.sync-form { margin-top: 1rem; }

.admin-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.admin-panel-highlight { border-color: #93c5fd; background: #f8fafc; }
.admin-panel-compact { padding: 1rem 1.5rem; }
.panel-title { font-size: 1.05rem; margin-bottom: .35rem; }
.panel-desc { font-size: .88rem; color: #64748b; margin-bottom: 1rem; line-height: 1.45; }
.panel-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.panel-form { margin: 0; }
.panel-form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: flex-end;
}
.field-label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .82rem;
  font-weight: 600;
  color: #475569;
}
.field-label input,
.field-label select {
  font-weight: 400;
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .9rem;
  min-width: 10rem;
}
.field-check {
  flex-direction: row;
  align-items: center;
  font-weight: 500;
  padding-bottom: .45rem;
}
.panel-meta { font-size: .82rem; color: #64748b; margin: .75rem 0 0; }
.hub-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: .9rem 1.2rem;
  margin-bottom: 1.25rem;
  font-size: .92rem;
  line-height: 1.5;
}
.card-hub { border-color: #93c5fd; }
.badge-hub {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  padding: .15rem .4rem;
  border-radius: 3px;
  vertical-align: middle;
}
details.help-box summary { cursor: pointer; }
details.help-box p { margin: .5rem 0; font-size: .9rem; line-height: 1.5; }

.site-picker .hint { font-size: .85rem; color: #64748b; margin-bottom: .75rem; }
.site-picker-actions { display: flex; gap: .5rem; margin-bottom: .75rem; }
.site-checkboxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem; }
.site-checkbox { align-items: flex-start !important; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: .6rem .75rem !important; }
.site-checkbox .domain { font-size: .8rem; color: #64748b; }

.url-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

.topic-fieldset { margin: 1rem 0; }
.topic-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .35rem .75rem;
  margin-bottom: .75rem;
}
.topic-preview {
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: .75rem;
  font-size: .9rem;
}
.topic-preview ul { margin: .35rem 0 0 1rem; }

.article-preview-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.article-preview-box .preview-links {
  list-style: none;
  margin: .5rem 0;
  padding: 0;
}

.article-preview-box .preview-links a {
  color: var(--accent);
  font-weight: 600;
}

.article-preview-box .hint {
  font-size: .82rem;
  color: #64748b;
  margin: 0;
}

.data-table .site-names {
  font-size: .85rem;
  max-width: 180px;
  line-height: 1.35;
  color: #334155;
}
.data-table .muted { color: #94a3b8; }
.data-table .mention-manuals {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: .85rem;
  line-height: 1.4;
  max-width: 28rem;
}
.data-table .mention-manuals li + li { margin-top: .45rem; }
.data-table .mention-url { word-break: break-all; max-width: 22rem; }
.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  font-size: .9rem;
  color: #64748b;
}
.pager a { color: var(--accent); }
.hero-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}
.hero-fieldset legend { font-weight: 600; padding: 0 .35rem; }

.site-lang-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: .2rem;
  margin-left: .35rem;
  vertical-align: middle;
}
.site-lang-badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #475569;
  background: #e2e8f0;
  border-radius: 3px;
  padding: .1rem .35rem;
  line-height: 1.4;
}
.site-checkbox .site-lang-badges {
  display: flex;
  margin: .2rem 0 0;
}
.lang-tabs-hint {
  margin: 0 0 .65rem;
  padding: .55rem .75rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.site-lang-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .5rem;
  max-width: 14rem;
}
.site-lang-form .checkbox-inline {
  font-size: .78rem;
  font-weight: 600;
  margin: 0;
}
.site-lang-form .btn-xs {
  padding: .15rem .45rem;
  font-size: .75rem;
}

/* Sidebar active nav */
.admin-sidebar a.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 600;
}

/* Quick analytics widget on main dashboard */
.analytics-quick-widget {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.quick-widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.quick-widget-title {
  display: flex;
  align-items: center;
  font-size: 1.05rem;
  color: #0f172a;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  margin-right: .5rem;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.quick-widget-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.quick-stat-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .85rem 1rem;
}
.quick-stat-label {
  font-size: .8rem;
  color: #64748b;
  margin-bottom: .25rem;
  font-weight: 500;
}
.quick-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}
.quick-stat-sub {
  font-size: .75rem;
  color: #94a3b8;
  margin-top: .3rem;
}

/* Analytics page KPI cards */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.analytics-kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.analytics-kpi-card.kpi-highlight {
  border-left: 4px solid #10b981;
}
.kpi-label {
  font-size: .85rem;
  color: #64748b;
  margin-bottom: .35rem;
  font-weight: 500;
}
.kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}
.kpi-sub {
  font-size: .8rem;
  color: #64748b;
  margin-top: .4rem;
}

/* Two column layout for analytics sections */
.analytics-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 900px) {
  .analytics-two-col {
    grid-template-columns: 1fr;
  }
}

/* Source progress bars */
.source-bars-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}
.source-bar-item {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.source-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .9rem;
}
.source-name {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.source-counts {
  font-size: .85rem;
  color: #64748b;
}
.analytics-progress {
  width: 100%;
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.analytics-progress-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Daily Chart */
.daily-chart-container {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  height: 160px;
  padding: 1rem 0 .5rem;
  border-bottom: 1px solid var(--border);
}
.daily-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
  cursor: pointer;
}
.daily-chart-val {
  font-size: .75rem;
  font-weight: 600;
  color: #64748b;
  margin-bottom: .25rem;
}
.daily-chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 0 0;
  display: flex;
  flex-direction: column-reverse;
  overflow: hidden;
  background: #e2e8f0;
}
.bar-seg-google {
  background: #4285f4;
  width: 100%;
}
.bar-seg-nongoogle {
  background: #10b981;
  width: 100%;
}
.daily-chart-label {
  font-size: .75rem;
  color: #94a3b8;
  margin-top: .4rem;
  white-space: nowrap;
}
