:root {
    --navy: #223047;
    --navy-2: #1d2a3f;
    --page: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #d5d9e0;
    --border-light: #e6e9ee;
    --text: #182233;
    --muted: #667386;
    --accent: #2f78c8;
    --accent-dark: #2467ad;
    --success-bg: #e7f6ec;
    --success-text: #0f6b3e;
    --warning-bg: #fff4d8;
    --warning-text: #8a5a00;
    --danger-bg: #fce8e6;
    --danger-text: #a92216;
    --neutral-bg: #eef1f5;
    --neutral-text: #465160;
    --sidebar-open-width: 60px;
    --sidebar-closed-width: 60px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: "Instrument Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }

.app-shell {
    min-height: 100vh;
    padding-left: var(--sidebar-open-width);
    padding-top: 56px;
}

.topbar {
    align-items: center;
    background: var(--navy);
    border-bottom: 1px solid #101827;
    color: #ffffff;
    display: flex;
    height: 56px;
    justify-content: space-between;
    left: 0;
    padding: 0 24px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 20;
}

.brand { align-items: center; display: flex; gap: 24px; min-width: 0; }
.brand-mark {
    color: #ffffff;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0;
    white-space: nowrap;
}
.brand-mark:hover { color: #ffffff; text-decoration: none; }
.topbar-section { color: #eef2f7; font-size: 16px; font-weight: 700; }
.topbar-actions { align-items: center; display: flex; gap: 12px; }
.account-chip { color: #cbd5e1; font-size: 12px; line-height: 1.25; }
.icon-button, .account-button {
    align-items: center;
    background: transparent;
    border: 1px solid rgba(255,255,255,.38);
    border-radius: 999px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    height: 32px;
    justify-content: center;
    min-width: 32px;
    padding: 0 10px;
}
.icon-button:hover, .account-button:hover { background: rgba(255,255,255,.1); color: #ffffff; text-decoration: none; }
.account-button { border-radius: 4px; height: 34px; }

.sidebar {
    background: #ffffff;
    border-right: 1px solid var(--border);
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    left: 0;
    overflow-x: hidden;
    padding: 10px 4px;
    position: fixed;
    top: 56px;
    width: var(--sidebar-open-width);
    z-index: 18;
}

.nav-icon {
    align-items: center;
    border-left: 3px solid transparent;
    border-radius: 4px;
    color: #526174;
    display: flex;
    flex-direction: column;
    font-size: 13px;
    font-weight: 800;
    gap: 3px;
    justify-content: center;
    min-height: 58px;
    min-width: 0;
    padding: 7px 3px;
    text-align: center;
    text-decoration: none;
    width: 100%;
}

.nav-icon:hover, .nav-icon.is-active {
    background: #eef5fc;
    border-left-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.nav-glyph {
    align-items: center;
    display: inline-flex;
    flex: 0 0 24px;
    justify-content: center;
}

.nav-glyph svg {
    display: block;
    fill: none;
    height: 21px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.9;
    width: 21px;
}

.nav-label {
    display: block;
    font-size: 8px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-break: keep-all;
}

.main-content {
    min-width: 0;
    padding: 22px 28px 44px;
}

.page-header {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 12px;
}
.page-heading { min-width: 0; }
.page-kicker {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}
h1 {
    font-size: 28px;
    line-height: 1.2;
    margin: 0;
}
h2 {
    font-size: 16px;
    margin: 0 0 12px;
}

.summary {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 12px;
}
.summary-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    min-height: 66px;
    padding: 10px 12px;
}
.summary-label {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 700;
}
.summary-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    margin-top: 3px;
}

.filter-panel, .content-panel, .form-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.filter-panel {
    border-top: 2px solid var(--accent);
    margin-bottom: 12px;
}
.filter-title {
    align-items: center;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    min-height: 44px;
    padding: 8px 12px;
}
.filter-title strong { font-size: 16px; }
.filter-chip {
    align-items: center;
    border: 1px solid #8f98a6;
    border-radius: 4px;
    color: #1f2937;
    display: inline-flex;
    font-weight: 700;
    gap: 6px;
    min-height: 28px;
    padding: 3px 10px;
}
.filter-clear { font-weight: 700; }
.filters, form.filters {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(150px, 190px)) auto;
    padding: 12px;
}

.operation-bar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 12px;
}
.operation-group {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-action-form {
    margin: 0;
}

button:disabled,
.button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

label {
    color: #344054;
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
}
input, select, textarea {
    background: #ffffff;
    border: 1px solid #aeb6c2;
    border-radius: 4px;
    color: var(--text);
    font: inherit;
    min-height: 36px;
    padding: 7px 10px;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(31, 115, 209, .16);
    outline: 0;
}
textarea { min-height: 84px; }
textarea:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }
.is-disabled label { color: #94a3b8; }

button, .button, .button-secondary {
    align-items: center;
    border: 1px solid var(--accent);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 36px;
    padding: 7px 12px;
    text-decoration: none;
    white-space: nowrap;
}
button, .button {
    background: var(--accent);
    color: #ffffff;
}
button:hover, .button:hover { background: var(--accent-dark); color: #ffffff; text-decoration: none; }
.button-secondary {
    background: #ffffff;
    border-color: #aeb6c2;
    color: var(--text);
}
.button-secondary:hover { background: #f8fafc; color: var(--text); text-decoration: none; }
.button-danger {
    background: #b42318;
    border-color: #b42318;
    color: #ffffff;
}
button:disabled { cursor: not-allowed; opacity: .45; }

.table-wrap {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow-x: auto;
}
table {
    border-collapse: collapse;
    min-width: 1100px;
    width: 100%;
}
th, td {
    border-bottom: 1px solid var(--border-light);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}
th {
    background: #f7f8fa;
    border-right: 1px solid var(--border-light);
    color: #404b5a;
    font-size: 12px;
    font-weight: 800;
    position: sticky;
    top: 56px;
    z-index: 1;
}
tbody tr:hover { background: #fbfdff; }
td.name, td.keyword, td.campaign, td.ad-group, td.expression, td.conditions, td.scope {
    max-width: 340px;
    white-space: normal;
}
.name-link, td.name strong {
    color: #0056c7;
    font-weight: 700;
}
.muted { color: var(--muted); }
.empty {
    color: var(--muted);
    padding: 24px;
    text-align: center;
}
code {
    color: #344054;
    font-size: 12px;
    white-space: normal;
    word-break: break-word;
}

.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.3;
    padding: 3px 9px;
}
.badge-enabled, .badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-paused { background: var(--warning-bg); color: var(--warning-text); }
.badge-archived, .badge-disabled, .badge-inactive { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-live, .badge-stale { background: var(--danger-bg); color: var(--danger-text); }
.badge-notify, .badge-ok { background: #e7f1ff; color: #145ca7; }

.status, .errors {
    border-radius: 4px;
    margin-bottom: 12px;
    padding: 10px 12px;
}
.status { background: var(--success-bg); border: 1px solid #acd9bd; color: var(--success-text); }
.errors, .error { background: var(--danger-bg); border: 1px solid #f1b8b2; color: var(--danger-text); }

.actions { align-items: center; display: flex; gap: 8px; }
.actions form { margin: 0; }
.status-cell { align-items: flex-start; display: flex; flex-direction: column; gap: 7px; }
.toggle-form { margin: 0; }
.toggle-button {
    background: transparent;
    border: 0;
    min-height: auto;
    padding: 0;
}
.toggle-button:hover { background: transparent; }
.toggle-track {
    align-items: center;
    background: #cad0d8;
    border-radius: 999px;
    display: inline-flex;
    height: 22px;
    justify-content: flex-start;
    padding: 2px;
    width: 42px;
}
.toggle-thumb {
    background: #ffffff;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(17, 24, 39, .25);
    display: block;
    height: 18px;
    transform: translateX(0);
    transition: transform .15s ease;
    width: 18px;
}
.toggle-button.is-active .toggle-track { background: #1f6899; }
.toggle-button.is-active .toggle-thumb { transform: translateX(20px); }
.toggle-button:focus-visible { outline: 2px solid rgba(31, 115, 209, .32); outline-offset: 3px; }

.pagination { margin-top: 12px; }
.pagination nav > div:first-child { display: none; }
.pagination svg {
    display: inline-block;
    height: 18px;
    width: 18px;
}
.pagination a,
.pagination span {
    align-items: center;
    display: inline-flex;
    min-height: 34px;
}

.fab-create {
    align-items: center;
    background: var(--accent);
    border: 1px solid var(--accent-dark);
    border-radius: 999px;
    bottom: 28px;
    box-shadow: 0 8px 18px rgba(24, 103, 173, .22);
    color: #ffffff;
    display: inline-flex;
    font-size: 30px;
    font-weight: 600;
    height: 48px;
    justify-content: center;
    line-height: 1;
    position: fixed;
    right: 28px;
    text-decoration: none;
    width: 48px;
    z-index: 30;
}

.fab-create:hover {
    background: var(--accent-dark);
    color: #ffffff;
    text-decoration: none;
}

.fab-create::before {
    background: #1f2937;
    border-radius: 4px;
    color: #ffffff;
    content: attr(data-tooltip);
    font-size: 12px;
    font-weight: 700;
    opacity: 0;
    padding: 6px 9px;
    pointer-events: none;
    position: absolute;
    right: 56px;
    transform: translateX(4px);
    transition: opacity .12s ease, transform .12s ease;
    white-space: nowrap;
}

.fab-create:hover::before,
.fab-create:focus-visible::before {
    opacity: 1;
    transform: translateX(0);
}

.grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: inherit;
    display: block;
    min-height: 96px;
    padding: 14px;
}
.card:hover { border-color: #9bb8d8; text-decoration: none; }
.card strong { display: block; font-size: 15px; margin-bottom: 6px; }
.card span { color: var(--muted); display: block; line-height: 1.5; }

.form-panel, form.form-panel {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 14px;
}
.form-panel .full, .full { grid-column: 1 / -1; }
.form-actions {
    display: flex;
    gap: 8px;
}
.condition-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}
.condition-row {
    display: grid;
    gap: 8px;
    grid-template-columns: 150px minmax(180px, 1fr) 180px 90px 140px 170px 96px;
    margin-top: 8px;
}
.checkbox-label { align-items: center; display: flex; gap: 8px; min-height: 36px; }
.checkbox-label input, input[type="checkbox"] { min-height: auto; width: auto; }
.toolbar { align-items: center; display: flex; gap: 12px; justify-content: space-between; margin-bottom: 12px; }
.pill-list { align-items: flex-start; display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.pill, .command-chip {
    background: #f1f5f9;
    border: 1px solid #d8dee8;
    border-radius: 999px;
    color: #475467;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    max-width: 100%;
    overflow: hidden;
    padding: 2px 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.login-shell {
    align-items: center;
    background: var(--page);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}
.login-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    max-width: 420px;
    padding: 28px;
    width: 100%;
}
.login-card p { color: var(--muted); line-height: 1.6; margin: 8px 0 20px; }
.google-icon { display: block; height: 22px; width: 22px; }



@media (max-width: 1100px) {
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters, form.filters { grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 1fr)); }
}

@media (max-width: 760px) {
    .app-shell { padding-left: 0; }
    .topbar { padding: 0 12px; }
    .brand { gap: 10px; }
    .brand-mark { font-size: 18px; }
    .topbar-section, .account-chip, .icon-button { display: none; }
    .sidebar {
        border-right: 0;
        border-top: 1px solid var(--border);
        bottom: 0;
        flex-direction: row;
        height: 68px;
        overflow-x: auto;
        padding: 8px;
        top: auto;
        width: 100%;
    }
    .nav-icon { flex: 0 0 auto; min-width: 86px; }
    .main-content { padding: 16px 12px 88px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    h1 { font-size: 22px; }
    .summary, .grid, .filters, form.filters, .form-panel, form.form-panel, .condition-row {
        grid-template-columns: 1fr;
    }
    .filter-title { align-items: flex-start; flex-direction: column; }
    .operation-bar, .toolbar { align-items: flex-start; flex-direction: column; }
    .table-wrap { overflow-x: auto; }
    th { top: 56px; }
}

body.admin-shell {
    padding-left: var(--sidebar-open-width);
    padding-top: 56px;
}

body.admin-shell > header {
    align-items: center;
    background: transparent;
    border-bottom: 0;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 20px 28px 8px;
}

body.admin-shell > header h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
}

body.admin-shell > main {
    padding: 12px 28px 44px;
}

body.admin-shell .legacy-logout { display: none; }

body.admin-shell .topbar form,
body.admin-shell .actions form,
body.admin-shell .toggle-form {
    background: transparent;
    border: 0;
    border-radius: 0;
    display: block;
    margin: 0;
    min-height: 0;
    padding: 0;
    width: auto;
}

body.admin-shell .topbar button,
body.admin-shell .actions button,
body.admin-shell .toggle-button,
body.admin-shell .button,
body.admin-shell .button-secondary {
    width: auto;
}

body.admin-shell main > form:not(.form-panel):not(.grid) {
    background: #ffffff;
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: 4px;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(240px, 1fr) repeat(3, minmax(150px, 190px)) auto;
    margin-bottom: 12px;
    padding: 12px;
}

body.admin-shell .summary {
    gap: 8px;
    margin-bottom: 12px;
}

body.admin-shell .summary-item {
    border-radius: 4px;
    min-height: 62px;
    padding: 10px 12px;
}

body.admin-shell .summary-value {
    font-size: 22px;
    line-height: 1.2;
}

body.admin-shell .table-wrap {
    border-radius: 4px;
    box-shadow: none;
}

body.admin-shell table {
    font-size: 13px;
}

body.admin-shell th,
body.admin-shell td {
    padding: 8px 10px;
}

body.admin-shell th {
    background: #f7f8fa;
    color: #404b5a;
    font-size: 12px;
    position: static;
    top: auto;
    z-index: auto;
}

body.metric-comparison-page .table-wrap {
    overflow: auto;
}

body.metric-comparison-page table {
    min-width: 3000px;
    table-layout: fixed;
}

body.metric-comparison-page th,
body.metric-comparison-page td {
    height: 42px;
    line-height: 1.35;
    padding: 8px 12px;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

body.metric-comparison-page th {
    position: static;
    top: auto;
}

body.metric-comparison-page th:nth-child(1),
body.metric-comparison-page td:nth-child(1) { width: 170px; text-align: left; }

body.metric-comparison-page th:nth-child(2),
body.metric-comparison-page td:nth-child(2) { width: 180px; text-align: left; }

body.metric-comparison-page th:nth-child(3),
body.metric-comparison-page td:nth-child(3) {
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    width: 260px;
}

body.metric-comparison-page th:nth-child(n+4),
body.metric-comparison-page td:nth-child(n+4) {
    width: 132px;
}

body.metric-comparison-page th:nth-child(5),
body.metric-comparison-page th:nth-child(18),
body.metric-comparison-page th:nth-child(19),
body.metric-comparison-page td:nth-child(5),
body.metric-comparison-page td:nth-child(18),
body.metric-comparison-page td:nth-child(19) {
    width: 190px;
}

body.metric-comparison-page th:nth-child(n+20),
body.metric-comparison-page td:nth-child(n+20) {
    width: 160px;
}

body.metric-comparison-page td.name {
    max-width: none;
    white-space: normal;
}

body.admin-shell tbody tr:hover {
    background: #fbfdff;
}

body.admin-shell td.name,
body.admin-shell td.keyword,
body.admin-shell td.campaign,
body.admin-shell td.ad-group,
body.admin-shell td.expression,
body.admin-shell td.conditions,
body.admin-shell td.scope {
    max-width: 340px;
    white-space: normal;
}

body.admin-shell .toolbar,
body.admin-shell .operation-bar {
    margin-bottom: 12px;
}

body.admin-shell .card {
    border-radius: 4px;
    min-height: 96px;
    padding: 14px;
}

body.admin-shell .grid {
    gap: 10px;
}

body.admin-shell form.form-panel {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 4px;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 14px;
}

body.admin-shell form.form-panel .full {
    grid-column: 1 / -1;
}

body.admin-shell .condition-row {
    grid-template-columns: 150px minmax(180px, 1fr) 180px 90px 140px 170px 96px;
}

body.admin-shell .form-actions {
    display: flex;
    gap: 8px;
    grid-template-columns: none;
}

body.admin-shell .form-actions > * {
    width: auto;
}



body.admin-shell.optimization-rule-page form.optimization-rule-form {
    align-items: start;
    border-top: 2px solid var(--accent);
    gap: 12px 10px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    padding: 14px 14px 16px;
}

.optimization-rule-form .field,
.optimization-rule-form .action-settings,
.optimization-rule-form .conditions {
    min-width: 0;
}

.optimization-rule-form .field-name { grid-column: span 5; }
.optimization-rule-form .field-profile { grid-column: span 4; }
.optimization-rule-form .field-ad-product { grid-column: span 3; }
.optimization-rule-form .field-target-type,
.optimization-rule-form .field-lookback,
.optimization-rule-form .field-scope { grid-column: span 3; }
.optimization-rule-form .field-schedule { grid-column: span 4; }
.optimization-rule-form .field-action { grid-column: span 3; }
.optimization-rule-form .field-mode { grid-column: span 3; }
.optimization-rule-form .field-priority { grid-column: span 2; }
.optimization-rule-form .multi-choice-field { grid-column: span 6; }


.optimization-rule-form .field-schedule-time { grid-column: span 3; }
.optimization-rule-form .schedule-subsettings {
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 10px;
}
.optimization-rule-form .compact-choice-grid {
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}
.optimization-rule-form .monthly-subsettings {
    margin-top: 10px;
}
.optimization-rule-form .monthly-nth-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(160px, 220px));
}

.optimization-rule-form .multi-choice-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.optimization-rule-form .choice-chip {
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    gap: 8px;
    line-height: 1.35;
    margin: 0;
    min-height: 38px;
    padding: 7px 10px;
}

.optimization-rule-form .choice-chip:has(input:checked) {
    background: #e7f1ff;
    border-color: var(--accent);
    color: #145ca7;
}

.optimization-rule-form .choice-chip input {
    flex: 0 0 auto;
    min-height: auto;
    width: auto;
}

.optimization-rule-form .form-section-title {
    border-top: 1px solid var(--border-light);
    color: #1f2937;
    font-size: 13px;
    font-weight: 800;
    margin-top: 4px;
    padding-top: 12px;
}

.optimization-rule-form .form-section-title:first-of-type {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.optimization-rule-form textarea {
    min-height: 72px;
}

.optimization-rule-form .condition-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 8px;
}

.optimization-rule-form .condition-heading .muted {
    line-height: 1.5;
    min-width: 0;
}


.optimization-rule-form .optional-badge {
    background: #f1f5f9;
    border: 1px solid #d8dee8;
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    margin-left: 4px;
    padding: 1px 6px;
    vertical-align: middle;
}

.optimization-rule-form .field-help {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    margin-top: 5px;
}

.optimization-rule-form .action-setting-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

body.admin-shell .optimization-rule-form .optimization-condition-row {
    align-items: end;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(150px, 180px) minmax(220px, 1fr) minmax(92px, 120px) minmax(140px, 180px) auto;
    margin-top: 8px;
}

.optimization-rule-form .optimization-condition-row select,
.optimization-rule-form .optimization-condition-row input {
    min-width: 0;
}

.optimization-rule-form .add-condition,
.optimization-rule-form .remove-condition {
    min-width: 84px;
}

.optimization-rule-form .form-actions {
    border-top: 1px solid var(--border-light);
    margin-top: 2px;
    padding-top: 12px;
}

@media (max-width: 1180px) {
    .optimization-rule-form .field-name,
    .optimization-rule-form .field-profile,
    .optimization-rule-form .field-ad-product,
    .optimization-rule-form .field-target-type,
    .optimization-rule-form .multi-choice-field,
    .optimization-rule-form .field-lookback,
    .optimization-rule-form .field-schedule,
    .optimization-rule-form .field-schedule-time,
    .optimization-rule-form .field-action,
    .optimization-rule-form .field-mode,
    .optimization-rule-form .field-scope {
        grid-column: span 6;
    }

    .optimization-rule-form .field-priority {
        grid-column: span 3;
    }
}

@media (max-width: 760px) {
    body.admin-shell.optimization-rule-page form.optimization-rule-form,
    body.admin-shell .optimization-rule-form .optimization-condition-row,
    .optimization-rule-form .action-setting-grid {
        grid-template-columns: 1fr;
    }

    .optimization-rule-form .field-name,
    .optimization-rule-form .field-profile,
    .optimization-rule-form .field-ad-product,
    .optimization-rule-form .field-target-type,
    .optimization-rule-form .multi-choice-field,
    .optimization-rule-form .field-lookback,
    .optimization-rule-form .field-schedule,
    .optimization-rule-form .field-schedule-time,
    .optimization-rule-form .field-action,
    .optimization-rule-form .field-mode,
    .optimization-rule-form .field-priority,
    .optimization-rule-form .field-scope {
        grid-column: 1 / -1;
    }

    .optimization-rule-form .condition-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .optimization-rule-form .monthly-nth-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1100px) {
    body.admin-shell main > form:not(.form-panel):not(.grid) {
        grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 1fr));
    }
}

@media (max-width: 760px) {
    body.admin-shell {
        padding-left: 0;
        padding-bottom: 68px;
    }

    body.admin-shell > header {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 12px 8px;
    }

    body.admin-shell > main {
        padding: 8px 12px 24px;
    }

    body.admin-shell > header h1 {
        font-size: 22px;
    }

    body.admin-shell main > form:not(.form-panel):not(.grid),
    body.admin-shell form.form-panel,
    body.admin-shell .condition-row,
    body.admin-shell .form-actions {
        grid-template-columns: 1fr;
    }

    body.admin-shell .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .fab-create {
        bottom: 68px;
        right: 16px;
    }

    .fab-create::before {
        display: none;
    }
}
