:root,
html[data-theme="light"] {
    --primary: #3972e6;
    --secondary: #101827;
    --accent: #3972e6;
    --primary-fg: #ffffff;
    --body-fg: #172033;
    --body-bg: #f4f7fb;
    --body-quiet-color: #718096;
    --body-medium-color: #526078;
    --body-loud-color: #172033;
    --header-color: #ffffff;
    --header-branding-color: #ffffff;
    --header-bg: #101827;
    --header-link-color: #dce5f3;
    --breadcrumbs-fg: #718096;
    --breadcrumbs-link-fg: #3972e6;
    --breadcrumbs-bg: transparent;
    --link-fg: #2858be;
    --link-hover-color: #1e4da9;
    --link-selected-fg: #3972e6;
    --hairline-color: #e3e9f1;
    --border-color: #d8e0eb;
    --error-fg: #b83d4d;
    --message-success-bg: #e3f7ef;
    --message-warning-bg: #fff0df;
    --message-error-bg: #fde9ec;
    --darkened-bg: #f7f9fc;
    --selected-bg: #e9f0ff;
    --selected-row: #f2f6ff;
    --button-fg: #ffffff;
    --button-bg: #3972e6;
    --button-hover-bg: #2858be;
    --default-button-bg: #3972e6;
    --default-button-hover-bg: #2858be;
    --delete-button-bg: #ca4b5a;
    --delete-button-hover-bg: #a93745;
    --object-tools-fg: #2858be;
    --object-tools-bg: #e9f0ff;
    --object-tools-hover-bg: #dce8ff;
    color-scheme: light;
}

html[data-theme="dark"] {
    --primary: #73a1ff;
    --secondary: #080e18;
    --accent: #73a1ff;
    --body-fg: #e8eef8;
    --body-bg: #0c1320;
    --body-quiet-color: #9aabc2;
    --body-medium-color: #b2bfd1;
    --body-loud-color: #f4f7fb;
    --header-color: #ffffff;
    --header-branding-color: #ffffff;
    --header-bg: #101827;
    --header-link-color: #dce5f3;
    --breadcrumbs-fg: #9aabc2;
    --breadcrumbs-link-fg: #8fb3ff;
    --breadcrumbs-bg: transparent;
    --link-fg: #8fb3ff;
    --link-hover-color: #b6ceff;
    --link-selected-fg: #a9c5ff;
    --hairline-color: #29384d;
    --border-color: #34445b;
    --darkened-bg: #1a2638;
    --selected-bg: #1d3358;
    --selected-row: #182942;
    --button-bg: #3972e6;
    --button-hover-bg: #5286ed;
    --default-button-bg: #3972e6;
    --default-button-hover-bg: #5286ed;
    --object-tools-fg: #b6ceff;
    --object-tools-bg: #1d3358;
    --object-tools-hover-bg: #294572;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    color: var(--body-fg);
    background:
        radial-gradient(circle at 90% 0, #e6eeff 0, transparent 28rem),
        var(--body-bg);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#container {
    min-width: 0;
}

#header {
    min-height: 78px;
    padding: 0 32px;
    background:
        radial-gradient(circle at 12% 0, #243b68 0, transparent 23rem),
        #101827;
    box-shadow: 0 10px 30px rgba(16, 24, 39, 0.18);
}

#branding {
    display: flex;
    align-items: center;
}

.nico-branding,
.nico-brand {
    display: flex;
    align-items: center;
}

.nico-brand {
    gap: 12px;
    color: #ffffff !important;
    text-decoration: none;
}

.nico-brand-symbol {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    color: #ffffff;
    background: linear-gradient(145deg, #4b84f1, #2e61cf);
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(42, 100, 221, 0.35);
}

.nico-brand-symbol svg {
    width: 27px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.nico-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.nico-brand-text strong {
    font-size: 19px;
    font-weight: 800;
}

.nico-brand-text small {
    margin-top: 4px;
    color: #94a4bc;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

#user-tools {
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

#user-tools a,
#logout-form button {
    padding: 9px 11px;
    color: #c6d2e3;
    border: 0;
    border-radius: 9px;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
}

#user-tools a:hover,
#logout-form button:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

#user-tools .theme-toggle {
    border-radius: 9px;
}

#nav-global {
    display: flex;
    align-items: center;
    margin-left: auto;
    padding-left: 20px;
}

.nico-site-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    color: #ffffff !important;
    background: rgba(57, 114, 230, 0.28);
    border: 1px solid rgba(115, 161, 255, 0.28);
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.nico-site-link:hover {
    background: rgba(57, 114, 230, 0.45);
}

.nico-site-link svg {
    width: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

div.breadcrumbs {
    padding: 18px max(32px, calc((100vw - 1440px) / 2));
    color: #718096;
    background: transparent;
    font-size: 12px;
}

div.breadcrumbs a {
    color: #3972e6;
    font-weight: 700;
}

.main > #nav-sidebar {
    top: 0;
    width: 255px;
    flex: 0 0 255px;
    margin: 0 0 32px 32px;
    background: #ffffff;
    border: 1px solid #e3e9f1;
    border-radius: 17px;
    box-shadow: 0 8px 28px rgba(27, 42, 70, 0.07);
    overflow: hidden;
}

#nav-sidebar .module {
    margin: 0;
}

#nav-sidebar .module caption,
#nav-sidebar .module h2 {
    padding: 15px 18px;
    color: #718096;
    background: #f7f9fc;
    border-bottom: 1px solid #e3e9f1;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

#nav-sidebar .module th,
#nav-sidebar .module td {
    padding: 11px 16px;
    border-bottom-color: #edf1f6;
}

#nav-sidebar .current-model {
    background: #e9f0ff;
}

#nav-sidebar .current-model a {
    color: #2858be;
    font-weight: 750;
}

#nav-filter {
    margin: 14px;
    padding: 10px 12px;
    background: #f7f9fc;
    border: 1px solid #e3e9f1;
    border-radius: 10px;
}

#content {
    width: min(100%, 1440px);
    padding: 12px 32px 40px;
}

#content h1 {
    margin: 0 0 24px;
    color: #172033;
    font-size: clamp(25px, 3vw, 34px);
    font-weight: 820;
    letter-spacing: -0.03em;
}

#content-main > .module,
.inline-group,
#changelist .results,
#changelist-filter,
.dashboard #content-main .module,
.login #content-main {
    background: #ffffff;
    border: 1px solid #e3e9f1;
    border-radius: 17px;
    box-shadow: 0 8px 28px rgba(27, 42, 70, 0.07);
    overflow: hidden;
}

.module h2,
.module caption,
.inline-group h2 {
    padding: 15px 18px;
    color: #172033;
    background: #f7f9fc;
    border-bottom: 1px solid #e3e9f1;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.dashboard .module caption a,
.dashboard .module h2 a,
#nav-sidebar .module caption a,
#nav-sidebar .module h2 a {
    color: #2858be;
    font-weight: 850;
    opacity: 1;
}

html[data-theme="dark"] .dashboard .module caption a,
html[data-theme="dark"] .dashboard .module h2 a,
html[data-theme="dark"] #nav-sidebar .module caption a,
html[data-theme="dark"] #nav-sidebar .module h2 a {
    color: #a9c5ff;
}

.dashboard #content-main .module table th,
.dashboard #content-main .module table td {
    padding: 14px 18px;
}

.dashboard #content-main .module table tr:hover {
    background: #f7f9fc;
}

.dashboard #content-related {
    width: 310px;
    margin-right: 0;
}

.dashboard #content-related .module {
    border-radius: 17px;
    box-shadow: 0 8px 28px rgba(27, 42, 70, 0.07);
}

.object-tools {
    margin-top: -52px;
}

.object-tools a:link,
.object-tools a:visited {
    min-height: 38px;
    padding: 10px 15px;
    border-radius: 10px;
    font-weight: 750;
    letter-spacing: 0;
    text-transform: none;
}

#changelist {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

#changelist .changelist-form-container {
    min-width: 0;
}

#changelist .results {
    border-radius: 0 0 17px 17px;
    box-shadow: none;
}

#changelist table thead th {
    padding: 13px 12px;
    color: #526078;
    background: #f7f9fc;
    border-bottom: 1px solid #e3e9f1;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

#changelist table tbody td,
#changelist table tbody th {
    padding: 13px 12px;
    border-color: #edf1f6;
}

#changelist table tbody tr:hover {
    background: #f7f9fc;
}

#changelist-filter {
    flex: 0 0 250px;
    margin: 0;
}

#changelist-filter h2 {
    padding: 15px 18px;
}

#changelist-filter h3 {
    margin: 0;
    padding: 15px 18px 7px;
    color: #526078;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

#changelist-filter li {
    margin: 0;
    padding: 5px 18px;
}

#changelist-filter li:last-child {
    padding-bottom: 14px;
}

#changelist-filter li.selected {
    border-left-color: #3972e6;
}

#changelist-filter li.selected a {
    color: #2858be;
    font-weight: 750;
}

#changelist-search,
#toolbar {
    padding: 13px 16px;
    background: #ffffff;
    border: 1px solid #e3e9f1;
    border-radius: 17px 17px 0 0;
    box-shadow: 0 8px 28px rgba(27, 42, 70, 0.07);
}

#toolbar form input[type="submit"] {
    min-height: 40px;
}

.actions {
    padding: 12px 16px !important;
    background: #f7f9fc !important;
    border-color: #e3e9f1 !important;
}

input,
textarea,
select,
.vTextField {
    min-height: 42px;
    padding: 9px 11px;
    color: #172033;
    background: #ffffff;
    border: 1px solid #d8e0eb;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    min-height: 110px;
}

input:focus,
textarea:focus,
select:focus,
.vTextField:focus {
    border-color: #6f9bf1;
    box-shadow: 0 0 0 3px rgba(57, 114, 230, 0.14);
}

input[type="checkbox"],
input[type="radio"] {
    min-height: auto;
    accent-color: #3972e6;
}

.form-row {
    padding: 17px 20px;
    border-bottom-color: #edf1f6;
}

.form-row label {
    color: #526078;
    font-weight: 750;
}

.help,
p.help,
form p.help,
div.help,
form div.help {
    color: #718096;
}

.aligned .form-row.errors {
    background: #fff7f8;
}

.errorlist {
    color: #b83d4d;
}

fieldset.collapse {
    border-radius: 17px;
}

fieldset.collapse summary {
    padding: 15px 18px;
    color: #172033;
    background: #f7f9fc;
    font-weight: 800;
}

.submit-row {
    padding: 14px 18px;
    background: #ffffff;
    border: 1px solid #e3e9f1;
    border-radius: 17px;
    box-shadow: 0 8px 28px rgba(27, 42, 70, 0.07);
}

.button,
input[type="submit"],
input[type="button"],
.submit-row input,
a.button {
    min-height: 40px;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 750;
}

.messagelist {
    padding: 0 32px;
}

ul.messagelist li {
    margin: 14px 0 0;
    padding: 14px 18px 14px 44px;
    border-radius: 12px;
    box-shadow: 0 5px 18px rgba(27, 42, 70, 0.05);
}

.paginator {
    padding: 15px 18px !important;
    background: #ffffff !important;
    border-radius: 0 0 17px 17px;
}

.login {
    background:
        radial-gradient(circle at 25% 20%, #243b68 0, transparent 30rem),
        #101827;
}

.login #container {
    width: min(440px, calc(100% - 32px));
    margin-top: 10vh;
    background: transparent;
    border: 0;
}

.login #header {
    min-height: auto;
    padding: 0 0 24px;
    background: transparent;
    box-shadow: none;
}

.login #content-main {
    padding: 28px;
}

.login .form-row {
    padding: 10px 0;
}

.login .form-row label {
    color: #526078;
}

.login .submit-row {
    padding: 14px 0 0;
    border: 0;
    box-shadow: none;
}

.login .submit-row input {
    width: 100%;
}

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 90% 0, #172746 0, transparent 28rem),
        var(--body-bg);
}

html[data-theme="dark"] .main > #nav-sidebar,
html[data-theme="dark"] #content-main > .module,
html[data-theme="dark"] .inline-group,
html[data-theme="dark"] #changelist .results,
html[data-theme="dark"] #changelist-filter,
html[data-theme="dark"] .dashboard #content-main .module,
html[data-theme="dark"] .login #content-main,
html[data-theme="dark"] #changelist-search,
html[data-theme="dark"] #toolbar,
html[data-theme="dark"] .submit-row {
    background: #151f2f;
    border-color: #29384d;
}

html[data-theme="dark"] .module h2,
html[data-theme="dark"] .module caption,
html[data-theme="dark"] .inline-group h2,
html[data-theme="dark"] #nav-sidebar .module caption,
html[data-theme="dark"] #nav-sidebar .module h2,
html[data-theme="dark"] #changelist table thead th,
html[data-theme="dark"] fieldset.collapse summary,
html[data-theme="dark"] .actions,
html[data-theme="dark"] .paginator {
    color: #e8eef8;
    background: #1a2638 !important;
    border-color: #29384d !important;
}

html[data-theme="dark"] #content h1,
html[data-theme="dark"] fieldset.collapse summary {
    color: #e8eef8;
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .vTextField {
    color: #e8eef8;
    background: #101a29;
    border-color: #34445b;
}

html[data-theme="dark"] .form-row,
html[data-theme="dark"] #changelist table tbody td,
html[data-theme="dark"] #changelist table tbody th,
html[data-theme="dark"] #nav-sidebar .module th,
html[data-theme="dark"] #nav-sidebar .module td {
    border-color: #29384d;
}

html[data-theme="dark"] .form-row label,
html[data-theme="dark"] #changelist-filter h3 {
    color: #b2bfd1;
}

html[data-theme="dark"] .dashboard #content-main .module table tr:hover,
html[data-theme="dark"] #changelist table tbody tr:hover {
    background: #1a2638;
}

html[data-theme="dark"] .login {
    background:
        radial-gradient(circle at 25% 20%, #243b68 0, transparent 30rem),
        #080e18;
}

@media (max-width: 1024px) {
    #header {
        padding: 0 20px;
    }

    #nav-global {
        display: none;
    }

    .main > #nav-sidebar {
        margin-left: 20px;
    }

    #content {
        padding-right: 20px;
        padding-left: 20px;
    }

    #changelist {
        display: block;
    }

    #changelist-filter {
        width: 100%;
        margin-top: 20px;
    }
}

@media (max-width: 767px) {
    #header {
        min-height: 68px;
        padding: 9px 14px;
    }

    .nico-brand-symbol {
        width: 42px;
        height: 42px;
    }

    .nico-brand-text strong {
        font-size: 16px;
    }

    .nico-brand-text small {
        font-size: 9px;
    }

    #user-tools {
        margin: 0;
    }

    #user-tools strong,
    #user-tools > a:not(:last-of-type) {
        display: none;
    }

    div.breadcrumbs {
        padding: 14px 16px;
        overflow-x: auto;
        white-space: nowrap;
    }

    .main > #nav-sidebar {
        margin: 0;
        border-radius: 0;
    }

    #content {
        padding: 10px 16px 32px;
    }

    #content h1 {
        margin-bottom: 18px;
        font-size: 25px;
    }

    .object-tools {
        display: flex;
        float: none;
        margin: 0 0 16px;
        padding: 0;
    }

    .object-tools li {
        flex: 1;
    }

    .object-tools a:link,
    .object-tools a:visited {
        display: block;
        text-align: center;
    }

    .form-row {
        padding: 14px 16px;
    }

    .aligned .form-row > div {
        width: 100%;
    }

    .aligned label {
        width: auto;
        padding: 0 0 7px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="url"],
    input[type="number"],
    textarea,
    select,
    .vTextField {
        width: 100%;
        max-width: 100%;
    }

    .submit-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .submit-row input,
    .submit-row a {
        flex: 1 1 auto;
        margin: 0 !important;
    }

    .messagelist {
        padding: 0 16px;
    }

    .login #user-tools,
    .login #nav-global {
        display: none;
    }
}
