:root {
    --blue: #2962ff;
    --blue-dark: #1f4fd6;
    --text: #1a2233;
    --text-muted: #7a8599;
    --bg: #f6f7f9;
    --card: #ffffff;
    --border: #e3e7ee;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
}

.topbar .crumbs {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 17px;
}

.topbar .crumbs .logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.topbar .crumbs .sep { color: #b6c3d9; }
.topbar .crumbs .current { color: #4a5468; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 65px); }

.sidebar {
    width: 300px;
    padding: 20px 12px;
    flex-shrink: 0;
}

.sidebar .field-label {
    font-size: 14px;
    margin: 4px 8px 8px;
    color: var(--text);
}

.sidebar select.account-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    margin-bottom: 16px;
}

.sidebar .nav-group {
    background: #eef0f3;
    border-radius: var(--radius);
    padding: 8px;
}

.sidebar .nav-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-weight: 600;
}

.sidebar a.nav-item {
    display: block;
    padding: 10px 12px 10px 32px;
    color: var(--text);
    border-radius: 8px;
    font-size: 14.5px;
    position: relative;
}

.sidebar a.nav-item::before {
    content: "•";
    position: absolute;
    left: 16px;
    color: #b6c3d9;
}

.sidebar a.nav-item.active {
    background: var(--blue);
    color: #fff;
}

.sidebar a.nav-item.active::before { color: #fff; }

.sidebar a.cabinet {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    color: var(--text);
    font-size: 15px;
}

/* Content */
.content { flex: 1; padding: 24px 32px; }

.card {
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(26, 34, 51, .06);
    padding: 28px 32px;
    max-width: 1100px;
}

.card h1 {
    font-size: 21px;
    margin: 0 0 20px;
}

.hint {
    display: flex;
    gap: 12px;
    align-items: center;
    background: #f2f5fa;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
    color: #45516b;
    font-size: 14px;
}

/* Forms */
.form-row { margin-bottom: 18px; }

.form-row > label {
    display: block;
    margin-bottom: 8px;
    font-size: 14.5px;
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea,
select.input {
    width: 100%;
    padding: 11px 14px;
    font-size: 14.5px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

input:focus, textarea:focus, select:focus { outline: 2px solid rgba(41, 98, 255, .25); }

textarea { min-height: 110px; resize: vertical; }

input.input-narrow { width: 90px; text-align: center; }

/* Toggle switch (label.toggle перебивает display:block от .form-row > label) */
label.toggle, .toggle { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14.5px; }
.toggle input { display: none; }
.toggle .track {
    width: 46px;
    height: 26px;
    background: #d9dee7;
    border-radius: 13px;
    position: relative;
    transition: background .15s;
    flex-shrink: 0;
}
.toggle .track::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: left .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle input:checked + .track { background: var(--blue); }
.toggle input:checked + .track::after { left: 23px; }

/* Checkbox */
.check { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }

/* Buttons */
.btn {
    display: inline-block;
    border: none;
    cursor: pointer;
    background: var(--blue);
    color: #fff;
    font-size: 14.5px;
    padding: 11px 22px;
    border-radius: 8px;
}
.btn:hover { background: var(--blue-dark); }

/* Tables */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
    text-align: left;
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
table.grid th.strong { color: var(--text); font-weight: 600; }
table.grid td { padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }

.muted { color: var(--text-muted); font-size: 13.5px; }

.flash {
    background: #e8f5e9;
    color: #1b5e20;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 14px;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.q {
    display: inline-flex;
    width: 18px; height: 18px;
    border: 1px solid #c3cbd9;
    border-radius: 50%;
    color: #9aa6ba;
    font-size: 12px;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    cursor: help;
    position: relative;
    vertical-align: middle;
}

/* Тултип: показывается по наведению и по клику/фокусу (tabindex="0") */
.q::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a2233;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
    width: max-content;
    max-width: 300px;
    white-space: normal;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 20;
}

.q::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1a2233;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s;
    z-index: 20;
}

.q:hover::after, .q:focus::after,
.q:hover::before, .q:focus::before {
    opacity: 1;
    visibility: visible;
}

.q:focus { outline: none; border-color: var(--blue); }

/* Тост автосохранения */
.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: #1b5e20;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(26, 34, 51, .2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    z-index: 100;
    max-width: 420px;
}

.toast-visible { opacity: 1; transform: translateY(0); }
.toast-error { background: #b3261e; }
