:root {
  --ink: #172034;
  --muted: #68738a;
  --line: #e5e9f1;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --primary: #315bea;
  --primary-dark: #2044c3;
  --accent: #12324a;
  --success: #167a55;
  --warning: #a66108;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 246px; padding: 28px 22px;
  color: #dbe5ff; background: linear-gradient(175deg, #111c32 0%, #172c48 70%, #123b4e 100%);
  display: flex; flex-direction: column; z-index: 10;
}
.brand { display: flex; gap: 12px; align-items: center; color: #fff; margin: 0 6px 44px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.brand small { color: #91a5ca; font-size: 11px; margin-top: 3px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: #fff; color: #244ecf; font-weight: 800; letter-spacing: -.04em; box-shadow: 0 8px 22px #07101d55; }
.brand-mark--large { width: 54px; height: 54px; border-radius: 16px; font-size: 20px; background: var(--primary); color: #fff; }
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a, .nav-button { color: #c4d0e9; padding: 12px 14px; border-radius: 10px; font-size: 14px; background: transparent; border: 0; text-align: left; width: 100%; }
.sidebar nav a:hover, .nav-button:hover { color: #fff; background: #ffffff12; }
.logout-form { margin-top: auto; }
.main-content { margin-left: 246px; padding: 42px clamp(28px, 4vw, 70px) 72px; min-height: 100vh; }
.main-content--public { margin-left: 0; display: grid; place-items: center; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 5px 0 7px; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary); font-weight: 750; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.back-link { color: var(--muted); font-size: 13px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--surface); font-weight: 650; font-size: 13px; white-space: nowrap; }
.button:hover { border-color: #b8c1d1; }
.button--primary { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 7px 18px #315bea2b; }
.button--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button--quiet { background: transparent; }
.button--wide { width: 100%; margin-top: 8px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-grid--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 5px 24px #28344e09; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 13px; font-weight: 650; }
.metric-card strong { display: block; font-size: 30px; margin: 12px 0 8px; letter-spacing: -.04em; }
.metric-card small { font-size: 11px; }
.metric-card--accent { color: #fff; background: linear-gradient(135deg, #244fd9, #315bea 55%, #3875f2); border-color: transparent; }
.metric-card--accent span, .metric-card--accent small { color: #dce5ff; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 24px; margin: 0 0 20px; box-shadow: 0 5px 24px #28344e08; }
.panel--flush { padding: 0; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.panel-heading h2 { font-size: 17px; margin: 0 0 4px; }
.panel-heading p { color: var(--muted); font-size: 12px; margin: 0; }
.panel-heading > a { font-size: 13px; font-weight: 650; }

.mini-chart { height: 210px; display: flex; align-items: flex-end; gap: 4px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.mini-chart__column { height: 100%; flex: 1; min-width: 4px; display: flex; align-items: flex-end; justify-content: center; gap: 1px; position: relative; }
.mini-chart__column small { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 9px; white-space: nowrap; }
.bar { display: block; width: 52%; min-height: 0; border-radius: 3px 3px 0 0; }
.bar--impression { background: #6f8ff4; }
.bar--click { width: 25%; background: #163a69; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { color: var(--muted); font-size: 11px; font-weight: 700; text-align: left; letter-spacing: .03em; background: #fafbfc; }
th, td { padding: 14px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 4px; font-size: 11px; }
.campaign-table td:first-child { min-width: 210px; }
.campaign-table td:nth-child(3) { min-width: 210px; }
.campaign-table td:nth-child(4) { min-width: 160px; }

.status { display: inline-flex; padding: 4px 8px; border-radius: 99px; background: #eef1f6; color: #5b6578; font-size: 11px; font-weight: 700; }
.status--active { background: #e4f7ef; color: var(--success); }
.status--scheduled { background: #fff2db; color: var(--warning); }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-list span { padding: 4px 7px; border-radius: 5px; background: #f0f3fa; color: #4d5d7a; font-size: 10px; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.row-actions form { margin: 0; }
.text-link, .text-button { font-weight: 650; font-size: 12px; }
.text-button { border: 0; color: #59657a; background: transparent; padding: 0; }
.text-button--primary { color: var(--primary); }

.filter-bar { display: flex; align-items: flex-end; gap: 9px; padding: 14px; margin-bottom: 18px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.filter-bar > input { flex: 1; max-width: 420px; }
.filter-bar--analytics { flex-wrap: wrap; }
.filter-bar label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; font-weight: 700; }
input, select, textarea { width: 100%; color: var(--ink); background: #fff; border: 1px solid #d8deea; border-radius: 8px; padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #315bea16; }
textarea { resize: vertical; }

.editor-form { max-width: 1000px; }
.form-section { padding: 28px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.form-section__heading { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 24px; }
.form-section__heading > span { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; color: var(--primary); background: #edf1ff; font-weight: 800; font-size: 11px; }
.form-section__heading h2 { margin: 0 0 4px; font-size: 17px; }
.form-section__heading p { margin: 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid--spaced { margin-top: 22px; }
.field { display: grid; gap: 7px; align-content: start; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 700; }
.field small { color: var(--muted); font-size: 10px; }
.field-optional { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.placement-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.placement-option { display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.placement-option:has(input:checked) { border-color: #7993ed; background: #f3f6ff; }
.placement-option input { width: auto; margin-top: 2px; accent-color: var(--primary); }
.placement-option strong, .placement-option small { display: block; }
.placement-option strong { font-size: 12px; }
.placement-option small { color: var(--muted); margin-top: 3px; font-size: 10px; line-height: 1.45; }
.image-upload { display: grid; grid-template-columns: minmax(220px, 38%) 1fr; gap: 20px; padding: 16px; border: 1px dashed #cbd4e4; border-radius: 12px; background: #fafbfe; }
.image-upload__preview { position: relative; display: grid; place-items: center; min-height: 180px; overflow: hidden; border-radius: 9px; background: #edf1f7; }
.image-upload__preview img { width: 100%; max-height: 260px; display: block; object-fit: contain; }
.image-upload__preview-label { position: absolute; top: 9px; left: 9px; z-index: 1; padding: 4px 7px; border-radius: 5px; color: #fff; background: #172034b8; font-size: 9px; font-weight: 700; }
.image-upload__placeholder { color: var(--muted); font-size: 12px; text-align: center; padding: 24px; }
.image-upload__controls { align-self: center; }
.image-upload__controls > p { margin: 10px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }
#campaign-image-file { padding: 7px; color: var(--muted); background: #fff; }
#campaign-image-file::file-selector-button { margin-right: 10px; padding: 8px 13px; border: 1px solid #b9c6ef; border-radius: 7px; color: var(--primary); background: #f4f6ff; font-weight: 650; cursor: pointer; }
.image-requirements, .image-file-status { margin-top: 8px; padding: 9px 11px; border-radius: 8px; color: #385078; background: #eef3ff; font-size: 11px; line-height: 1.55; }
.image-requirements--warning, .image-file-status--error { color: #934317; background: #fff1e8; }
.image-file-status:empty { display: none; }
.image-file-status--success { color: var(--success); background: #e8f7f0; }
.crop-preview-panel { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.crop-preview-panel__heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.crop-preview-panel__heading strong, .crop-preview-panel__heading small { display: block; }
.crop-preview-panel__heading strong { font-size: 13px; }
.crop-preview-panel__heading small { margin-top: 4px; line-height: 1.55; }
.crop-preview-panel__heading > span { flex: none; padding: 5px 8px; border-radius: 99px; color: #42609b; background: #edf2ff; font-size: 9px; font-weight: 700; }
.crop-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: start; gap: 12px; }
.crop-preview { min-width: 0; margin: 0; padding: 10px; border: 1px solid #e4e9f2; border-radius: 10px; background: #f9fafc; }
.crop-preview__frame { position: relative; display: grid; place-items: center; width: 100%; overflow: hidden; border-radius: 8px; background: #e9edf5; box-shadow: inset 0 0 0 1px #1720340d; }
.crop-preview__frame img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.crop-preview__badge { position: absolute; top: 7px; left: 7px; padding: 3px 6px; border-radius: 4px; color: #fff; background: #111c3299; font-size: 8px; font-weight: 700; }
.crop-preview__placeholder { padding: 18px; color: #7d889c; font-size: 10px; text-align: center; }
.crop-preview figcaption { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 10px; }
.crop-preview figcaption strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crop-preview figcaption span { flex: none; color: var(--muted); }
.crop-preview-grid__empty { grid-column: 1 / -1; margin: 0; padding: 28px; border-radius: 8px; color: var(--muted); background: #f7f8fb; font-size: 11px; text-align: center; }
.is-hidden { display: none !important; }
.form-actions { position: sticky; bottom: 14px; display: flex; justify-content: flex-end; gap: 8px; padding: 13px; background: #ffffffee; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px #29354d20; backdrop-filter: blur(10px); }

.validation { color: #b3213f; font-size: 11px; }
.validation--summary:empty { display: none; }
.alert { padding: 12px 15px; margin-bottom: 18px; border-radius: 9px; font-size: 13px; }
.alert--success { color: #126444; background: #e4f7ef; border: 1px solid #bfe9d7; }
.empty-panel, .empty-inline { text-align: center; color: var(--muted); padding: 54px 24px; }
.empty-panel h1, .empty-panel h2 { color: var(--ink); }
.empty-inline { padding: 34px; background: #fafbfc; border-radius: 9px; font-size: 13px; }

.login-card { width: min(450px, calc(100vw - 34px)); padding: 34px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 80px #15213d18; }
.login-heading { display: flex; gap: 16px; align-items: center; margin-bottom: 30px; }
.login-heading h1 { margin: 0 0 5px; font-size: 22px; }
.login-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.stack-form { display: grid; gap: 9px; }
.stack-form label { font-weight: 700; font-size: 12px; margin-top: 5px; }

@media (max-width: 980px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 20px; flex-direction: row; align-items: center; }
  .brand { margin: 0 24px 0 0; }
  .sidebar nav { display: flex; }
  .logout-form { margin: 0 0 0 auto; }
  .main-content { margin-left: 0; padding: 30px 22px 60px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 650px) {
  .sidebar { flex-wrap: wrap; }
  .sidebar nav { order: 3; width: 100%; overflow-x: auto; margin-top: 8px; }
  .sidebar nav a { white-space: nowrap; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid, .metric-grid--three, .form-grid, .placement-grid { grid-template-columns: 1fr; }
  .image-upload { grid-template-columns: 1fr; }
  .crop-preview-panel__heading { flex-direction: column; }
  .field--full { grid-column: auto; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar > input { max-width: none; }
  .mini-chart { height: 150px; }
}
