:root {
    color-scheme: light;
    --grass: #4a7729;
    --grass-dark: #35571d;
    --grass-light: #dbe4d4;
    --soil: #edece7;
    --ink: #252821;
    --muted: #565652;
    --line: #dddddc;
    --canvas: #f6f7f3;
    --white: #fff;
    --poppy: #d22630;
    --danger: #a01b26;
    --error-bg: #fdf0f0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--white);
    font: 400 1rem/1.55 "Noto Sans", system-ui, sans-serif;
}

h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { color: var(--grass); line-height: 1.2; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -.025em; }
h2 { font-size: clamp(1.2rem, 2.8vw, 1.5rem); }
h3 { font-size: 1.2rem; }
p + p { margin-top: 12px; }
small, .muted { color: var(--muted); }
a { color: var(--grass-dark); text-underline-offset: .18em; }

button, input, select { font: inherit; }
button, .button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--grass); outline-offset: 3px; }

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 9px 19px;
    border: 1px solid transparent;
    border-radius: 99px;
    background: var(--grass);
    color: var(--white);
    text-decoration: none;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: .035em;
    font-size: .875rem;
    line-height: 1.25;
}

.button:hover { background: var(--grass-dark); }
.button--outline { color: var(--grass-dark); background: var(--white); border-color: var(--grass); }
.button--outline:hover { background: var(--grass-light); }
.button--danger { background: var(--danger); }
.button--danger:hover { background: #7e1520; }

.text-button { border: 0; background: none; color: inherit; min-height: 44px; padding: 4px; }
.text-button:hover { text-decoration: underline; }
.sign-out:focus-visible { outline-color: var(--white); }

.field { min-width: 0; display: grid; gap: 7px; align-content: start; }
.field label { font-size: .875rem; font-weight: 700; }
.field > :is(input, select) {
    width: 100%;
    height: 46px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink);
    padding: 0 12px;
    background: var(--white);
}

.field > input::placeholder { color: #666b61; opacity: 1; }
.field > input[readonly] { background: var(--canvas); color: var(--muted); }
.field > [aria-invalid="true"] { border-color: var(--poppy); }
.field-error { color: var(--danger); font-size: .875rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.action-footer { margin-top: 24px; }
.breadcrumb { display: inline-block; margin-bottom: 16px; }
.container { width: min(calc(100% - 64px), 1120px); margin-inline: auto; }

.notice {
    border-inline-start: 3px solid #a69f88;
    color: var(--ink);
    background: var(--soil);
    padding: 14px 18px;
    border-radius: 3px;
    overflow-wrap: anywhere;
}

.notice h2, .notice strong { display: block; margin-bottom: 5px; }
.notice--error { border-color: var(--poppy); background: var(--error-bg); color: var(--danger); }
.notice--error h2 { color: var(--danger); }
.notice--success { background: var(--grass-light); border-color: var(--grass); }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); min-width: 0; }
.panel > h2 { margin-bottom: 18px; }
.panel > h3 { margin-bottom: 16px; }

.login {
    display: grid;
    grid-template-columns: minmax(0, 58fr) minmax(0, 42fr);
    min-height: 100svh;
}

.login-photo { background: #111811 url("../assets/tradition.jpg") 53% 45% / cover no-repeat; }
.login-panel { display: grid; place-items: center; padding: 44px clamp(24px, 5vw, 64px); min-width: 0; }
.login-form { width: min(100%, 440px); }
.login-logo { display: block; width: auto; height: 50px; margin-bottom: 30px; }
.login h1 { margin-bottom: 28px; font-size: 3rem; letter-spacing: -.045em; }
.login .field + .field { margin-top: 18px; }
.login .field input { height: 48px; box-shadow: 0 2px 12px #25281f24; border-color: transparent; }
.login .field input[aria-invalid="true"] { border-color: var(--poppy); }
.login .notice { margin: 0 0 18px; font-size: .875rem; }
.login-button { min-height: 48px; width: 100%; margin-top: 24px; font-size: 1rem; }

.dealer-layout { background: var(--canvas); }
.dealer-header, .admin-header { color: var(--white); background: var(--grass); }
.dealer-header-inner, .admin-header { display: flex; align-items: center; min-height: 74px; gap: 20px; font-weight: 700; }
.dealer-header img { margin-inline-start: auto; }
.search-hero { display: grid; align-items: center; min-height: 116px; background: url("../assets/krone-pattern.jpg") right center / 47% auto no-repeat; }
.search-hero h1 { color: var(--white); font-size: clamp(1.75rem, 4vw, 3rem); }
.dealer-nav { background: var(--white); border-bottom: 1px solid var(--line); }
.dealer-nav .container { display: flex; align-items: end; gap: 28px; }
.dealer-nav a { display: flex; align-items: center; min-height: 53px; border-bottom: 3px solid transparent; color: var(--muted); text-decoration: none; }
.dealer-nav a:hover, .dealer-nav a[aria-current] { border-color: var(--grass); color: var(--grass-dark); }
.dealer-nav a[aria-current] { font-weight: 700; }
.dealer-content { padding: 34px 0 56px; }
.dealer-content > h1 { margin-bottom: 26px; }
.dealer-content > .notice, .access-panel { margin-top: 16px; }
.access-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-block: 14px; }
.documentation { margin-top: 26px; }
.documentation p { margin: 12px 0 16px; }

.search-form { display: flex; align-items: end; gap: 12px; }
.search-form .field { flex: 1 1 0; }
.search-form .button { min-width: 116px; min-height: 46px; }
.search-result { margin-top: 30px; }
.search-result > h2 { margin-bottom: 16px; }
.search-result.notice > h2 { margin-bottom: 8px; }

.table-wrap { overflow: auto; background: var(--white); border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: var(--soil); color: var(--muted); font-size: .875rem; }
th, td { padding: 13px 16px; vertical-align: middle; }
td { border-top: 1px solid var(--line); }
tbody tr:nth-child(even) { background: var(--canvas); }
.table-key, .dealer-name { font-weight: 700; color: var(--grass-dark); }
.phone { white-space: nowrap; }

.dialog {
    width: min(560px, calc(100% - 32px));
    max-height: calc(100svh - 32px);
    border: 0;
    border-radius: 8px;
    padding: 26px 32px 32px;
    color: var(--ink);
    box-shadow: 0 14px 40px #20241d38;
}

.dialog::backdrop { background: #1d251980; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-company { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.icon-button { min-width: 44px; min-height: 44px; border: 0; border-radius: 50%; background: var(--white); color: var(--muted); font-size: 1.5rem; }
.icon-button:hover { background: var(--canvas); }
.dialog-action { margin-top: 24px; }
.dialog > .muted { margin-top: 12px; }

.details-grid, .field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; }
.details-grid > div { min-width: 0; }
.details-grid dd { overflow-wrap: anywhere; }
.span-all { grid-column: 1 / -1; }
.single-column { grid-template-columns: 1fr; }
dt { color: var(--muted); font-weight: 700; font-size: .875rem; margin-bottom: 4px; }
.badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 40px; background: var(--soil); color: var(--muted); font-weight: 700; font-size: .8125rem; }
.badge--active { color: var(--grass-dark); background: var(--grass-light); }
.badge--error { color: var(--danger); background: var(--error-bg); }
.guide-download { margin-top: 14px; }
.guide-steps { list-style: none; margin: 24px 0 0; padding: 0; display: grid; gap: 12px; counter-reset: steps; }
.guide-steps li { counter-increment: steps; }
.guide-steps h2::before { content: counter(steps) ". "; }
.guide-steps .panel h2 { margin-bottom: 8px; }

.admin-layout { background: var(--canvas); }
.admin-header { min-height: 76px; padding: 0 32px; }
.admin-header form { margin-inline-start: auto; }
.admin-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100svh - 76px); }
.admin-nav { display: grid; align-content: start; gap: 8px; padding: 28px 16px; background: var(--white); border-inline-end: 1px solid var(--line); }
.admin-nav a { padding: 13px 16px; border-radius: 5px; color: var(--muted); text-decoration: none; }
.admin-nav a:hover, .admin-nav a[aria-current] { color: var(--grass-dark); background: var(--grass-light); }
.admin-nav a[aria-current] { font-weight: 700; }
.admin-content { padding: 44px 48px 56px; min-width: 0; }
.admin-content > .notice { margin-bottom: 18px; }
.page-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; }
.admin-search { max-width: 900px; margin-bottom: 24px; }
.admin-table table { min-width: 560px; }
.form-columns { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(255px, 1fr); align-items: start; gap: 24px; }
.field-grid h2 { margin-bottom: 2px; }
.product-form { max-width: 950px; }
.map-link { margin-top: 18px; }
.setting { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.switch { appearance: none; position: relative; width: 50px; height: 28px; flex: 0 0 auto; margin: 0; background: #777772; border-radius: 99px; cursor: pointer; }
.switch::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: var(--white); }
.switch:checked { background: var(--grass); }
.switch:checked::after { left: 25px; }

.file-zone { margin: 18px 0 20px; padding: 15px; background: var(--canvas); border: 1px dashed #9a9a97; border-radius: 4px; }
.file-zone label { display: block; font-weight: 700; margin-bottom: 7px; }
.file-zone input { width: 100%; color: var(--muted); font-size: .875rem; }
.file-zone input::file-selector-button { padding: 8px 12px; border: 1px solid var(--grass); border-radius: 99px; color: var(--grass-dark); background: var(--white); cursor: pointer; margin-right: 8px; }
.file-name { margin-top: 8px; overflow-wrap: anywhere; }
.checkbox { display: flex; align-items: start; gap: 9px; font-weight: 700; }
.checkbox input { flex: 0 0 auto; accent-color: var(--grass); width: 20px; height: 20px; margin: 2px 0 0; }
.import-hint { margin: 6px 0 18px 29px; font-size: .875rem; }
.import-result { max-width: 1000px; }

@media (max-width: 1140px) {
    .admin-shell { grid-template-columns: 210px minmax(0, 1fr); }
    .admin-content { padding-inline: 28px; }
}

@media (max-width: 920px) {
    .form-columns { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .login { grid-template-columns: 1fr; grid-template-rows: clamp(250px, 51.12vw, 414px) minmax(min-content, 1fr); }
    .login-form { width: min(100%, 400px); }
    .login-logo { height: 39px; margin-bottom: 24px; }
    .login h1 { font-size: 2.25rem; }
    .admin-shell { display: block; }
    .admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; border-inline-end: 0; border-bottom: 1px solid var(--line); padding: 7px 16px; }
    .admin-nav a { padding: 9px 12px; }
}

@media (max-width: 560px) {
    .container { width: calc(100% - 40px); }
    .login { grid-template-rows: 250px minmax(min-content, 1fr); }
    .login-panel { align-items: start; padding: 36px 24px 32px; }
    .login-logo { height: 31px; margin-bottom: 20px; }
    .login h1 { font-size: 1.75rem; margin-bottom: 22px; }
    .login-button { margin-top: 20px; }
    .dealer-header-inner { gap: 9px; min-height: 66px; font-size: .875rem; }
    .dealer-header img { width: 72px; height: auto; }
    .search-hero { min-height: 76px; background-size: auto 100%; }
    .dealer-nav .container { gap: 18px; font-size: .875rem; }
    .dealer-content { padding-top: 24px; }
    .search-form { flex-wrap: wrap; }
    .search-form .field { flex-basis: 100%; }
    .search-form .button { flex: 1; }
    .dealer-table { border: 0; border-radius: 0; background: none; overflow: visible; }
    .dealer-table table, .dealer-table tbody { display: block; }
    .dealer-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .dealer-table tr { display: grid; padding: 14px; margin-bottom: 10px; background: var(--white); border-radius: 5px; border: 1px solid var(--line); }
    .dealer-table td { padding: 3px 0; border: 0; display: block; }
    .dealer-table td[data-label="Артикул"]::before { content: "Артикул "; color: var(--muted); }
    .dealer-table .dealer-name { order: -1; font-size: 1.1rem; }
    .dealer-table .table-action { justify-self: end; }
    .dialog { padding: 18px 22px 24px; }
    .dialog-action { width: 100%; }
    .details-grid, .field-grid { grid-template-columns: 1fr; }
    .panel { padding: 18px; }
    .admin-header { gap: 10px; padding-inline: 16px; font-size: .875rem; }
    .admin-header img { width: 75px; height: auto; }
    .admin-content { padding: 24px 16px 42px; }
    .page-heading { margin-bottom: 20px; }
}
