:root {
    --color-background: #EEEEEE;

    --color-primary: #004080;

    --color-text: #202020;
    --color-text-on-primary: #EEEEEE;
    --color-text-light: #505050;

    --color-focus: #FF8000;
    --color-shadow: #00000055;
    --color-title: var(--color-primary);
    --color-border: var(--color-title);
    --color-gray-border: gray;
    --color-row-even: var(--color-background);
    --color-row-odd: #FEF6FF;

    --color-svg: var(--color-title);
    --color-svg-on-primary: var(--color-text-on-primary);
}

:root.theme-dark {
    --color-background: #202020;

    --color-text: #CDCDCD;
    --color-text-light: #B3B3B3;

    --color-shadow: #FFFFFF55;
    --color-title: #0080FF;
    --color-gray-border: lightgray;
}

:root {
    /* COLORS */
    --window--shadow: 0 0 calc(var(--window--margin) * 2) var(--window--margin) var(--color-shadow);
    --label--color-text: var(--color-text-light);

    /* SVG */
    --color-svg-black: #101010;
    --color-svg-cyan: #00ABCD;
    --color-svg-green: #00AA00;
    --color-svg-orange: #FF9933;
    --color-svg-red: #EE0000;
    --color-svg-white: #FFFFFF;

    /* TEXT */
    --font-family: Verdana;
    --font-size-base: 12px;
    --line-height-base: 1.5;

    /* SIZES */
    --border-radius: 5px;
    --field-max-width: 300px;
    --icon-height: 24px;
    --icon-small-height: 16px;
    --icon-table-height: 18px;
    --window--margin: 5px;

    /* Z-INDEXES */
    --zindex-loading: 1000;
}


/*****************************************/
/* BASE ELEMENTS                         */
/*****************************************/

html {
    box-sizing: border-box;
    scroll-behavior: smooth;
    text-size-adjust: 100%;
    word-break: break-word;
    word-wrap: break-word;
    -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    background-color: var(--color-background);
    color: var(--color-text);
    font-family: var(--font-family), sans-serif;
    font-size: var(--font-size-base);
    height: 100vh;
    line-height: var(--line-height-base);
    margin: 0;
    min-height: 100dvh;
    overflow: hidden;
    padding: 0;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* A */

a {
    display: inline;
    text-decoration: none;
    vertical-align: middle;
}

a:hover {
    text-decoration: underline;
}

/* BUTTON */

button,
a.button {
    background: transparent;
    border: none;
    color: var(--color-text);
    cursor: pointer;
    display: inline-block;
    font-size: inherit;
    line-height: var(--line-height-base);
    margin: 0;
    padding: 0;
    text-decoration: none;
    vertical-align: middle;
}

button:hover,
a.button:hover {
    text-decoration: none;
}

button[disabled],
a.button[disabled] {
    opacity: 0.5;
}

/* IMG */

img,
svg {
    border-style: none;
    display: block;
    height: auto;
    image-orientation: from-image;
    image-rendering: auto;
    max-inline-size: 100%;
    vertical-align: middle;
}

img.icon,
svg.icon {
    height: var(--icon-height);
    width: var(--icon-height);
}

img.icon-small,
svg.icon-small {
    height: var(--icon-small-height);
    width: var(--icon-small-height);
}

/* LIST */

ol,
ul {
    list-style-position: inside;
    margin: 2px auto;
    max-width: max-content;
    padding: 0;
    text-align: left;
    width: 100%;
}

/* P */

p {
    color: var(--color-text);
}

/* PROGRESS */

progress {
    display: block;
    margin: auto;
    max-width: 100%;
    width: 250px;
}

/* FIELDSET */

fieldset {
    border: 1px solid var(--color-gray-border);
    border-radius: var(--border-radius);
    margin: 20px auto;
    padding: 10px;
    width: 100%;
}

fieldset legend {
    margin: 0 auto 0 0;
}

fieldset legend.title,
fieldset legend.subtitle,
fieldset legend.ssubtitle {
    font-size: larger;
}

/* TABLE */

table {
    --even-background: var(--color-row-even);
    --odd-background: var(--color-row-odd);

    border: 1px solid var(--color-primary);
    border-collapse: separate;
    border-spacing: 0;
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
    display: block;
    margin: 20px auto;
    max-width: 100%;
    overflow-x: auto;
    text-align: left;
    white-space: nowrap;
    width: max-content;
}

table tr {
    margin: 0;
    padding: 0;
}

table tr:has(th) {
    background: var(--color-primary);
    color: var(--color-text-on-primary);
    font-weight: bold;
}

table tr th,
table tr td {
    overflow: hidden;
    padding: 5px 15px;
}

table tr th {
    font-weight: inherit;
    padding-bottom: 8px;
    padding-top: 10px;
    text-align: center;
}

table tr:nth-child(odd) > td {
    background-color: var(--odd-background);
}

table tr:nth-child(even) > td {
    background-color: var(--even-background);
}

table:has(tr.selected) {
    border-collapse: collapse;
}

table tr.selected {
    border: 2px solid var(--color-focus);
    font-weight: bold;
}

table img.icon,
table svg.icon {
    display: inline-block;
    height: var(--icon-table-height);
    margin: 0 5px;
    width: var(--icon-table-height);
}


/*****************************************/
/* SVG                                   */
/*****************************************/

svg {
    fill: none;
    font-family: arial, sans-serif;
    font-weight: bold;
    stroke: var(--color-svg);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 6px;
}

svg text {
    dominant-baseline: middle;
    fill: var(--color-svg);
    letter-spacing: 1px;
    stroke: none;
    text-anchor: middle;
}

svg.on-primary {
    --color-svg: var(--color-svg-on-primary);
}


/*****************************************/
/* UTILITIES                             */
/*****************************************/

span.no-wrap {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-wrap: normal;
}

*[hidden] {
    display: none !important;
}

button.offvalue,
img.offvalue,
svg.offvalue {
    opacity: 0.3;
}

button[disabled] {
    cursor: default;
}

a.back,
button.back {
    color: var(--color-text);
    display: block;
    margin: 0 auto 10px min(5vw, 40px);
    max-width: max-content;
}

a.back:before,
button.back:before {
    content: "◀";
    margin-right: 5px;
    vertical-align: text-bottom;
}

a.back:hover,
button.back:hover {
    color: var(--color-focus);
}


/*****************************************/
/* WINDOW                                */
/*****************************************/

div.window-background {
    align-items: stretch;
    background: transparent;
    display: flex;
    height: 100vh;
    justify-content: stretch;
    left: 0;
    position: fixed;
    top: 0;
    width: 100vw;
    z-index: var(--zindex-loading);
}

div.window {
    --window-max-height: calc(100vh - var(--window--margin) * 2);
    --window-max-width: calc(100vw - var(--window--margin) * 2);
    --window-min-height: 150px;
    --window-min-width: 200px;

    background: var(--color-background);
    border: 2px solid var(--color-primary);
    border-radius: var(--border-radius);
    box-shadow: var(--window--shadow);
    display: block;
    margin: auto;
    height: var(--window-max-height);
    max-height: max-content;
    max-width: max-content;
    min-height: min(var(--window-min-height), var(--window-max-height));
    min-width: min(var(--window-min-width), var(--window-max-width));
    overflow: hidden auto;
    padding: 20px;
    text-align: center;
    width: var(--window-max-width);
}

div.window > span {
    display: block;
}

div.window > span.title,
div.window > span.subtitle,
div.window > span.ssubtitle {
    font-size: large;
    margin: 0 auto 10px auto;
}

div.window > span.title {
    font-size: large;
}

div.window > span.subtitle,
div.window > span.ssubtitle {
    font-size: larger;
}

div.window fieldset {
    margin: 10px 0;
}


/*****************************************/
/* TEXT                                  */
/*****************************************/

h1, h2, h3, h4, h5, h6 {
    display: block;
    margin: 10px auto;
    text-align: center;
    width: 100%;
}

.title, .subtitle, .ssubtitle {
    color: var(--color-title);
    font-weight: bold;
}

.title {
    font-size: x-large;
}

.subtitle {
    font-size: large;
}

.ssubtitle {
    font-size: larger;
}


/*****************************************/
/* LAYOUT                                */
/*****************************************/

body {
    --open-close-size: min(36px, 20vh);

    display: grid;
    grid-template-columns: max-content 1fr;
    grid-template-rows: max-content 1fr;
}

/* HEADER */

body > header {
    align-items: center;
    background-color: var(--color-primary);
    color: var(--color-text-on-primary);
    display: flex;
    flex-wrap: nowrap;
    font-size: larger;
    font-weight: bold;
    gap: min(1vw, 20px);
    grid-column: 1 / -1;
    grid-row: 1;
    justify-content: space-between;
    overflow: hidden;
    padding: 8px min(40px, 5%);
}

body > header > span.app,
body > header > span.name,
body > header > span.user {
    flex: 1;
    max-width: max-content;
}

body > header > span > img,
body > header > span > svg,
body > header > span > button {
    display: inline-block;
}

body > header > span.app > img {
    margin-right: 10px;
}

body > header > span.user > button {
    margin-left: 10px;
}

body > header > span.user > button:hover {
    --color-svg-on-primary: var(--color-focus);
}

/* NAV */

body > nav {
    background-color: var(--color-primary);
    grid-column: 1;
    grid-row: 2;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px 0 20px 0;
    position: relative;
}

body > nav:not(:has(> a)) {
    display: none;
}

body > nav > a {
    align-items: center;
    color: var(--color-text-on-primary);
    cursor: pointer;
    display: flex;
    flex-wrap: nowrap;
    font-weight: bolder;
    gap: 8px;
    justify-content: flex-start;
    padding: 8px 10px;
}

body > nav > a.selected {
    text-decoration: underline;
    text-decoration-color: var(--color-focus);
}

body > nav > a > svg {
    --color-svg: var(--color-svg-on-primary);

    display: inline-block;
    height: 16px;
    width: 16px;
}

body > nav > a:hover {
    --color-svg-on-primary: var(--color-focus);

    color: var(--color-focus);
    text-decoration: none;
}

body > nav > button.open-close {
    background: var(--color-primary);
    border-bottom-right-radius: var(--border-radius);
    display: none;
    height: var(--open-close-size);
    left: 0;
    padding: 2.5%;
    position: absolute;
    top: 0;
    width: var(--open-close-size);
}

body > nav > button.open-close > svg {
    height: 100%;
    width: 100%;
}

body > nav > button.open-close > svg.close {
    display: none;
}

body > nav > button.open-close:hover {
    --color-svg: var(--color-focus);
}

/* MAIN */

body > main {
    grid-column: 2;
    grid-row: 2;
    overflow-x: hidden;
    overflow-y: auto;
    padding: calc(var(--open-close-size) + 10px) min(10px, 1%) min(80px, 20vh) min(10px, 1%);
    text-align: center;
}

body > main > .title:first-child {
    margin-top: 0;
}

@media screen and (max-width: 700px) {
    body {
        grid-template-rows: max-content max-content 1fr;
    }

    body > nav {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-bottom: 10px;
    }

    body > nav:not(.opened) {
        height: 0;
        overflow: visible;
        padding: 0;
    }

    body > nav > a {
        justify-content: center;
    }

    body > nav:not(.opened) > a {
        display: none;
    }

    body > nav > button.open-close {
        display: block;
    }

    body > nav.opened > button.open-close > svg.open {
        display: none;
    }

    body > nav.opened > button.open-close > svg.close {
        display: block;
    }

    body > main {
        grid-column: 1 / -1;
        grid-row: 3;
    }
}

@media screen and (max-width: 750px) {
    body > header > span.name {
        display: none;
    }
}

@media screen and (max-width: 500px) {
    body > header:has(> span.user) > span.app > span {
        display: none;
    }
}


/*****************************************/
/* INPUT                                 */
/*****************************************/

input:not([type="checkbox"]),
select {
    display: block;
    background-color: var(--color-background);
    border: 1px solid var(--color-gray-border);
    border-radius: var(--border-radius);
    color: var(--color-text);
    margin: 5px auto;
    padding: 2px 5px;
    text-align: center;
    width: 100%;
}

input[type=checkbox] {
    accent-color: var(--color-primary);
}

input[type=checkbox][inert] {
    accent-color: gray;
}

label {
    display: block;
    margin: 0 auto;
    text-align: left;
    width: 100%;
}

label + input:not([type="checkbox"]),
label + select {
    margin-top: 0;
}

label:not(.checkbox) {
    color: var(--label--color-text);
    font-size: smaller;
    padding-left: min(5%, 8px);
}

label.checkbox {
    width: max-content;
}

div.field-std {
    margin: auto;
    max-width: 100%;
    padding: 5px;
    width: var(--field-max-width);
}

a.button.std,
button.std {
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    margin: 5px;
    padding: 3px 6px;
}

a.button.std:hover,
button.std:hover {
    background: var(--color-primary);
    color: var(--color-text-on-primary);
}

div.field-std:has(+ a.button.std),
div.field-std:has(+ button.std) {
    margin-bottom: 15px;
}

div.field-std.checkbox {
    --columns-template: 1fr 3fr;

    display: grid;
    gap: 5px 10px;
    grid-template-columns: var(--columns-template);
}

div.field-std.checkbox > input[type="checkbox"] {
    grid-column: 1;
    margin: 0 0 0 auto;
}

div.field-std.checkbox > label {
    grid-column: 2;
    margin: 0 auto 0 0;
}


/*****************************************/
/* MESSAGE                               */
/*****************************************/

div.message-window > svg.icon {
    display: block;
    height: 60px;
    margin: 0 auto 20px auto;
    max-width: min(50vh, 100%);
    width: 60px;
}

div.message-window > span.title,
div.message-window > span.subtitle {
    display: block;
    margin: 0 auto 10px auto;
    text-align: center;
}

div.message-window > span.subtitle {
    font-size: larger;
}

div.message-window:has(> span.subtitle:not([hidden])) > span.title {
    margin-bottom: 0;
}

div.message-window > div.content {
    margin-bottom: 10px;
}

div.message-window > div.content > p {
    margin: 0 auto 0 0;
}

div.message-window > div.content > p + p {
    margin-top: 5px;
}

div.message-window > button.close {
    display: block;
    margin: 0 0 0 auto;
}


/*****************************************/
/* LOADING                               */
/*****************************************/

div.loading {
    --window-min-width: 150px;

    min-height: unset;
}

div.loading > div.loader {
    aspect-ratio: 1 / 1;
    border: 16px solid var(--color-primary);
    border-radius: 50%;
    border-top: 16px solid var(--color-focus);
    margin: 0 auto 20px auto;
    max-width: calc(100% - 20px);
    width: 80px;

    animation: loading-spin 2s linear infinite;
    -webkit-animation: loading-spin 2s linear infinite; /* Safari */
}


/* Safari */
@-webkit-keyframes loading-spin {
    0% {
        -webkit-transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
    }
}

@keyframes loading-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

div.window-background[hidden] > div.window.loading > div.loader {
    animation-play-state: paused;
}

div.loading > div.messages {
    display: grid;
    gap: 5px 10px;
    grid-template-columns: 1fr max-content;
}

div.loading > div.messages > span {
    grid-column: 1;
}

div.loading > div.messages > button {
    grid-column: 2;
}

/*****************************************/
/* PW REQUIREMENTS                       */
/*****************************************/

div.pw-requirements {
    display: block;
    margin: 20px auto;
    max-width: max-content;
    width: 100%;
}

div.password-requirements ul li {
    color: red;
}

div.password-requirements ul li::marker {
    color: red;
    content: "✕   ";
}

div.password-requirements ul li.ok {
    color: green;
}

div.password-requirements ul li.ok::marker {
    color: green;
    content: "✓   ";
}


/*****************************************/
/* PAGING                                */
/*****************************************/

div.pages-index {
    display: block;
    margin: 20px auto;
    min-width: min(100%, 100px);
    max-width: max-content;
    text-align: center;
    width: 100%;
}

div.pages-index button {
    border: none;
    color: var(--color-text);
    margin: 0;
    padding: 5px;
    vertical-align: middle;
}

div.pages-index select {
    display: inline-block;
    max-width: 100%;
    vertical-align: middle;
    width: 100px;
}

div.pages-index button:hover {
    color: var(--color-focus);
}

div.pages-index button.current {
    color: var(--color-focus);
    font-weight: bold;
}


/*****************************************/
/* NOT-AUTHORIZED PAGE                   */
/*****************************************/

svg.not-authorized {
    height: min(50vh, 100px);
    margin: 50px auto;
    width: 100%;
}

span.not-authorized {
    display: block;
    margin: 10px auto;
}

a.not-authorized {
    display: block;
    margin: 30px auto !important;
    width: max-content;
}