:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #f7fbfd;
  --surface-3: #eaf5fa;
  --line: #e5edf2;
  --text: #333333;
  --muted: #7c8993;
  --accent: #00a5e1;
  --accent-hover: #008cc8;
  --accent-soft: rgba(0, 165, 225, .08);
  --success: #1f9d68;
  --warning: #b97912;
  --danger: #dc3545;
  --radius: 16px;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.admin-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: white;
  box-shadow: 4px 0 20px rgba(0, 0, 0, .025);
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 20px;
  position: sticky;
  top: 0;
}
.brand { align-items: center; display: flex; justify-content: center; padding: 5px 10px 34px; }
.brand__word { color: var(--accent); font-size: 40px; font-weight: 900; letter-spacing: -.06em; line-height: 1; }
.navigation { display: grid; gap: 5px; overflow-y: auto; }
.navigation__item {
  align-items: center;
  border-radius: 10px;
  color: #707b84;
  display: flex;
  font-size: 14px;
  gap: 12px;
  padding: 12px 15px;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.navigation__item:hover { background: var(--accent-soft); color: var(--accent); }
.navigation__item.is-active { background: var(--accent); box-shadow: 0 4px 10px rgba(0, 165, 225, .28); color: white; }
.navigation__item span { font-size: 17px; text-align: center; width: 20px; }
.sidebar__account { align-items: center; border-top: 1px solid var(--line); display: flex; gap: 10px; margin-top: auto; padding: 16px 8px 0; }
.avatar { align-items: center; background: var(--accent); border-radius: 50%; color: white; display: flex; font-weight: 700; height: 34px; justify-content: center; width: 34px; }
.sidebar__identity { min-width: 0; flex: 1; }
.sidebar__identity strong, .sidebar__identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__identity strong { font-size: 12px; }
.sidebar__identity small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.workspace { min-width: 0; }
.page { margin: 0 auto; max-width: 1500px; padding: 30px 40px 64px; }
.page > section + section { margin-top: 22px; }
.mobile-header { display: none; }

.page-header { align-items: flex-end; display: flex; gap: 24px; justify-content: space-between; margin-bottom: 28px; }
.page-header h1 { font-size: clamp(26px, 3vw, 38px); letter-spacing: -.04em; margin: 0; }
.page-header p { color: var(--muted); margin: 7px 0 0; }
.page-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }

.grid { display: grid; gap: 16px; }
.grid--metrics { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: 0 5px 20px rgba(0, 0, 0, .035); overflow: hidden; }
.card__header { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 16px; justify-content: space-between; padding: 17px 19px; }
.card__header h2, .card__header h3 { font-size: 14px; margin: 0; }
.card__body { padding: 19px; }
.metric { background: white; min-height: 132px; padding: 20px; transition: transform .2s ease, box-shadow .2s ease; }
.metric:hover { box-shadow: 0 10px 30px rgba(0, 0, 0, .07); transform: translateY(-3px); }
.metric strong { display: block; font-size: 27px; letter-spacing: -.04em; margin-top: 16px; }
.metric span { color: var(--muted); font-size: 11px; }
.metric--alert strong { color: var(--danger); }
.metric__delta { color: var(--success); display: block; font-size: 10px; margin-top: 9px; }
.metric__delta.is-negative { color: var(--danger); }

.table-wrap { overflow: auto; }
table { border-collapse: collapse; font-size: 12px; width: 100%; }
th { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid var(--line); padding: 12px 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
.empty-cell { color: var(--muted); padding: 34px; text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.muted { color: var(--muted); }
.block { display: block; margin-top: 4px; }
.danger { color: var(--danger); }
.success { color: var(--success); }
.is-hidden { display: none !important; }

.badge { border: 1px solid transparent; border-radius: 999px; display: inline-flex; font-size: 9px; font-weight: 700; letter-spacing: .05em; padding: 4px 7px; text-transform: uppercase; }
.badge--success { background: #e9f8f1; border-color: #c9eadb; color: var(--success); }
.badge--warning { background: #fff6df; border-color: #f3dfaa; color: var(--warning); }
.badge--danger { background: #fff0f1; border-color: #f4cdd1; color: var(--danger); }
.badge--neutral { background: #edf2f5; border-color: #dce5ea; color: #66737d; }

.button { align-items: center; background: white; border: 1px solid #d7e2e8; border-radius: 10px; color: var(--text); cursor: pointer; display: inline-flex; font-size: 12px; font-weight: 650; gap: 7px; justify-content: center; min-height: 38px; padding: 8px 13px; }
.button:hover { border-color: var(--accent); color: var(--accent); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button--primary { background: var(--accent); border-color: var(--accent); box-shadow: 0 7px 16px rgba(0, 165, 225, .22); color: white; }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }
.button--danger { background: #fff1f2; border-color: #f4c9cd; color: var(--danger); }
.button--small { min-height: 30px; padding: 5px 9px; }
.icon-button { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 17px; padding: 7px; }

.field { display: grid; gap: 7px; }
.field label { color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.input, .select, .textarea {
  background: #f9fbfc;
  border: 1px solid #dde7ec;
  border-radius: 9px;
  color: var(--text);
  min-height: 39px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}
.textarea { min-height: 88px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { background: white; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 165, 225, .1); }
.form-grid { display: grid; gap: 13px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-actions { align-items: flex-end; display: flex; gap: 8px; }
.checkbox { align-items: center; display: inline-flex; font-size: 12px; gap: 7px; }
.checkbox input { accent-color: var(--accent); }
.toolbar { align-items: end; display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar .field { min-width: 190px; }

.state { align-items: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); display: flex; flex-direction: column; gap: 8px; justify-content: center; min-height: 180px; padding: 30px; text-align: center; }
.state--error { border-color: #efc5ca; color: var(--danger); }
.state--loading::before { animation: spin .8s linear infinite; border: 2px solid #d6e2e8; border-top-color: var(--accent); border-radius: 50%; content: ''; height: 24px; width: 24px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { background: white; border: 1px solid var(--line); border-radius: 10px; bottom: 24px; box-shadow: 0 15px 50px rgba(35, 63, 78, .18); font-size: 12px; left: 50%; max-width: 420px; padding: 12px 16px; position: fixed; transform: translateX(-50%); z-index: 20; }
.toast--danger { border-color: #efc5ca; color: var(--danger); }
.token-box { background: #eef9fd; border: 1px solid var(--accent); border-radius: 10px; color: #006f9f; overflow-wrap: anywhere; padding: 14px; white-space: pre-wrap; }
.stack { display: grid; gap: 16px; }
.section-gap { margin-top: 22px; }
.split-detail { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); }
.detail-editor, .media-editor { margin: 12px 0; min-width: 320px; }
details summary { color: var(--accent); cursor: pointer; font-weight: 650; }

.catalog-summary .metric { min-height: 108px; }
.catalog-workspace { align-items: start; display: grid; gap: 18px; grid-template-columns: minmax(520px, .95fr) minmax(520px, 1.05fr); }
.catalog-product-list { position: sticky; top: 24px; }
.catalog-product-row { cursor: pointer; }
.catalog-product-row.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.catalog-editor { min-width: 0; }
.catalog-editor__header > div { min-width: 0; }
.catalog-editor__header h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-toolbar { align-items: end; flex-wrap: wrap; }
.catalog-toolbar .input { min-width: 230px; width: auto; }
.catalog-scope-note { background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 8px; display: grid; gap: 4px; padding: 11px 13px; }
.catalog-scope-note strong { font-size: 12px; }
.catalog-scope-note span { color: var(--muted); font-size: 11px; }
.catalog-warning { background: #fff6df; border: 1px solid #f3dfaa; border-radius: 9px; color: var(--warning); font-size: 11px; padding: 11px 13px; }
.catalog-json-editor { margin-top: 12px; }
.catalog-json-editor .textarea { min-height: 220px; }
.catalog-media-list { display: grid; gap: 8px; }
.catalog-product-cell { align-items: center; display: flex; gap: 10px; min-width: 190px; }
.catalog-media-card { background: var(--surface-2); border-radius: 12px; overflow: hidden; }
.catalog-media-item { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; padding: 10px 12px; }
.catalog-media-preview { align-items: center; aspect-ratio: 16 / 9; background: #eaf1f5; display: flex; justify-content: center; overflow: hidden; width: 100%; }
.catalog-media-preview img, .catalog-media-preview video { height: 100%; object-fit: cover; width: 100%; }
.catalog-media-preview.is-compact { aspect-ratio: 1; border-radius: 8px; flex: 0 0 46px; height: 46px; width: 46px; }
.catalog-media-preview.is-empty { color: #9aa8b1; font-size: 18px; }
.catalog-empty-state { min-height: 82px; }
.catalog-source-state { display: grid; gap: 8px; }
.catalog-source-state > strong { font-size: 15px; overflow-wrap: anywhere; }
.catalog-comparison-row--issue { background: #fffafb; }

.login { align-items: center; background: linear-gradient(135deg, #00a5e1 0%, #0082b4 100%); display: grid; min-height: 100vh; padding: 24px; }
.login__card { background: white; border-radius: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .16); margin: auto; max-width: 420px; padding: 40px 50px; text-align: center; width: 100%; }
.login__logo { color: var(--accent); font-size: 48px; font-weight: 900; letter-spacing: -.07em; line-height: 1; }
.login__card h1 { font-size: 24px; letter-spacing: -.03em; margin: 22px 0 8px; }
.login__card > p { color: var(--muted); margin: 0 0 28px; }
.login__form { display: grid; gap: 15px; }
.login__form .field { text-align: left; }
.login__form .button { font-size: 15px; min-height: 50px; margin-top: 5px; }
.login__error { color: var(--danger); font-size: 12px; min-height: 18px; }

@media (max-width: 1180px) {
  .grid--metrics { grid-template-columns: repeat(3, 1fr); }
  .form-grid--4 { grid-template-columns: repeat(2, 1fr); }
  .catalog-workspace { grid-template-columns: 1fr; }
  .catalog-product-list { position: static; }
}
@media (max-width: 780px) {
  .admin-shell { display: block; }
  .sidebar { bottom: 0; flex-direction: row; height: 66px; left: 0; padding: 7px; position: fixed; right: 0; top: auto; z-index: 10; }
  .sidebar > .brand, .sidebar__account { display: none; }
  .navigation { display: flex; gap: 3px; overflow-x: auto; width: 100%; }
  .navigation__item { flex: 0 0 66px; flex-direction: column; font-size: 9px; gap: 2px; justify-content: center; padding: 5px; }
  .navigation__item span { text-align: center; }
  .mobile-header { align-items: center; background: white; border-bottom: 1px solid var(--line); display: flex; height: 58px; padding: 8px 16px; }
  .mobile-header .brand { padding: 0 10px 0 0; }
  .mobile-header .brand__word { font-size: 24px; }
  .page { padding: 24px 14px 90px; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .grid--metrics, .grid--2, .grid--3, .form-grid, .form-grid--4, .split-detail, .catalog-workspace { grid-template-columns: 1fr; }
  .card__body { padding: 14px; }
  .catalog-toolbar .input { min-width: 0; width: 100%; }
}

@media (max-width: 480px) {
  .login__card { padding: 32px 24px; }
}
