* { box-sizing: border-box; }
:root {
  --c-primary: #1877f2;
  --c-primary-hover: #166fe5;
  --c-bg: #f0f2f5;
  --c-card: #ffffff;
  --c-border: #dadde1;
  --c-text: #1a1a1a;
  --c-text-muted: #65676b;
  --c-warning: #ff9800;
  --c-danger: #f44336;
  --c-success: #4caf50;
  --r-md: 8px;
  --r-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,.08);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
}
header {
  background: #1877f2;
  color: white;
  padding: 8px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header .brand {
  color: white;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
}
header nav { display: flex; gap: 16px; align-items: center; }
header nav a { color: white; text-decoration: none; opacity: .9; }
header nav a:hover { opacity: 1; }
header .user { opacity: .85; font-size: .9rem; }

main {
  max-width: 1080px;
  margin: 12px auto;
  padding: 0 16px;
}

h1 { font-size: 1.5rem; margin: 0 0 24px; }

.login-card {
  max-width: 360px;
  margin: 80px auto;
  background: white;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.login-card h1 { text-align: center; margin-bottom: 24px; }

form { display: flex; flex-direction: column; gap: 16px; }
fieldset {
  border: 1px solid #dadde1;
  border-radius: 6px;
  padding: 16px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}
legend { font-weight: 600; padding: 0 6px; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .9rem;
  color: #444;
}
label.radio {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  color: #1a1a1a;
}

input[type="text"], input[type="password"], input[type="number"],
input[type="file"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccd0d5;
  border-radius: 4px;
  font: inherit;
  font-size: .95rem;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1877f2;
  box-shadow: 0 0 0 2px rgba(24,119,242,.15);
}
textarea { resize: vertical; }

button {
  background: #1877f2;
  color: white;
  border: none;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
}
button:hover:not(:disabled) { background: #166fe5; }
button:disabled { opacity: .6; cursor: not-allowed; }

details summary { cursor: pointer; user-select: none; padding: 4px 0; }
details[open] { padding-top: 8px; }

small { display: block; color: #666; margin-top: 4px; }

.error {
  background: #ffe6e6;
  color: #c00;
  border: 1px solid #fcc;
  padding: 10px 12px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  padding: 16px;
  border-radius: 6px;
  margin-top: 16px;
}
.success code { background: rgba(0,0,0,.06); padding: 2px 6px; border-radius: 3px; }

#result { margin-top: 24px; }
.progress {
  background: #e3f2fd;
  color: #1565c0;
  padding: 16px;
  border-radius: 6px;
  margin-top: 16px;
  border: 1px solid #90caf9;
}

.token-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 12px 16px;
  border: 1px solid #dadde1;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.token-status .btn-fb {
  background: #1877f2;
  color: white;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}
.token-status .btn-fb:hover { background: #166fe5; }
.token-status.invalid { background: #fff3e0; border-color: #ffb74d; color: #e65100; }
.token-status.valid { color: #2e7d32; }

/* History table */
.history-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  font-size: .9rem;
}
.history-table th, .history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}
.history-table th {
  background: #f7f8fa;
  font-weight: 600;
  font-size: .85rem;
  color: #555;
}
.history-table tr:last-child td { border-bottom: none; }
.caption-cell { max-width: 280px; word-break: break-word; }
.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .75rem;
  font-weight: 600;
}
.status-paused { background: #fff3e0; color: #e65100; }
.status-active { background: #e8f5e9; color: #2e7d32; }
.status-failed { background: #ffebee; color: #c62828; }

/* Dialog */
dialog {
  border: none;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-width: 500px;
  width: 92%;
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { gap: 12px; }
dialog h2 { margin: 0 0 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dialog-actions button[type="button"] { background: #eee; color: #333; }

/* Template list */
.tpl-card {
  background: white;
  border: 1px solid #dadde1;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tpl-card .tpl-meta { font-size: .85rem; color: #666; margin-top: 2px; }
.tpl-card .tpl-actions { display: flex; gap: 6px; }
.tpl-card button {
  padding: 4px 10px;
  font-size: .8rem;
  background: #f0f2f5;
  color: #333;
}
.tpl-card button.danger { background: #ffebee; color: #c62828; }

/* Header nav */
header nav { gap: 12px; }
header nav a { padding: 4px 8px; border-radius: 4px; }
header nav a:hover { background: rgba(255,255,255,.15); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 600;
  margin-left: 4px;
}
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff3e0; color: #e65100; }

/* Auto options fieldset (templates) */
.auto-options {
  background: #f0f9ff;
  border-color: #b3e5fc;
}
.auto-options legend { color: #0277bd; }
.auto-options label.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 4px;
}
.auto-options input[type="checkbox"] { margin-top: 4px; flex-shrink: 0; }
.auto-options small { color: #777; padding-left: 26px; }

/* Mobile responsive */
@media (max-width: 600px) {
  main { padding: 0 12px; margin: 16px auto; }
  header { padding: 10px 12px; flex-wrap: wrap; }
  header nav { gap: 8px; }
  header nav a { font-size: .85rem; padding: 4px 6px; }
  header .user { display: none; }
  h1 { font-size: 1.25rem; }
  fieldset { padding: 12px; }
  .tpl-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tpl-card .tpl-actions { width: 100%; justify-content: flex-end; }
  .history-table { font-size: .8rem; }
  .history-table th, .history-table td { padding: 8px 6px; }
  .caption-cell { max-width: 120px; }
  dialog { padding: 16px; max-width: 100%; }
}

/* Template select highlight */
#block-template {
  background: linear-gradient(135deg, #e3f2fd 0%, #fff 60%);
  border-color: #90caf9;
}
#block-template legend { color: #1565c0; font-weight: 700; }

.tpl-info {
  background: white;
  border: 1px solid #b3e5fc;
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: .9rem;
}
.tpl-info-meta { color: #666; font-size: .85rem; margin-top: 2px; }
.tpl-info-badges { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.tpl-info-badges .badge { margin: 0; }

.tpl-note {
  background: #f1f8e9;
  border: 1px solid #c5e1a5;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: .82rem;
  color: #558b2f;
}

/* Form section numbers */
fieldset legend { font-size: .95rem; }

/* Better button states */
button:active:not(:disabled) { transform: translateY(1px); }
.tpl-card button:hover:not(:disabled) { background: #e4e6eb; }
.tpl-card button.danger:hover { background: #ffcdd2; }

/* Comments page */
/* ===================== Minus so'zlar (qora ro'yxat) ===================== */
.minus-words-box {
  background: #fff;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.minus-word-form {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.minus-word-form input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #ccd0d5;
  border-radius: 6px;
  font-size: .9rem;
}
.minus-word-form button {
  padding: 7px 14px;
  font-size: .88rem;
  white-space: nowrap;
}
.minus-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.minus-word-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
  border-radius: 14px;
  padding: 3px 6px 3px 12px;
  font-size: .85rem;
}
.minus-word-chip button {
  background: #ef9a9a;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: .7rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.minus-word-chip button:hover { background: #c62828; }

.comment-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.comment-toolbar #comment-search {
  width: 100%;
  font-size: 1rem;
  padding: 10px 14px;
  border: 1px solid #ccd0d5;
  border-radius: 6px;
  background: white;
}
.bulk-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff8e1;
  border: 1px solid #ffd54f;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.bulk-bar button {
  padding: 6px 12px;
  font-size: .85rem;
  background: #fff3e0;
  color: #333;
}
.bulk-bar button.danger { background: #ffebee; color: #c62828; }
.bulk-bar #bulk-count { color: #e65100; font-size: 1.1rem; padding-right: 6px; }

.comment-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #1877f2;
}

.comment-filters {
  display: flex;
  gap: 8px;
  margin: 0;
  flex-wrap: wrap;
}

.sync-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid #f0f0f0;
}
.sync-btn {
  padding: 5px 12px;
  font-size: .8rem;
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.sync-btn:hover:not(:disabled) { background: #ffe0b2; }
.sync-btn:disabled { opacity: .5; cursor: not-allowed; }
.filter-btn {
  background: #eee;
  color: #333;
  padding: 6px 12px;
  font-size: .85rem;
  border-radius: 16px;
  border: none;
  cursor: pointer;
}
.filter-btn.active { background: #1877f2; color: white; }

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comment-card {
  background: white;
  border: 1px solid #dadde1;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: .9rem;
}
.comment-card.caught {
  border-left: 3px solid #e57373;
  background: #fffafa;
}
.comment-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.comment-phone {
  margin: 6px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1565c0;
}
.comment-phone a { color: inherit; text-decoration: none; }
.comment-text { color: #333; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.comment-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.comment-actions button {
  padding: 4px 10px;
  font-size: .8rem;
  background: #f0f2f5;
  color: #333;
}
.comment-actions button.danger { background: #ffebee; color: #c62828; }
.comment-actions .btn-link {
  padding: 4px 10px;
  background: #eee;
  color: #1565c0;
  text-decoration: none;
  border-radius: 4px;
  font-size: .8rem;
}

/* Facebook page */
.fb-card {
  background: white;
  border: 1px solid #dadde1;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.fb-card.ok { border-left: 4px solid #4caf50; }
.fb-card.warning { border-left: 4px solid #ff9800; background: #fffbf0; }
.fb-card.expired { border-left: 4px solid #f44336; background: #fff5f5; }
.fb-card.empty { text-align: center; padding: 40px; color: #888; }
.fb-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.fb-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 24px;
}
.fb-card-grid > div { font-size: .9rem; }
.fb-card-grid small { color: #888; font-size: .75rem; text-transform: uppercase; letter-spacing: .3px; }
.fb-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
}
.btn-primary {
  background: #1877f2;
  color: white;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 5px;
  font-size: .9rem;
  font-weight: 600;
  display: inline-block;
  border: none;
  cursor: pointer;
}
.btn-primary:hover { background: #166fe5; }
.btn-primary.big { padding: 12px 24px; font-size: 1rem; margin-top: 12px; }

@media (max-width: 600px) {
  .fb-card-grid { grid-template-columns: 1fr; }
}

/* ============================== Dashboard ============================== */
.dashboard {
  margin-bottom: 12px;
}
.welcome {
  margin: 0 0 16px;
}
.welcome h1 { font-size: 1.5rem; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.qa-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.qa-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-primary);
}
.qa-card.primary {
  background: linear-gradient(135deg, var(--c-primary), #4f9eff);
  color: white;
  border-color: var(--c-primary);
}
.qa-card.primary:hover { background: linear-gradient(135deg, var(--c-primary-hover), #3d8aff); }
.qa-icon {
  font-size: 1.75rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.04);
  border-radius: 50%;
  flex-shrink: 0;
}
.qa-card.primary .qa-icon { background: rgba(255,255,255,.18); }
.qa-title { font-weight: 600; font-size: 1rem; }
.qa-sub { font-size: .82rem; opacity: .8; margin-top: 2px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  margin-bottom: 12px;
  font-size: .92rem;
}
.alert.warning { background: #fff3e0; border: 1px solid #ffcc80; color: #e65100; }
.alert.danger { background: #ffebee; border: 1px solid #ef9a9a; color: #c62828; }
.alert.info { background: #e3f2fd; border: 1px solid #90caf9; color: #1565c0; }
.alert a { color: inherit; font-weight: 600; }

/* ============================== Form refinements ============================== */
.step {
  display: inline-block;
  width: 22px;
  height: 22px;
  background: var(--c-primary);
  color: white;
  border-radius: 50%;
  text-align: center;
  font-size: .75rem;
  line-height: 22px;
  font-weight: 700;
  margin-right: 4px;
}
.step-tpl .step {
  background: #ffd54f;
  color: #5d4037;
}

.radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.radio-group label.radio {
  flex-direction: row;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  background: white;
  cursor: pointer;
  transition: border-color .12s;
}
.radio-group label.radio:has(input:checked) {
  border-color: var(--c-primary);
  background: #e7f1ff;
}
.radio-group label.radio input { margin-right: 6px; }

.form-row {
  display: flex;
  gap: 12px;
}
@media (max-width: 600px) {
  .form-row { flex-direction: column; gap: 8px; }
}

.submit-row {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.btn-primary.big {
  padding: 14px 32px;
  font-size: 1.05rem;
  letter-spacing: .3px;
}

/* Compact welcome bar (one line) */
.welcome-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--c-card);
  padding: 14px 18px;
  border-radius: var(--r-md);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.quick-stats {
  display: flex;
  gap: 8px;
}
.qs {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f7f8fa;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 6px 14px;
  min-width: 72px;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s, transform .12s;
}
.qs:hover { border-color: var(--c-primary); transform: translateY(-1px); }
.qs b { font-size: 1.15rem; line-height: 1.2; color: var(--c-primary); }
.qs small { font-size: .7rem; color: var(--c-text-muted); margin-top: 2px; }

/* Form: 2-column ultra-compact grid (ekranga sig'ishi uchun) */
.ads-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: start;
}
.ads-form fieldset {
  padding: 5px 10px 7px;
  margin: 0;
}
.ads-form fieldset legend {
  font-size: .8rem;
  padding: 0 5px;
  font-weight: 600;
  color: var(--c-text-muted);
  letter-spacing: .2px;
}
.ads-form fieldset legend .legend-link {
  font-size: .72rem;
  margin-left: 6px;
  text-decoration: none;
  color: var(--c-primary);
  font-weight: 500;
}
.ads-form label { display: block; margin: 0; font-size: .82rem; color: var(--c-text-muted); }
.ads-form label + label { margin-top: 5px; }
/* Inputlar ixcham: kichikroq padding va shrift */
.ads-form select,
.ads-form input[type=text],
.ads-form input[type=number],
.ads-form input[type=file],
.ads-form textarea {
  margin-top: 1px;
  padding: 5px 8px;
  font-size: .88rem;
}
.ads-form textarea { min-height: 48px; }
.ads-form .form-row { gap: 6px; }
.ads-form fieldset + fieldset { margin-top: 0; }
.ads-form small,
.ads-form small.hint { color: var(--c-text-muted); font-size: .72rem; font-weight: normal; line-height: 1.3; }
.ads-form details summary { font-size: .8rem; padding: 2px 0; }
.ads-form .submit-row { margin-top: 2px; }
.ads-form .submit-row button.big { padding: 9px 20px; font-size: .95rem; }
.ads-form #block-new,
.ads-form #block-existing { margin-top: 7px; }
.ads-form .radio-group { gap: 6px; }
.ads-form .radio-group label.radio { padding: 6px 10px; font-size: .85rem; }
/* Shablon ma'lumot qutisi ham ixcham */
.ads-form .tpl-info { padding: 6px 10px; margin-top: 5px; font-size: .8rem; }
.tpl-note { padding: 5px 10px; font-size: .78rem; }
.ads-form #page-from-tpl { margin-top: 5px; }

/* Compact welcome bar + header (vertikal joy tejash) */
.welcome-bar { padding: 7px 12px; margin-bottom: 7px; }
.welcome-bar h1 { font-size: 1rem !important; }
.welcome-bar p { font-size: .75rem !important; }
.qs { padding: 4px 12px !important; min-width: 64px !important; }
.qs b { font-size: 1rem !important; }
.qs small { font-size: .65rem !important; }

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .welcome-bar { flex-direction: column; align-items: stretch; }
  .quick-stats { justify-content: space-between; }
  .qs { flex: 1; min-width: 0 !important; padding: 5px 4px !important; }
}

#token-status { /* eski elementni yashiramiz (yangi dashboard'da bor) */
  display: none;
}

/* ============================== Templates page ============================== */
.tpl-card {
  transition: box-shadow .12s;
}
.tpl-card:hover { box-shadow: var(--shadow-md); }
.tpl-card b { font-size: 1rem; }

/* ============================== Header ============================== */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
header .brand {
  font-size: 1.05rem;
  letter-spacing: .2px;
}

/* ============================== Form general ============================== */
fieldset {
  background: var(--c-card);
  border-color: var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
fieldset legend {
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

label > small {
  margin-top: 2px;
  color: var(--c-text-muted);
  font-size: .8rem;
}

/* ============================== Tables ============================== */
.history-table {
  box-shadow: var(--shadow-sm);
}
.history-table tbody tr:hover { background: #fafbfc; }

/* ============================== Buttons consistency ============================== */
button, .btn-primary {
  font-family: inherit;
}
.fb-card-actions button,
.fb-card-actions .btn-primary { padding: 8px 16px; font-size: .9rem; }

/* ============================== Profile page ============================== */
form fieldset + fieldset { margin-top: 12px; }
form button[type="submit"] { align-self: flex-start; margin-top: 4px; }

/* ============================== Login card refinement ============================== */
.login-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-md);
}

/* Hide old token status box on main page since we have alerts */
.token-status { display: none; }

/* ============================== Page header ============================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.4rem; }

/* ============================== Empty state ============================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--c-card);
  border-radius: var(--r-md);
  border: 1px dashed var(--c-border);
}
.empty-state h3 { margin: 12px 0 4px; }

/* ============================== Table wrap (horizontal scroll on mobile) ============================== */
.table-wrap {
  background: var(--c-card);
  border-radius: var(--r-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.table-wrap .history-table { min-width: 600px; box-shadow: none; }

/* ============================== Mobile improvements ============================== */
@media (max-width: 600px) {
  header { padding: 10px 12px; }
  header nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  header nav a { white-space: nowrap; }
  .quick-actions { grid-template-columns: 1fr; }
  .qa-card { padding: 12px; }
  .qa-icon { width: 36px; height: 36px; font-size: 1.4rem; }
  .bulk-bar { gap: 6px; }
  .bulk-bar button { padding: 6px 8px; font-size: .8rem; }
  .comment-toolbar { gap: 8px; }
  .comment-filters { font-size: .8rem; }
}
.progress .stage { font-weight: 600; margin-bottom: 4px; }
.progress .detail { font-size: .9rem; opacity: .85; }

/* ============================== Analitika sahifasi ============================== */
.analytics-period {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 16px;
  flex-wrap: wrap;
}
.period-btn {
  background: #fff;
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 7px 16px;
  font-size: .88rem;
  cursor: pointer;
}
.period-btn.active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}
.analytics-generated { font-size: .75rem; color: var(--c-text-muted); margin-left: auto; }
.analytics-loading { color: var(--c-text-muted); padding: 24px 0; font-style: italic; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat-label { font-size: .72rem; color: var(--c-text-muted); }
.stat-value { font-size: 1.25rem; font-weight: 700; margin: 2px 0; color: var(--c-primary); }
.delta { font-size: .68rem; display: block; }
.delta.good { color: #2e7d32; }
.delta.bad { color: #c62828; }
.delta.neutral { color: var(--c-text-muted); }

.chart-box {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

/* Kampaniya kartasi */
.ca-card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.ca-card.ca-critical { border-left-color: #e53935; }
.ca-card.ca-warning  { border-left-color: #fb8c00; }
.ca-card.ca-good     { border-left-color: #43a047; }
.ca-card.ca-normal   { border-left-color: #bdbdbd; }
.ca-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ca-status {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.ca-status-critical { background: #ffebee; color: #c62828; }
.ca-status-warning  { background: #fff3e0; color: #e65100; }
.ca-status-good     { background: #e8f5e9; color: #2e7d32; }
.ca-status-normal   { background: #f0f0f0; color: #757575; }
.ca-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 8px 0;
  padding: 8px 0;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
}
.ca-metrics span { display: flex; flex-direction: column; }
.ca-metrics b { font-size: .95rem; }
.ca-metrics small { font-size: .68rem; color: var(--c-text-muted); }
.ca-recs { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.rec {
  border-radius: 6px;
  padding: 7px 10px;
  font-size: .82rem;
}
.rec-critical { background: #ffebee; }
.rec-warning  { background: #fff8e1; }
.rec-good     { background: #e8f5e9; }
.rec-normal   { background: #f5f5f5; }
.rec-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rec-critical .rec-dot { background: #e53935; }
.rec-warning  .rec-dot { background: #fb8c00; }
.rec-good     .rec-dot { background: #43a047; }
.rec-normal   .rec-dot { background: #bdbdbd; }
.rec-text { color: #444; line-height: 1.4; }

@media (max-width: 768px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Analitika — qo'shimcha (15 kun, kesh, refresh, summary) */
.refresh-btn {
  background: #fff;
  color: var(--c-primary);
  border: 1px solid var(--c-primary);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: .82rem;
  cursor: pointer;
}
.refresh-btn:hover { background: #e7f1ff; }
/* Grafik konteyner — barqaror balandlik (Chart.js cho'zilib ketmasligi uchun) */
.chart-wrap { position: relative; height: 300px; width: 100%; }
@media (max-width: 600px) { .chart-wrap { height: 240px; } }

.status-summary {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 9px 14px;
  margin-bottom: 12px;
  font-size: .85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.sum-chip {
  font-size: .76rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
}
.sum-critical { background: #ffebee; color: #c62828; }
.sum-warning  { background: #fff3e0; color: #e65100; }
.sum-good     { background: #e8f5e9; color: #2e7d32; }
.sum-normal   { background: #f0f0f0; color: #757575; }

.campaigns-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 22px 0 8px;
  flex-wrap: wrap;
}
.campaigns-head select {
  width: auto;
  padding: 5px 8px;
  font-size: .82rem;
  border: 1px solid var(--c-border);
  border-radius: 6px;
}

/* Analitika — reklama hisobi holati ogohlantirishi (grace period va h.k.) */
.account-banner {
  background: #fff3e0;
  border: 1px solid #ffb74d;
  border-left: 4px solid #fb8c00;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: .88rem;
  color: #e65100;
  line-height: 1.45;
}
.account-banner small { color: #bf6a00; }
