:root {
    --bg: #f7f7f8;
    --ink: #1c1c1f;
    --muted: #4d4d54;
    --line: #ececec;
    --accent: #fd5757;
    --accent-hover: #e64e4e;
    --err: #a11810;
    --err-bg: #fff1f0;
    --font: "Noto Sans Display", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
}

.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    width: min(400px, 100%);
    padding: 40px 32px 32px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
    text-align: center;
}

.card--install {
    width: min(520px, 100%);
}

.card__logo {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 16px;
}

h1 {
    margin: 16px 0 0;
    font-size: 32px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.card__lead,
.card__session {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.card__note {
    margin: 20px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: #eefbf2;
    color: #048f27;
    font-size: 14px;
    text-align: left;
}

.card .hint {
    margin: 16px 0 0;
    text-align: left;
}

.card input[name="code"] {
    letter-spacing: 0.28em;
    font-variant-numeric: tabular-nums;
}

.card__link {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: underline;
    cursor: pointer;
}

.card__link:hover,
.card__link:focus-visible {
    color: var(--accent-hover);
}

.card__error {
    margin: 20px 0 0;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--err-bg);
    color: var(--err);
    font-size: 14px;
    text-align: left;
}

form {
    margin-top: 24px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="tel"],
input[type="date"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    background: #fff;
}

input:focus {
    outline: 2px solid rgba(253, 87, 87, 0.35);
    border-color: var(--accent);
}

input[readonly],
textarea[readonly],
select:disabled,
input:disabled:not([type="checkbox"]):not([type="hidden"]),
textarea:disabled {
    background: #ececee;
    color: #6b6b6b;
    border-color: #d9d9de;
    cursor: default;
}

input[readonly]:focus,
textarea[readonly]:focus,
select:disabled:focus,
input:disabled:focus,
textarea:disabled:focus {
    outline: none;
    border-color: #d9d9de;
}

input[type="checkbox"]:disabled {
    accent-color: #9a9a9a;
    cursor: not-allowed;
}

.button {
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.button:hover,
.button:focus-visible {
    background: var(--accent-hover);
}

.button--ghost {
    width: auto;
    margin-top: 0;
    padding: 8px 14px;
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.button--ghost:hover,
.button--ghost:focus-visible {
    background: var(--bg);
}

.bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 64px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.bar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.bar__brand img {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 8px;
}

.bar__name {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    line-height: 1.15;
}

.bar__tag {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.bar__account {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    margin-left: auto;
}

.bar__settings {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
}

.bar__settings:hover,
.bar__settings:focus-visible {
    background: var(--bg);
}

.bar__user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    min-width: 0;
    margin: 0;
    line-height: 1.15;
    text-align: right;
}

.bar__user .bar__title,
.bar__name .bar__tag {
    overflow-wrap: anywhere;
}

.bar__user .bar__title {
    color: var(--ink);
    font-weight: 600;
}

.bar__logout {
    margin: 0;
}

.bar__menu,
.bar__menu-label {
    display: none;
}

.bar__toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.bar__menu-caption {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.bar__tools {
    display: contents;
}

.cabinet {
    width: calc(100% - 48px);
    margin: 0 auto;
    padding: 32px 0 48px;
}

.settings {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin-top: 20px;
    position: relative;
}

.side-menu {
    display: none;
}

.side-toggle {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.side-menu__caption {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.settings .sheet,
.settings .sheet--letter {
    width: 100%;
    max-width: none;
    margin-top: 0;
}

.settings .grid {
    margin-top: 0;
}

.settings__pane .sheet__delete {
    max-width: none;
}

.tree {
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree ul ul {
    margin: 4px 0 4px 14px;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.tree a {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}

.tree a:hover,
.tree a:focus-visible {
    background: var(--bg);
}

.tree a.is-current {
    background: var(--err-bg);
    color: var(--accent);
}

@media (max-width: 800px) {
    .settings {
        grid-template-columns: 1fr;
    }

    .side-menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        justify-self: start;
        width: 36px;
        height: 36px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        color: var(--ink);
        cursor: pointer;
    }

    .settings .tree {
        display: none;
    }

    .side-toggle:checked ~ .tree {
        display: block;
        position: absolute;
        z-index: 25;
        top: 48px;
        left: 0;
        width: min(280px, 100%);
        box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
    }

    .letter-send {
        flex-direction: column;
        align-items: stretch;
    }

    .license-fields {
        grid-template-columns: 1fr;
    }

    .cabinet {
        width: calc(100% - 32px);
        padding: 20px 0 32px;
    }

    .cabinet h1,
    .crumb a,
    .crumb__sep {
        font-size: 22px;
    }

    .cabinet__head {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .pair {
        grid-template-columns: 1fr;
    }

    .sheet {
        padding: 18px 16px;
    }

    .sheet__actions {
        flex-wrap: wrap;
    }

    .grid,
    .tariffs {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tariffs input {
        width: min(160px, 100%);
    }
}

@media (max-width: 720px) {
    .bar {
        flex-wrap: nowrap;
        padding: 10px 16px;
    }

    .bar__brand {
        flex: 1 1 auto;
    }

    .bar__name {
        overflow: hidden;
    }

    .bar__name .bar__title,
    .bar__name .bar__tag {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bar__menu {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 36px;
        height: 36px;
        margin-left: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
        color: var(--ink);
        cursor: pointer;
    }

    .bar__tools {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        right: 12px;
        width: min(280px, calc(100% - 24px));
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08);
    }

    .bar__tools.is-open,
    .bar__toggle:checked ~ .bar__tools {
        display: flex;
    }

    .bar__account {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
    }

    .bar__user {
        align-items: flex-start;
        text-align: left;
    }

    .bar__settings {
        width: auto;
        justify-content: flex-start;
        gap: 10px;
        padding: 0 10px;
    }

    .bar__menu-label {
        display: inline;
        font-size: 15px;
        font-weight: 600;
    }

    .bar__logout .button {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .card {
        padding: 28px 18px 22px;
    }

    h1 {
        font-size: 28px;
    }

    .sheet__actions .button,
    .sheet__actions .button--inline {
        width: 100%;
    }
}

.cabinet h1 {
    margin: 0;
    font-size: 28px;
}

.cabinet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.button--inline {
    width: auto;
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
}

.crumb {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.crumb a {
    color: var(--accent);
    font-size: 28px;
    font-weight: 700;
    text-decoration: none;
}

.crumb a:hover,
.crumb a:focus-visible {
    text-decoration: underline;
}

.crumb__sep {
    color: var(--muted);
    font-size: 28px;
    font-weight: 600;
}

.button--quiet {
    width: auto;
    margin: 0;
    padding: 6px 10px;
    background: transparent;
    color: var(--err);
    font-size: 14px;
}

.button--quiet:hover,
.button--quiet:focus-visible {
    background: var(--err-bg);
}

.button:disabled,
.button:disabled:hover,
.button:disabled:focus-visible {
    background: #ececee;
    color: #6b6b6b;
    opacity: 1;
    cursor: not-allowed;
}

.button--quiet:disabled,
.button--quiet:disabled:hover,
.button--quiet:disabled:focus-visible {
    background: transparent;
    color: #b9b9be;
    opacity: 1;
    cursor: not-allowed;
}

.note--ok {
    color: #048f27;
}

.sheet {
    max-width: 440px;
    margin-top: 20px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.sheet--letter {
    max-width: 640px;
    display: flex;
    flex-direction: column;
}

.letter-send {
    order: 1;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin: 0 0 18px;
}

.letter-send label {
    flex: 1 1 auto;
    margin: 0;
}

.letter-send .button {
    flex: 0 0 auto;
    padding: 12px 14px;
}

.sheet--letter .sheet__actions {
    order: 2;
}

.sheet h2 {
    margin: 8px 0 16px;
    color: var(--ink);
    font-size: 18px;
}

.sheet h2 + .pair,
.sheet h2 + label {
    margin-top: 0;
}

.pair {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 12px;
}

.sheet select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    background: #fff;
}

.sheet select:focus {
    outline: 2px solid rgba(253, 87, 87, 0.35);
    border-color: var(--accent);
}

.sheet textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    background: #fff;
}

.sheet textarea:focus {
    outline: 2px solid rgba(253, 87, 87, 0.35);
    border-color: var(--accent);
}

.letter-sign {
    margin: 4px 0 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.letter-sign img {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 10px;
}

.sheet__actions {
    display: flex;
    gap: 12px;
}

.sheet--wide {
    width: 100%;
    max-width: none;
}

.sheet__delete {
    max-width: 440px;
    margin-top: 12px;
}

.sheet--wide + .sheet__delete {
    max-width: none;
}

.hint {
    margin: -4px 0 14px;
    color: var(--muted);
    font-size: 13px;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
}

select {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    background: #fff;
}

.sheet input[readonly],
.sheet textarea[readonly],
.sheet select:disabled,
.sheet input:disabled:not([type="checkbox"]):not([type="hidden"]),
.sheet textarea:disabled,
.card input[readonly],
.card textarea[readonly],
.card select:disabled,
.card input:disabled:not([type="checkbox"]):not([type="hidden"]),
.card textarea:disabled,
select:disabled,
textarea[readonly],
textarea:disabled {
    background: #ececee;
    color: #6b6b6b;
    border-color: #d9d9de;
    cursor: default;
}

.sheet input[readonly]:focus,
.sheet textarea[readonly]:focus,
.sheet select:disabled:focus,
.sheet input:disabled:focus,
.sheet textarea:disabled:focus,
.card input[readonly]:focus,
.card textarea[readonly]:focus,
.card select:disabled:focus,
select:disabled:focus,
textarea[readonly]:focus,
textarea:disabled:focus {
    outline: none;
    border-color: #d9d9de;
}

.note {
    margin: 16px 0 0;
    color: var(--muted);
}

.back {
    display: inline-block;
    margin: 0 0 16px;
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
}

.back:hover,
.back:focus-visible {
    color: var(--ink);
}

.grid {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.grid th,
.grid td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
}

.grid th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    background: #fafafa;
}

.grid tr:last-child td {
    border-bottom: 0;
}

.grid__row {
    cursor: pointer;
}

.grid__row:hover td {
    background: #fff8f8;
}

.grid a {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.grid form {
    margin: 0;
}

.grid__actions {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.tariffs {
    width: auto;
    border-collapse: collapse;
    margin: 8px 0 20px;
}

.tariffs th,
.tariffs td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.tariffs th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.tariffs tbody th {
    color: var(--ink);
    font-size: 16px;
    padding-right: 24px;
}

.tariffs input {
    width: 160px;
    margin-top: 0;
}

.license-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.license-fields input,
.license-fields select {
    margin-top: 6px;
}

.license-key {
    font-family: Consolas, "Courier New", monospace;
    word-break: break-all;
}

.settings .license-list {
    margin-top: 48px;
}

.idle {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(17, 17, 17, 0.72);
}

.idle[hidden] {
    display: none;
}

.idle__card {
    width: min(420px, 100%);
    padding: 32px 28px;
    background: #fff;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.idle__card h2 {
    margin: 0;
    font-size: 28px;
}

.idle__card p {
    margin: 12px 0 0;
    color: var(--muted);
}

.idle__card .button {
    margin-top: 24px;
}
