:root {
  color-scheme: light;
  --main: #2275fc;
  --main-dark: #145bd1;
  --white: #fff;
  --heading: #111;
  --body-text: #575864;
  --green: #22c55e;
  --green-soft: #eafaf1;
  --style: #ff5200;
  --red: #e65353;
  --red-soft: #fff0f0;
  --orange: #f08a3c;
  --orange-soft: #fff4e9;
  --input: #ecf0f4;
  --stroke: #ecf0f4;
  --backdrop: #f2f7fb;
  --hover: #edf1f5;
  --note: #95989d;
  --shadow: 0 4px 24px rgba(20, 25, 38, .05);
  font-family: "Inter", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; color: var(--body-text); background: var(--backdrop); font: 14px/1.45 "Inter", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(34,117,252,.18); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
.is-hidden { display: none !important; }
.muted { color: var(--note); }
.eyebrow { color: var(--note); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* Login ----------------------------------------------------------------- */
.auth-screen { display: grid; min-height: 100vh; place-items: center; padding: 28px 16px; }
.auth-layout { display: grid; width: 100%; max-width: 470px; gap: 24px; }
.brand-lockup { display: flex; align-items: baseline; justify-content: center; gap: 10px; color: var(--heading); }
.brand-lockup strong { font-size: 24px; font-weight: 800; letter-spacing: -.055em; }
.brand-lockup span { color: var(--note); font-size: 12px; }
.auth-card { display: grid; gap: 16px; padding: 32px; background: var(--white); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card h1 { color: var(--heading); font-size: 25px; line-height: 1.2; }
.stack-form { display: grid; gap: 17px; margin-top: 8px; }
.field { display: grid; gap: 8px; color: var(--heading); font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea, .toolbar-input { width: 100%; min-height: 48px; padding: 12px 15px; color: var(--heading); background: var(--white); border: 1px solid var(--input); border-radius: 12px; outline: 0; transition: border .2s, box-shadow .2s; }
.field textarea { min-height: 96px; resize: vertical; }
.field input::placeholder, .toolbar-input::placeholder { color: #a8afb8; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar-input:focus { border-color: var(--main); box-shadow: 0 0 0 3px rgba(34,117,252,.11); }
.primary-button, .secondary-button, .danger-button, .ghost-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 0; border-radius: 11px; font-weight: 700; transition: transform .15s, background .2s, color .2s; }
.primary-button { color: #fff; background: var(--main); }
.primary-button:hover { background: var(--main-dark); transform: translateY(-1px); }
.secondary-button { color: var(--main); background: #eaf2ff; }
.secondary-button:hover { background: #dceaff; }
.danger-button { color: var(--red); background: var(--red-soft); }
.danger-button:hover { background: #ffe1e1; }
.ghost-button { color: var(--body-text); background: var(--hover); }
.ghost-button:hover { color: var(--heading); background: #e2eaf3; }
.small-button { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.wide { width: 100%; }
.form-status { min-height: 20px; color: var(--red); font-size: 13px; }
.auth-hint { color: var(--note); font-size: 12px; line-height: 1.5; }

/* Shell ----------------------------------------------------------------- */
.app-shell { display: block; min-height: 100vh; }
.sidebar { position: fixed; top: 0; right: 0; z-index: 30; display: flex; flex-direction: column; width: min(360px, calc(100vw - 24px)); height: 100vh; min-height: 0; padding: 30px 24px 24px; overflow-y: auto; background: var(--white); border-left: 1px solid var(--stroke); border-radius: 18px 0 0 18px; box-shadow: -18px 0 50px rgba(20,25,38,.16); transform: translateX(105%); visibility: hidden; transition: transform .3s cubic-bezier(.16, 1, .3, 1), visibility 0s linear .3s; }
.sidebar.is-open { transform: translateX(0); visibility: visible; transition-delay: 0s; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 0 24px; margin-bottom: 24px; border-bottom: 1px solid var(--stroke); }
.brand-small { display: grid; justify-content: start; gap: 3px; }
.brand-small strong { font-size: 19px; }
.brand-small span { font-size: 11px; }
.owner-chip { display: flex; align-items: center; gap: 11px; margin: 0 0 24px; padding: 12px; background: transparent; border: 1px solid var(--input); border-radius: 15px; }
.avatar { display: grid; flex: 0 0 35px; width: 35px; height: 35px; place-items: center; color: #fff; background: var(--main); border-radius: 11px; font-weight: 800; }
.owner-copy { display: grid; min-width: 0; gap: 2px; }
.owner-copy strong { overflow: hidden; color: var(--heading); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.owner-copy small { color: var(--note); font-size: 11px; text-transform: capitalize; }
.side-nav { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 43px; padding: 0 13px; color: var(--body-text); background: transparent; border: 0; border-radius: 12px; text-align: left; font-weight: 600; transition: color .2s ease, background-color .2s ease; }
.nav-label { display: flex; align-items: center; gap: 11px; min-width: 0; }
.nav-icon, .nav-arrow { display: grid; flex: 0 0 20px; place-items: center; color: var(--main); opacity: .78; }
.nav-icon .ui-icon { width: 18px; height: 18px; }
.nav-arrow { flex-basis: 16px; margin-left: auto; opacity: 0; transition: opacity .2s ease, transform .2s ease; }
.nav-arrow .ui-icon { width: 15px; height: 15px; }
.nav-item:hover { background: var(--hover); color: var(--heading); }
.nav-item.is-active { color: var(--main); background: #edf4ff; }
.nav-item:hover .nav-arrow, .nav-item.is-active .nav-arrow { opacity: 1; transform: translateX(2px); }
.nav-count { display: inline-grid; min-width: 20px; height: 20px; margin-left: auto; place-items: center; color: #fff; background: var(--orange); border-radius: 8px; font-size: 10px; }
.nav-count + .nav-arrow { margin-left: 8px; }
.sidebar-bottom { display: grid; gap: 8px; margin-top: auto; padding-top: 20px; border-top: 1px solid var(--stroke); }
.site-link, .logout-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 13px; border-radius: 11px; font-size: 12px; font-weight: 700; text-align: left; transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .2s ease; }
.sidebar-link-label { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-link-label .ui-icon, .site-link > .ui-icon, .logout-arrow { flex: 0 0 17px; width: 17px; height: 17px; }
.site-link { color: var(--note); background: transparent; border: 1px solid transparent; }
.site-link:hover { color: var(--heading); background: var(--hover); border-color: var(--stroke); transform: translateY(-1px); }
.logout-button { color: var(--style); background: transparent; border: 1px solid var(--style); }
.logout-button:hover { color: #fff; background: var(--style); border-color: var(--style); transform: translateY(-1px); }
.main-content { width: 100%; min-height: 100vh; margin: 0; padding: 36px clamp(22px, 5vw, 76px) 60px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; max-width: 1220px; margin: 0 auto 34px; }
.topbar h1 { margin-top: 6px; color: var(--heading); font-size: clamp(26px, 3vw, 34px); letter-spacing: -.04em; }
.topbar-account { display: flex; align-items: center; gap: 10px; color: var(--note); font-size: 12px; }
.role-pill, .status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; color: var(--main); background: #eaf2ff; border-radius: 999px; font-size: 11px; font-weight: 700; }
.global-status { max-width: 1220px; min-height: 0; margin: -18px auto 18px; color: var(--red); font-size: 13px; }
.view-content { max-width: 1220px; margin: 0 auto; }
.icon-button { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; padding: 0; color: var(--heading); background: var(--white); border: 1px solid var(--input); border-radius: 50%; box-shadow: var(--shadow); font-size: 20px; line-height: 1; transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .2s ease; }
.icon-button .ui-icon { width: 20px; height: 20px; }
.ui-icon { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover { color: var(--main); background: var(--hover); border-color: var(--main); transform: translateY(-1px); }
.sidebar-close { flex-basis: 38px; width: 38px; height: 38px; color: var(--note); background: transparent; box-shadow: none; font-size: 22px; }
.sidebar-close .ui-icon { width: 18px; height: 18px; }
.avatar .ui-icon { width: 18px; height: 18px; }
.sidebar-close:hover { background: var(--hover); }
.menu-backdrop { position: fixed; z-index: 20; inset: 0; background: rgba(17,24,39,.28); }
body.menu-open { overflow: hidden; }

/* Shared content -------------------------------------------------------- */
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-intro h2 { color: var(--heading); font-size: 20px; letter-spacing: -.025em; }
.page-intro p { margin-top: 5px; color: var(--note); font-size: 13px; }
.toolbar { display: flex; align-items: center; gap: 9px; }
.toolbar-input { min-width: 230px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { min-height: 136px; padding: 20px; background: var(--white); border: 1px solid var(--stroke); border-radius: 18px; box-shadow: var(--shadow); }
.stat-card .stat-label { color: var(--note); font-size: 12px; font-weight: 600; }
.stat-card strong { display: block; margin-top: 13px; color: var(--heading); font-size: 30px; letter-spacing: -.05em; }
.stat-card em { display: block; margin-top: 2px; color: var(--note); font-size: 11px; font-style: normal; }
.stat-card.accent { background: var(--main); }
.stat-card.accent .stat-label, .stat-card.accent em { color: rgba(255,255,255,.76); }
.stat-card.accent strong { color: #fff; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 18px; }
.card { padding: 22px; background: var(--white); border: 1px solid transparent; border-radius: 18px; box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.card-heading h3 { color: var(--heading); font-size: 15px; }
.card-heading p { margin-top: 4px; color: var(--note); font-size: 12px; }
.quick-list { display: grid; gap: 9px; }
.quick-action { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 14px; color: var(--heading); background: var(--backdrop); border: 1px solid transparent; border-radius: 12px; font-weight: 700; text-align: left; transition: color .2s ease, background-color .2s ease, border-color .2s ease, transform .2s ease; }
.quick-action:hover { color: var(--main); background: #edf4ff; }
.quick-action .ui-icon { flex: 0 0 16px; width: 16px; height: 16px; }
.empty-state { padding: 42px 20px; color: var(--note); background: var(--white); border-radius: 18px; text-align: center; }
.table-list { display: grid; gap: 10px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; background: var(--white); border: 1px solid var(--stroke); border-radius: 14px; }
.list-main { min-width: 0; }
.list-main strong { display: block; overflow: hidden; color: var(--heading); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.list-main p { margin-top: 4px; color: var(--note); font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 20px 0 4px; }
.pagination span { color: var(--note); font-size: 12px; }
.pagination button { min-width: 35px; height: 34px; color: var(--main); background: var(--white); border: 1px solid var(--stroke); border-radius: 9px; font-weight: 700; }
.pagination button:disabled { color: #c7ced7; cursor: default; }
.field-select { min-height: 34px; padding: 6px 9px; color: var(--heading); background: var(--white); border: 1px solid var(--stroke); border-radius: 9px; font-size: 12px; }
.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 44px)); padding: 13px 16px; color: #fff; background: var(--heading); border-radius: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast[data-kind="error"] { background: var(--red); }

/* Reviews --------------------------------------------------------------- */
.tab-line { display: flex; gap: 22px; margin-bottom: 19px; border-bottom: 1px solid var(--stroke); }
.tab-button { position: relative; padding: 0 0 12px; color: var(--note); background: none; border: 0; font-weight: 700; }
.tab-button::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; content: ""; background: var(--main); transform: scaleX(0); transition: transform .2s; }
.tab-button.is-active { color: var(--main); }
.tab-button.is-active::after { transform: scaleX(1); }
.review-card { padding: 18px; background: var(--white); border: 1px solid var(--stroke); border-radius: 16px; }
.review-card + .review-card { margin-top: 10px; }
.review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.review-head h3 { color: var(--heading); font-size: 14px; }
.review-meta { margin-top: 4px; color: var(--note); font-size: 11px; }
.review-body { margin: 14px 0; color: var(--heading); font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.stars { color: #f6a623; letter-spacing: 1px; }
.status-pending { color: var(--orange); background: var(--orange-soft); }
.status-approved { color: var(--green); background: var(--green-soft); }
.status-rejected, .status-deleted { color: var(--red); background: var(--red-soft); }
.filter-line { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filter-button { padding: 8px 12px; color: var(--note); background: var(--white); border: 1px solid var(--stroke); border-radius: 9px; font-size: 12px; font-weight: 700; }
.filter-button.is-active { color: var(--main); background: #eaf2ff; border-color: #d7e6ff; }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { width: min(360px, calc(100vw - 24px)); padding: 24px 18px 20px; }
  .main-content { width: 100%; margin-left: 0; padding: 22px 16px 45px; }
  .topbar { align-items: center; margin-bottom: 25px; }
  .topbar h1 { font-size: 27px; }
  .topbar-account { display: none; }
  .topbar .icon-button { flex: 0 0 auto; }
  .toolbar, .page-intro { align-items: stretch; flex-direction: column; }
  .toolbar-input { min-width: 0; }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 115px; padding: 16px; }
  .stat-card strong { margin-top: 8px; font-size: 25px; }
  .list-row { align-items: flex-start; flex-direction: column; }
  .row-actions { justify-content: flex-start; }
}
@media (max-width: 430px) {
  .auth-card { padding: 24px 19px; }
  .brand-lockup { flex-direction: column; align-items: center; gap: 4px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card .stat-label { font-size: 11px; }
  .stat-card strong { font-size: 22px; }
  .card { padding: 17px; }
}

/* Theme and announcements ------------------------------------------------ */
.topbar-tools { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.theme-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 7px 10px; color: var(--body-text); background: var(--white); border: 1px solid var(--stroke); border-radius: 10px; font-size: 12px; font-weight: 700; transition: color .2s, background .2s, border-color .2s; }
.theme-toggle:hover { color: var(--main); background: var(--hover); border-color: var(--main); }
.theme-toggle span:first-child { font-size: 16px; line-height: 1; }
.check-line { display: flex; align-items: flex-start; gap: 10px; color: var(--heading); font-size: 13px; cursor: pointer; }
.check-line input { flex: 0 0 auto; width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--main); }
.check-line span { display: grid; gap: 3px; }
.check-line small { color: var(--note); font-size: 12px; font-weight: 400; }
.announcement-admin-row { align-items: flex-start; }
.announcement-admin-title { display: flex; align-items: center; gap: 8px; }
.announcement-dot { display: inline-block; flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%; }
.announcement-dot-success { background: var(--green); }
.announcement-dot-danger { background: var(--red); }
.field-hint { margin-top: -8px; color: var(--note); font-size: 12px; line-height: 1.5; }
.field-hint code { padding: 2px 5px; color: var(--main); background: var(--hover); border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.announcement-preview-wrap { display: grid; gap: 8px; margin-top: -2px; }
.announcement-preview { display: block; padding: 13px 14px; border: 1px solid transparent; border-left-width: 4px; border-radius: 11px; font-size: 13px; line-height: 1.5; }
.announcement-preview strong { display: block; margin-bottom: 2px; }
.announcement-preview p strong { display: inline; margin: 0; font-size: inherit; }
.announcement-preview p { margin: 0; white-space: pre-wrap; }
.announcement-preview-success { color: #166534; background: #ecfdf5; border-color: #bbf7d0; border-left-color: #22c55e; }
.announcement-preview-danger { color: #991b1b; background: #fef2f2; border-color: #fecaca; border-left-color: #ef4444; }
.announcement-preview a, .announcement-admin-body a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.announcement-admin-body { overflow: visible !important; white-space: normal !important; }
.announcement-admin-body strong { display: inline; overflow: visible; color: inherit; font-size: inherit; text-overflow: clip; white-space: normal; }
.announcement-date { color: var(--note); }
.role-permissions-card { margin-bottom: 18px; }
.permissions-table-wrap { overflow-x: auto; }
.permissions-table { width: 100%; min-width: 720px; border-collapse: collapse; }
.permissions-table th, .permissions-table td { padding: 12px 13px; border-bottom: 1px solid var(--stroke); text-align: left; vertical-align: top; font-size: 12px; }
.permissions-table th { color: var(--note); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.permissions-table td:first-child { color: var(--heading); font-weight: 700; }
.permissions-table tr:last-child td { border-bottom: 0; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --main: #6ca4ff;
  --main-dark: #4f8ff4;
  --white: #1e293b;
  --heading: #f8fafc;
  --body-text: #cbd5e1;
  --green: #4ade80;
  --green-soft: #123d2d;
  --style: #ff8662;
  --red: #ff7777;
  --red-soft: #44232c;
  --orange: #ffad70;
  --orange-soft: #4c3221;
  --input: #324055;
  --stroke: #324055;
  --backdrop: #121923;
  --hover: #273445;
  --note: #94a3b8;
  --shadow: 0 4px 24px rgba(0, 0, 0, .2);
}

:root[data-theme="dark"] body { background: var(--backdrop); }
:root[data-theme="dark"] .auth-card { border-color: var(--stroke); }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .toolbar-input,
:root[data-theme="dark"] .field-select { color: var(--heading); background: var(--white); border-color: var(--input); }
:root[data-theme="dark"] .field input::placeholder,
:root[data-theme="dark"] .toolbar-input::placeholder { color: #718198; }
:root[data-theme="dark"] .secondary-button { color: #a9c7ff; background: #20385f; }
:root[data-theme="dark"] .secondary-button:hover { background: #294875; }
:root[data-theme="dark"] .danger-button { color: #ffaaaa; background: var(--red-soft); }
:root[data-theme="dark"] .danger-button:hover { background: #5a2a35; }
:root[data-theme="dark"] .ghost-button { color: var(--body-text); background: var(--hover); }
:root[data-theme="dark"] .ghost-button:hover { color: var(--heading); background: #304057; }
:root[data-theme="dark"] .nav-item:hover { color: var(--heading); background: var(--hover); }
:root[data-theme="dark"] .nav-item.is-active { color: var(--main); background: #223b61; }
:root[data-theme="dark"] .quick-action { color: var(--heading); background: var(--white); border-color: var(--stroke); }
:root[data-theme="dark"] .quick-action:hover { color: var(--main); background: #223b61; border-color: #3a619a; transform: translateY(-1px); }
:root[data-theme="dark"] .role-pill { color: #a9c7ff; background: #223b61; }
:root[data-theme="dark"] .logout-button { color: var(--style); background: transparent; border-color: var(--style); }
:root[data-theme="dark"] .logout-button:hover { color: #fff; background: var(--style); border-color: var(--style); }
:root[data-theme="dark"] .site-link:hover { background: var(--hover); border-color: var(--stroke); }
:root[data-theme="dark"] .status-pending { color: var(--orange); background: var(--orange-soft); }
:root[data-theme="dark"] .status-approved { color: var(--green); background: var(--green-soft); }
:root[data-theme="dark"] .status-rejected,
:root[data-theme="dark"] .status-deleted { color: #ffaaaa; background: var(--red-soft); }
:root[data-theme="dark"] .filter-button { color: var(--body-text); background: var(--white); border-color: var(--stroke); }
:root[data-theme="dark"] .filter-button.is-active { color: var(--main); background: #223b61; border-color: #315887; }
:root[data-theme="dark"] .stat-card,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .list-row,
:root[data-theme="dark"] .review-card,
:root[data-theme="dark"] .empty-state { border-color: var(--stroke); }
:root[data-theme="dark"] .stat-card { border: 1px solid var(--stroke); }
:root[data-theme="dark"] .list-row,
:root[data-theme="dark"] .review-card { border-color: var(--stroke); }
:root[data-theme="dark"] .announcement-preview-success { color: #bbf7d0; background: #123326; border-color: #1d5a3d; }
:root[data-theme="dark"] .announcement-preview-danger { color: #fecaca; background: #3a1f26; border-color: #6b2b37; }

@media (max-width: 760px) {
  .topbar-tools { gap: 8px; }
  .theme-toggle { padding: 7px 9px; }
  .theme-toggle span:last-child { display: none; }
}
