:root {
  --navy: #15334b;
  --navy-dark: #0d2538;
  --blue: #2474c6;
  --blue-soft: #eaf3fb;
  --green: #198754;
  --green-soft: #e9f7ef;
  --amber: #b66b00;
  --amber-soft: #fff5df;
  --red: #bc3d3d;
  --red-soft: #fff0f0;
  --ink: #172333;
  --muted: #6c7887;
  --line: #dce3ea;
  --surface: #ffffff;
  --background: #f3f6f9;
  --shadow: 0 10px 30px rgba(18, 44, 65, .06);
}

* { box-sizing: border-box; }
html { min-width: 320px; overflow-x: hidden; }
body { margin: 0; overflow-x: hidden; background: var(--background); color: var(--ink); font: 15px/1.5 Inter, "Segoe UI", Arial, sans-serif; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
code { padding: 2px 6px; border-radius: 5px; background: #edf1f5; color: #36495a; font-size: 13px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 31px; line-height: 1.15; letter-spacing: -.03em; }
h2 { margin-bottom: 14px; font-size: 20px; line-height: 1.25; }
small { display: block; color: var(--muted); }

.topbar { position: sticky; z-index: 50; top: 0; display: flex; align-items: center; min-height: 68px; padding: 0 28px; border-bottom: 1px solid #dbe2e8; background: rgba(255,255,255,.96); box-shadow: 0 1px 8px rgba(16,42,62,.04); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 11px; min-width: 220px; color: var(--navy); }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--navy); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .05em; }
.brand strong, .brand small { display: block; line-height: 1.2; }
.brand small { margin-top: 3px; font-size: 11px; }
.nav { display: flex; align-self: stretch; gap: 3px; }
.nav a { display: flex; align-items: center; padding: 0 14px; border-bottom: 3px solid transparent; color: #526171; font-size: 14px; font-weight: 600; }
.nav a:hover { color: var(--navy); background: #f7f9fb; }
.nav a.active { border-bottom-color: var(--blue); color: var(--navy); }
.user-menu { display: flex; align-items: center; gap: 16px; margin-left: auto; padding-left: 20px; }
.user-menu span strong, .user-menu span small { display: block; text-align: right; line-height: 1.25; }
.user-menu span small { margin-top: 3px; font-size: 11px; }
.link-button { padding: 0; border: 0; background: none; color: var(--blue); cursor: pointer; }

.page-shell { width: min(1480px, calc(100% - 48px)); min-width: 0; margin: 0 auto; padding: 32px 0 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading .muted { margin-bottom: 0; }
.eyebrow { margin-bottom: 6px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); }
.back-link { display: inline-block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.heading-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 13px; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-heading h2, .section-heading h2 { margin: 0; }
.section-note { color: var(--muted); font-size: 12px; }
.callout { margin: 0 0 22px; padding: 14px 17px; border: 1px solid #cddff0; border-radius: 10px; background: var(--blue-soft); color: #36546e; }
.flash { margin-bottom: 20px; padding: 14px 18px; border-radius: 10px; font-weight: 600; }
.flash.success { border: 1px solid #b9e4cb; background: var(--green-soft); color: #12643c; }
.flash.error { border: 1px solid #f0c3c3; background: var(--red-soft); color: #932f2f; }
.empty { padding: 34px !important; color: var(--muted); text-align: center; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; line-height: 1; cursor: pointer; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; transform: none; cursor: wait; }
.button.primary { background: var(--blue); color: #fff; box-shadow: 0 6px 16px rgba(36,116,198,.2); }
.button.primary:hover { background: #1d65ae; }
.button.secondary { border-color: #bfd1e2; background: #f7fbff; color: #26597f; }
.button.ghost { border-color: var(--line); background: #fff; color: #536273; }
.button.small { min-height: 33px; padding: 7px 11px; font-size: 12px; }
.button.wide { width: 100%; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.metric { min-height: 156px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); color: var(--ink); }
.metric span, .metric small { display: block; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { display: block; margin: 12px 0 3px; font-size: 42px; line-height: 1; letter-spacing: -.04em; }
.metric.green { border-top: 4px solid var(--green); }
.metric.green strong { color: var(--green); }
.metric.amber { border-top: 4px solid #e9a52c; }
.metric.amber strong { color: var(--amber); }
.metric.blue { border-top: 4px solid var(--blue); }
.metric.blue strong { color: var(--blue); }
.metric.gray { border-top: 4px solid #8493a1; }
.metric.gray strong { color: #5b6b79; }
.two-columns { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .75fr); gap: 20px; }
.two-columns > .panel { padding: 24px; }
.activity-list { margin-top: 22px; }
.activity-row { display: grid; grid-template-columns: 50px 1fr 60px; align-items: center; gap: 12px; margin: 9px 0; }
.activity-row time { color: var(--muted); font-size: 12px; }
.activity-bars { display: grid; gap: 4px; }
.activity-bars > div { height: 6px; overflow: hidden; border-radius: 99px; background: #edf1f5; }
.activity-bars span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }
.activity-bars .complete span { background: var(--green); }
.activity-values { display: flex; justify-content: space-between; font-size: 12px; }
.activity-values strong { color: var(--blue); }
.activity-values span { color: var(--green); }
.legend { display: flex; gap: 18px; margin-top: 18px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; }
.blue-dot { background: var(--blue); }.green-dot { background: var(--green); }
.sync-summary .status-pill { margin-bottom: 14px; }
.summary-list { margin: 8px 0 20px; }
.summary-list div { display: flex; justify-content: space-between; gap: 15px; padding: 9px 0; border-bottom: 1px solid #edf0f3; }
.summary-list dt { color: var(--muted); }.summary-list dd { margin: 0; font-weight: 700; }

.filters { display: grid; grid-template-columns: minmax(260px, 1.5fr) repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; padding: 16px; }
label { color: #415365; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; margin-top: 6px; padding: 10px 11px; border: 1px solid #cdd7e0; border-radius: 8px; outline: none; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #6ba7dc; box-shadow: 0 0 0 3px rgba(36,116,198,.1); }
input[readonly], textarea[readonly], select:disabled { background: #f4f6f8; color: #687684; }
textarea { resize: vertical; }
.filter-actions { display: flex; align-items: flex-end; gap: 8px; grid-column: 1 / -1; justify-content: flex-end; }
.table-wrap { overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 13px 16px; border-bottom: 1px solid var(--line); background: #f7f9fb; color: #627180; font-size: 11px; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
.data-table td { padding: 14px 16px; border-bottom: 1px solid #edf0f3; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfd; }
.data-table td strong, .data-table td span, .data-table td small { display: block; }
.data-table td small { margin-top: 4px; }
.status-pill { display: inline-flex !important; width: max-content; align-items: center; padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: 800; }
.status-pill.success { background: var(--green-soft); color: var(--green); }
.status-pill.failed, .status-pill.error { background: var(--red-soft); color: var(--red); }
.status-pill.running { background: var(--amber-soft); color: var(--amber); }
.status-pill.muted { background: #edf1f4; color: #657481; }
.percent-cell { min-width: 120px; }
.percent-cell > div { height: 6px; margin-top: 6px; overflow: hidden; border-radius: 99px; background: #e9edf1; }
.percent-cell > div span { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #e9a52c, var(--green)); }
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; }
.pagination a { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #526273; }
.pagination a.active { border-color: var(--blue); background: var(--blue); color: #fff; }

.completion-card { min-width: 180px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.completion-card span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.completion-card strong { float: right; color: var(--blue); font-size: 21px; }
.completion-card div { clear: both; height: 6px; margin-top: 10px; overflow: hidden; border-radius: 99px; background: #e7ecf0; }
.completion-card i { display: block; height: 100%; background: linear-gradient(90deg, #e9a52c, var(--green)); }
.product-form { display: grid; min-width: 0; max-width: 100%; gap: 18px; }
.form-section { padding: 24px; }
.section-heading { margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.service-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.field-legend { display: grid; grid-template-columns: 92px 92px; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; text-align: center; }
.sticker-fields { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.sticker-field { display: grid; grid-template-columns: minmax(0, 1fr) 92px 92px; align-items: stretch; border-bottom: 1px solid var(--line); background: #fff; transition: background .15s; }
.sticker-field:last-child { border-bottom: 0; }
.sticker-field:hover { background: #fbfcfd; }
.sticker-field.not-required { background: #f6f7f8; }
.sticker-field.not-required .field-input { opacity: .58; }
.field-input { min-width: 0; padding: 13px 15px; }
.field-input > span:first-child { display: block; color: #3e5264; font-size: 12px; font-weight: 800; }
.field-input input, .field-input select, .field-input textarea { margin-top: 7px; }
.check-cell { display: grid; place-items: center; border-left: 1px solid var(--line); cursor: pointer; }
.check-cell input { position: absolute; opacity: 0; pointer-events: none; }
.check-cell span { position: relative; width: 22px; height: 22px; border: 2px solid #b9c5cf; border-radius: 6px; background: #fff; }
.check-cell input:checked + span { border-color: var(--blue); background: var(--blue); }
.check-cell input:checked + span::after { position: absolute; top: 2px; left: 6px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; content: ""; transform: rotate(45deg); }
.check-cell input:disabled + span { opacity: .42; }
.switch-value { display: flex !important; width: max-content; align-items: center; gap: 8px; margin-top: 8px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fb; }
.switch-value input { width: auto; margin: 0; }
.form-footer { position: sticky; z-index: 20; bottom: 14px; display: flex; justify-content: flex-end; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.95); box-shadow: 0 10px 30px rgba(16,42,62,.13); backdrop-filter: blur(12px); }
.moderation-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 28px; padding: 24px; border-left: 5px solid var(--blue); }
.moderation-card h2 { margin-bottom: 7px; }
.moderation-card p.muted { max-width: 760px; margin-bottom: 6px; }
.moderation-toggle { display: flex; width: auto; min-width: 190px; align-items: center; justify-content: flex-start; gap: 12px; padding: 15px 18px; border: 1px solid #c8d7e5; border-radius: 12px; background: #f7fbff; cursor: pointer; }
.moderation-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.moderation-toggle > span { position: relative; width: 44px; height: 24px; flex: 0 0 auto; border-radius: 99px; background: #b8c4ce; transition: .18s ease; }
.moderation-toggle > span::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); content: ""; transition: .18s ease; }
.moderation-toggle input:checked + span { background: var(--green); }
.moderation-toggle input:checked + span::after { transform: translateX(20px); }
.moderation-toggle strong { color: var(--navy); }

.settings-form { padding: 25px; }
.settings-checks { display: flex; gap: 24px; margin: 20px 0; padding: 16px; border-radius: 10px; background: #f6f8fa; }
.settings-checks label { display: flex; align-items: center; gap: 8px; }
.settings-checks input { width: auto; margin: 0; }
.file-field { display: block; padding: 16px; border: 1px dashed #aab9c7; border-radius: 10px; background: #fafcfd; }
.file-field input { border: 0; padding: 8px 0; background: transparent; }
.file-field small { margin-top: 4px; }
.stack-form { display: grid; gap: 14px; }
.users-layout { grid-template-columns: minmax(280px, .6fr) minmax(0, 1.4fr); }
.user-list article { display: grid; grid-template-columns: minmax(150px, 1fr) auto minmax(280px, 1fr); align-items: center; gap: 15px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.user-list article:last-child { border: 0; }
.user-list article > div > span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.user-actions, .user-actions form { display: flex; gap: 8px; }
.user-actions input { min-width: 130px; margin: 0; padding: 7px 9px; }
.three-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 20px; }
.action-card { padding: 24px; }
.action-card .step { display: grid; width: 32px; height: 32px; margin-bottom: 17px; place-items: center; border-radius: 50%; background: var(--navy); color: #fff; font-weight: 800; }
.action-card p { min-height: 68px; color: var(--muted); }
.split-links { display: flex; justify-content: space-between; margin-top: 13px; font-size: 12px; }
.notice { padding: 13px; border-radius: 8px; background: var(--amber-soft); color: #7b5414; font-size: 12px; }
.error-text { max-width: 420px; margin-top: 6px; color: var(--red); white-space: normal; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #dcebf7 0, transparent 35%), linear-gradient(145deg, #f6f9fb, #eaf0f5); }
.login-card { width: min(420px, 100%); padding: 38px; border: 1px solid rgba(255,255,255,.8); border-radius: 20px; background: rgba(255,255,255,.92); box-shadow: 0 24px 60px rgba(20,51,75,.14); backdrop-filter: blur(14px); }
.login-logo { display: grid; width: 54px; height: 54px; margin-bottom: 24px; place-items: center; border-radius: 15px; background: var(--navy); color: #fff; font-weight: 900; }
.login-card h1 { font-size: 34px; }
.login-card .stack-form { margin-top: 24px; }
.error-page { max-width: 620px; margin: 80px auto; text-align: center; }
.error-page > span { display: grid; width: 64px; height: 64px; margin: 0 auto 22px; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 30px; font-weight: 900; }

@media (max-width: 1180px) {
  .topbar { padding: 0 18px; }
  .brand { min-width: auto; margin-right: 14px; }
  .brand > span:last-child { display: none; }
  .nav a { padding: 0 9px; font-size: 12px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .search-field { grid-column: span 2; }
  .service-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .topbar { position: static; flex-wrap: wrap; padding: 12px 16px; }
  .brand { order: 1; }
  .user-menu { order: 2; }
  .nav { order: 3; width: 100%; margin-top: 10px; overflow-x: auto; }
  .nav a { min-height: 40px; white-space: nowrap; }
  .page-shell { width: min(100% - 24px, 100%); padding-top: 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics-grid, .two-columns, .three-cards, .users-layout { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .search-field { grid-column: 1 / -1; }
  .table-wrap { overflow-x: auto; }
  .data-table { min-width: 850px; }
  .sticker-field { grid-template-columns: minmax(0, 1fr) 62px 62px; }
  .field-legend { grid-template-columns: 62px 62px; }
  .form-grid, .service-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .user-list article { grid-template-columns: 1fr; }
  .user-actions { flex-wrap: wrap; }
  .moderation-card { grid-template-columns: 1fr; align-items: flex-start; }
}

@media (max-width: 520px) {
  h1 { font-size: 27px; }
  .user-menu span { display: none; }
  .metrics-grid, .filters { grid-template-columns: 1fr; }
  .metric { min-height: 130px; }
  .completion-card { width: 100%; }
  .form-section, .settings-form, .two-columns > .panel { padding: 16px; }
  .sticker-field { grid-template-columns: minmax(0, 1fr) 48px 48px; }
  .field-legend { grid-template-columns: 48px 48px; }
  .form-footer { bottom: 6px; }
}
