:root {
    color-scheme: light;
    --ink: #102f4a;
    --muted: #66717c;
    --line: #d7dde3;
    --surface: #ffffff;
    --page: #153a5a;
    --panel: #f8fafc;
    --accent: #153a5a;
    --accent-strong: #0d2941;
    --active: #7d8790;
    --active-strong: #606a73;
    --focus: #5f7182;
    --danger: #bd1e28;
    --danger-bg: #fff0f3;
    --success-bg: #eaf7f3;
    --shadow: 0 30px 80px rgba(31, 42, 55, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(21, 58, 90, 0.92), rgba(13, 41, 65, 0.98)),
        var(--page);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 42px;
}

.login-frame {
    width: min(100%, 1040px);
    min-height: 620px;
    display: grid;
    grid-template-columns: minmax(300px, 0.92fr) minmax(380px, 1.08fr);
    overflow: hidden;
    border: 1px solid rgba(217, 224, 231, 0.92);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.brand-pane {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px;
    background:
        linear-gradient(145deg, rgba(16, 47, 74, 0.06), rgba(223, 38, 49, 0.035)),
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 247, 249, 0.98)),
        #ffffff;
    border-right: 1px solid var(--line);
}

.avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    font-weight: 800;
}

.brand-logo {
    display: block;
    width: min(390px, 82%);
    height: auto;
}

.panel {
    align-self: center;
    justify-self: center;
    width: min(100% - 72px, 430px);
    background: var(--surface);
    border: 0;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.panel__header {
    margin-bottom: 18px;
}

h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.14;
}

h2 {
    margin: 4px 0;
    font-size: 22px;
}

.form,
.reset {
    display: grid;
    gap: 14px;
}

.form-hint {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.form-note {
    grid-column: 1 / -1;
    margin: 0;
    padding: 12px;
    border-radius: 6px;
    color: var(--muted);
    background: var(--panel);
}

.language-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.language-switch a {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

.language-switch a.is-active {
    color: #ffffff;
    border-color: var(--active);
    background: var(--active);
}

.reset {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    min-height: 46px;
    padding: 12px 14px;
    font: inherit;
    color: var(--ink);
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    min-height: 46px;
    padding: 12px 14px;
    font: inherit;
    color: var(--ink);
}

input:focus,
textarea:focus {
    border-color: var(--focus);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(95, 113, 130, 0.13);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.check input {
    width: auto;
}

button {
    border: 0;
    border-radius: 6px;
    min-height: 46px;
    padding: 12px 15px;
    color: #fff;
    background: var(--accent);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.16s ease;
}

button:hover {
    background: var(--accent-strong);
}

button:active {
    transform: translateY(1px);
}

.notice,
.error {
    border-radius: 6px;
    padding: 12px;
}

.notice {
    background: var(--success-bg);
}

.error {
    color: var(--danger);
    background: var(--danger-bg);
}

.muted {
    color: var(--muted);
    margin-bottom: 0;
}

.account {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.account p {
    margin: 4px 0 0;
}

.avatar {
    width: 46px;
    height: 46px;
    color: #ffffff;
    background: var(--accent);
    text-transform: uppercase;
}

.actions {
    margin-top: 18px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    background: #f3f6f8;
}

.app-sidebar {
    min-height: 100vh;
    max-height: 100vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    position: sticky;
    top: 0;
    padding: 24px 18px;
    background: #ffffff;
    border-right: 1px solid var(--line);
}

.app-sidebar__brand {
    padding: 0 2px 22px;
}

.app-sidebar__brand a {
    display: inline-block;
}

.app-logo {
    display: block;
    width: 204px;
    height: auto;
}

.app-nav {
    display: grid;
    align-content: start;
    gap: 18px;
    overflow-y: auto;
    padding: 0 4px 12px 0;
}

.app-nav__section {
    display: grid;
    gap: 5px;
}

.app-nav__title {
    padding: 0 10px 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.app-nav a,
.app-nav summary {
    display: block;
    min-height: 38px;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.app-nav summary::-webkit-details-marker {
    display: none;
}

.app-nav a.is-active,
.app-nav summary.is-active {
    color: #ffffff;
    background: var(--accent);
}

.app-nav__group {
    display: grid;
    gap: 5px;
}

.app-nav__group summary {
    position: relative;
}

.app-nav__group summary::after {
    content: "+";
    position: absolute;
    right: 12px;
}

.app-nav__group[open] summary {
    color: var(--ink);
    background: var(--panel);
}

.app-nav__group[open] summary::after {
    content: "-";
}

.app-nav__children {
    position: relative;
    display: grid;
    gap: 4px;
    margin: 2px 0 2px 12px;
    padding-left: 12px;
}

.app-nav__children::before {
    content: "";
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: 1px;
    background: var(--line);
}

.app-nav__children a {
    position: relative;
    min-height: 34px;
    padding: 8px 10px 8px 12px;
    font-size: 14px;
    font-weight: 750;
    background: transparent;
}

.app-nav__children a::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    width: 8px;
    height: 1px;
    background: var(--line);
}

.app-nav__children a:hover {
    color: var(--ink);
    background: var(--panel);
}

.app-nav__children a.is-active {
    color: #ffffff;
    background: var(--accent);
}

.app-nav__children a.is-active::before {
    height: 2px;
    background: var(--accent);
}

.app-main {
    width: 100%;
    min-width: 0;
    padding: 0;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 88px;
    padding: 22px 34px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.app-header .actions {
    margin: 0;
}

.dashboard-page {
    padding: 28px 34px 40px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(360px, 2fr) repeat(2, minmax(220px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.dashboard-card {
    min-height: 140px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.metric-card {
    min-height: 112px;
}

.metric-card h3 {
    margin: 8px 0 0;
    font-size: 34px;
}

.content-header {
    margin-bottom: 18px;
}

.content-header h2 {
    font-size: 28px;
}

.content-header--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.button-link {
    display: inline-grid;
    place-items: center;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: 6px;
    color: #ffffff;
    background: var(--accent);
    text-decoration: none;
    font-weight: 800;
}

.button-link--danger {
    border: 1px solid #b91c1c;
    background: #b91c1c;
}

.button-link--muted {
    color: var(--accent);
    background: var(--panel);
}

.table-link {
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.table-link:hover {
    text-decoration: underline;
}

.table-link--muted {
    color: var(--ink);
    font-weight: 700;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.acid-config-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.compact-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.compact-form button {
    justify-self: start;
    min-width: 160px;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

.form-actions--top {
    align-items: center;
    justify-content: flex-start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.form-actions button {
    min-width: 180px;
}

.upload-progress {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.upload-progress[hidden] {
    display: none;
}

.upload-progress__bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #d7dee8;
}

.upload-progress__bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--danger));
    transition: width 160ms ease;
}

.field-list {
    display: grid;
    gap: 10px;
    margin: 14px 0 0;
    padding-left: 18px;
    color: var(--ink);
}

.dashboard-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 16px;
    margin-top: 16px;
}

.activity-list,
.tool-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.activity-row,
.tool-row {
    display: grid;
    gap: 2px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
}

.activity-row span,
.tool-row span,
.activity-row small {
    color: var(--muted);
}

.table-card {
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.editor-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.field-group {
    display: grid;
    gap: 10px;
}

.repeatable-group {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.module-picker {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.module-picker legend {
    padding: 0 6px;
    font-weight: 900;
}

.module-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.module-toggle input {
    width: 18px;
    min-height: 18px;
    margin-top: 2px;
}

.module-toggle span {
    display: grid;
    gap: 3px;
}

.module-toggle small {
    color: var(--muted);
    font-weight: 600;
}

.repeatable-row {
    display: grid;
    gap: 10px;
}

.phone-row {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr 0.9fr 1.4fr;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.birthdate-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.birthdate-group > span {
    grid-column: 1 / -1;
}

.wide-field {
    grid-column: 1 / -1;
}

.field-group > span {
    font-size: 14px;
    font-weight: 800;
}

.secondary-button {
    justify-self: start;
    min-height: 38px;
    color: var(--accent);
    background: var(--panel);
}

.secondary-button:hover {
    color: #ffffff;
    background: var(--accent);
}

.editor-form button {
    grid-column: 1 / -1;
    justify-self: start;
    min-width: 180px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.empty-row {
    color: var(--muted);
    text-align: center;
}

.status-pill {
    display: inline-block;
    margin: 0;
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--ink);
    background: var(--panel);
    font-size: 12px;
    font-weight: 800;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row-actions a,
.row-actions button {
    min-height: 34px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 800;
}

.row-actions a {
    color: var(--accent);
    background: var(--panel);
    text-decoration: none;
}

.row-actions form {
    margin: 0;
}

.account-card {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

@media (max-width: 760px) {
    .login-shell {
        padding: 18px;
        place-items: start center;
    }

    .login-frame {
        min-height: auto;
        grid-template-columns: 1fr;
    }

    .brand-pane {
        min-height: auto;
        padding: 34px 24px 18px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: transparent;
    }

    .brand-logo {
        width: min(260px, 76vw);
    }

    .panel {
        width: 100%;
        padding: 26px 24px 28px;
    }

    h1 {
        font-size: 24px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        max-height: none;
        display: block;
        min-height: auto;
        padding: 22px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .app-logo {
        width: 170px;
    }

    .app-nav {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        padding: 0 0 2px;
    }

    .app-nav__section {
        display: flex;
        gap: 6px;
        flex: 0 0 auto;
    }

    .app-nav__group {
        flex: 0 0 auto;
    }

    .app-nav__children {
        margin: 0;
        padding-left: 0;
    }

    .app-nav__children::before,
    .app-nav__children a::before {
        display: none;
    }

    .app-nav__title {
        display: none;
    }

    .app-main {
        padding: 0;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 22px;
    }

    .dashboard-page {
        padding: 22px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .metric-grid,
    .dashboard-columns,
    .compact-form,
    .editor-form {
        grid-template-columns: 1fr;
    }

    .phone-row {
        grid-template-columns: 1fr;
    }

    .birthdate-group {
        grid-template-columns: 1fr;
    }

    .account-card {
        grid-column: auto;
    }
}
