:root {
  --ink: #18332d;
  --muted: #65736e;
  --green: #087b6b;
  --green-dark: #123f37;
  --coral: #dc5f4b;
  --blue: #2563a6;
  --yellow: #f0bd45;
  --paper: #fff;
  --canvas: #f2f5f3;
  --line: #d9e2de;
  --danger: #b63d3d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-family: "DM Sans", Arial, sans-serif; font-size: 15px; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #1769aa; outline-offset: 2px; }
.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 236px;
  flex-direction: column;
  padding: 22px 14px;
  background: var(--green-dark);
  color: #fff;
}
.admin-brand { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: center; padding: 0 8px 24px; color: #fff; text-decoration: none; }
.admin-brand img { width: 76px; height: 76px; border-radius: 6px; object-fit: contain; }
.admin-brand small { color: #dbe9e5; font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.admin-nav { display: grid; gap: 5px; }
.admin-nav button, .view-site {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #dbe9e5;
  font-weight: 700;
  text-decoration: none;
}
.admin-nav button svg, .view-site svg { width: 19px; }
.admin-nav button.active, .admin-nav button:hover { background: #fff; color: var(--green-dark); }
.admin-nav button[hidden] { display: none; }
.sidebar-footer { display: grid; gap: 6px; margin-top: auto; }
.view-site { width: 100%; border-color: #427269; }
.admin-app { min-height: 100vh; margin-left: 236px; }
.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 86px;
  padding: 14px 30px;
  background: rgba(255, 255, 255, .97);
  border-bottom: 1px solid var(--line);
}
.admin-header p, .modal-header p { margin: 0 0 2px; color: var(--coral); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.admin-header h1 { margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 2rem; line-height: 1; }
.admin-content { width: min(1320px, 100%); margin: 0 auto; padding: 28px 30px 60px; }
.mobile-nav { display: none; }
.primary-button, .secondary-button, .icon-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 800;
}
.primary-button { background: var(--green); color: #fff; }
.secondary-button { background: #fff; border-color: var(--line); color: var(--ink); }
.danger-button { background: #fff; border-color: #e4b3b3; color: var(--danger); }
.icon-button { width: 42px; padding: 0; background: #fff; border-color: var(--line); color: var(--ink); }
.primary-button svg, .secondary-button svg, .danger-button svg { width: 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 26px; }
.stat-card { position: relative; min-height: 145px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--accent, var(--green)); }
.stat-card span { color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; margin-top: 14px; font-family: "Newsreader", Georgia, serif; font-size: 2.8rem; line-height: 1; }
.stat-card svg { position: absolute; right: 18px; bottom: 18px; color: var(--accent, var(--green)); opacity: .42; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(270px, .7fr); gap: 20px; }
.admin-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 1.02rem; }
.panel-header p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.activity-list, .quick-list { display: grid; }
.activity-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 15px 18px; border-bottom: 1px solid #edf1ef; }
.activity-item:last-child { border-bottom: 0; }
.activity-item strong, .activity-item span { display: block; }
.activity-item span { margin-top: 3px; color: var(--muted); font-size: .82rem; }
.quick-list button { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 18px; background: #fff; border: 0; border-bottom: 1px solid #edf1ef; color: var(--ink); text-align: left; font-weight: 700; }
.quick-list button:last-child { border-bottom: 0; }
.quick-list svg { color: var(--green); }
.status-badge { display: inline-flex; align-items: center; width: max-content; min-height: 26px; padding: 0 9px; border-radius: 999px; background: #edf1ef; color: var(--muted); font-size: .75rem; font-weight: 800; }
.status-badge.approved { background: #dff2e9; color: #17624f; }
.status-badge.review { background: #fff1cc; color: #805b05; }
.status-badge.draft { background: #e6edf6; color: #315b89; }
.status-badge.rejected, .status-badge.archived { background: #f6e4e4; color: #8f3030; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.filter-group { display: flex; gap: 6px; }
.filter-group button { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--muted); font-weight: 700; }
.filter-group button.active { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 11px 14px; background: #f7f9f8; color: var(--muted); font-size: .72rem; text-align: left; text-transform: uppercase; }
.data-table td { padding: 13px 14px; border-top: 1px solid #edf1ef; vertical-align: middle; }
.data-table .title-cell { max-width: 500px; font-weight: 700; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.table-actions button { width: 36px; min-height: 36px; padding: 0; }
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.category-card { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 96px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.category-card.inactive { opacity: .55; }
.category-symbol { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 6px; background: color-mix(in srgb, var(--category-color) 14%, white); color: var(--category-color); }
.category-card strong, .category-card span { display: block; }
.category-card span { color: var(--muted); font-size: .8rem; }
.source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.source-card { padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.source-card header { display: flex; align-items: center; gap: 9px; }
.source-dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa6a2; }
.source-dot.ok { background: var(--green); }
.source-dot.error { background: var(--danger); }
.source-card p { margin: 8px 0 0 19px; color: var(--muted); font-size: .82rem; }
.empty-state { padding: 40px 20px; color: var(--muted); text-align: center; }

.admin-modal { width: min(880px, calc(100% - 28px)); max-height: 92vh; padding: 0; border: 0; border-radius: 8px; color: var(--ink); box-shadow: 0 24px 80px rgba(17, 45, 39, .28); overflow: auto; }
.admin-modal::backdrop { background: rgba(17, 45, 39, .58); }
.admin-modal form { padding: 24px; }
.category-modal { width: min(520px, calc(100% - 28px)); }
.user-modal { width: min(650px, calc(100% - 28px)); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 2rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.compact { margin-top: 14px; }
.admin-modal label { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 800; }
.admin-modal input, .admin-modal textarea, .admin-modal select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); font-weight: 500; line-height: 1.45; }
.admin-modal input[type="color"] { min-height: 44px; padding: 4px; }
.field-label { color: var(--muted); font-size: .82rem; font-weight: 800; }
.image-field { display: grid; gap: 6px; }
.image-picker { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 14px; align-items: stretch; }
.image-preview { display: grid; min-height: 138px; place-items: center; overflow: hidden; border: 1px dashed #afbfba; border-radius: 6px; background: var(--canvas); color: var(--muted); }
.image-preview img { width: 100%; height: 138px; object-fit: cover; }
.image-preview span { display: grid; gap: 7px; place-items: center; font-size: .78rem; }
.image-preview span[hidden] { display: none; }
.image-preview svg { width: 24px; }
.image-controls { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; gap: 9px; }
.image-controls small { color: var(--muted); font-weight: 500; }
.upload-button { display: inline-flex !important; min-height: 42px; padding: 0 14px; flex-direction: row; align-items: center; gap: 8px !important; border-radius: 6px; background: var(--green); color: #fff !important; cursor: pointer; }
.upload-button input { position: absolute; width: 1px !important; height: 1px; padding: 0 !important; opacity: 0; pointer-events: none; }
.upload-button svg { width: 18px; }
.full-field { grid-column: 1 / -1; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; padding: 14px; background: var(--canvas); border-radius: 6px; }
.check-grid label, .toggle-line { display: flex; grid-template-columns: none; align-items: center; gap: 8px; color: var(--ink); }
.check-grid input, .toggle-line input { width: 18px; height: 18px; }
.toggle-line { margin-top: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.modal-error { min-height: 22px; margin: 12px 0 0; color: var(--danger); font-weight: 700; }
.role-badge, .current-user { display: inline-flex; min-height: 25px; padding: 0 8px; align-items: center; border-radius: 4px; font-size: .72rem; font-weight: 800; }
.role-badge.owner { background: #e5f3ef; color: var(--green-dark); }
.role-badge.editor { background: #edf3f9; color: #245b84; }
.current-user { min-height: 21px; margin-left: 6px; padding: 0 6px; background: #f7e7bd; color: #7a5310; }
.user-modal small { color: var(--muted); font-weight: 500; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 380px; padding: 13px 16px; border-radius: 6px; background: var(--green-dark); color: #fff; box-shadow: 0 12px 34px rgba(17, 45, 39, .22); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .category-grid, .source-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 820px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-app { margin-left: 0; }
  .mobile-nav { display: inline-flex; width: 42px; min-height: 42px; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
  .admin-header { padding: 12px 16px; }
  .admin-content { padding: 20px 14px 40px; }
  .admin-grid { grid-template-columns: 1fr; }
  .data-table { min-width: 760px; }
  .admin-panel.table-panel { overflow-x: auto; }
}
@media (max-width: 590px) {
  .admin-header h1 { font-size: 1.6rem; }
  #quickAddArticle { width: 42px; padding: 0; }
  #quickAddArticle { font-size: 0; }
  #quickAddArticle svg { width: 18px; }
  .stats-grid, .category-grid, .source-grid, .form-grid, .check-grid { grid-template-columns: 1fr; }
  .full-field { grid-column: 1; }
  .image-picker { grid-template-columns: 1fr; }
  .image-preview, .image-preview img { min-height: 170px; height: 170px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-group { overflow-x: auto; }
}
