:root {
    --primary: #2387a8;
    --primary-deep: #16657e;
    --secondary: #f3f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-strong: #eef3f7;
    --body-bg: #f3f6f8;
    --body-fg: #1f2937;
    --muted: #6b7280;
    --line: #d6dee6;
    --line-soft: #e5ebf1;
    --shadow: 0 18px 40px rgba(148, 163, 184, 0.18);
    --success-bg: #edf8f1;
    --warning-bg: #fff6e6;
    --error-bg: #fdecec;
}

html {
    scroll-behavior: smooth;
}

body,
body.login {
    background:
        radial-gradient(circle at top right, rgba(125, 211, 252, 0.18), transparent 18%),
        linear-gradient(180deg, #f8fbfd 0%, #eef3f7 100%);
    color: var(--body-fg);
}

#container,
#container > .main {
    background: transparent;
}

a:link,
a:visited {
    color: var(--primary);
}

a:hover,
a:focus {
    color: var(--primary-deep);
}

#header {
    color: var(--body-fg);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(12px);
}

#branding,
#user-tools {
    position: relative;
    z-index: 1;
}

.brand-shell {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid #9dd6e6;
    border-radius: 12px;
    color: var(--primary-deep);
    font-weight: 700;
    letter-spacing: 0.06em;
    background: #dff3f8;
    box-shadow: inset 0 0 18px rgba(35, 135, 168, 0.08);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

#site-name {
    margin: 0;
}

#site-name a,
#site-name a:link,
#site-name a:visited {
    color: var(--body-fg);
}

.brand-entry {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    margin-left: auto;
    border-radius: 999px;
    border: 1px solid #b9dbe6;
    color: var(--primary-deep) !important;
    background: #eef8fb;
    font-size: 12px;
    font-weight: 600;
}

#user-tools,
#user-tools a:link,
#user-tools a:visited {
    color: var(--muted);
}

#user-tools a:hover,
#user-tools a:focus {
    color: var(--body-fg);
}

div.breadcrumbs {
    border-bottom: 1px solid var(--line);
    background: rgba(250, 251, 253, 0.9);
    color: var(--muted);
}

div.breadcrumbs a {
    color: #374151;
}

#main,
#content,
.dashboard #content,
#content-main,
.login #content-main {
    color: var(--body-fg);
}

#content {
    padding: 24px 24px 32px;
}

.module,
#changelist-filter,
.results,
.submit-row,
.login #content-main form,
.dashboard .module,
.inline-group,
div.form-row,
.selector,
.paginator,
#content-related,
fieldset.module,
.form-row {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.module,
.results,
.inline-group,
fieldset.module,
.dashboard .module {
    overflow: hidden;
}

.module h2,
.module caption,
.inline-group h2,
fieldset.module h2,
#changelist-filter h2,
.selector h2,
.calendar caption,
.calendarbox h2 {
    color: var(--body-fg);
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
}

.dashboard .module table,
.results table,
#result_list {
    border: 0;
    width: 100%;
}

.dashboard .module table td,
.dashboard .module table th,
.results td,
.results th {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.dashboard .module table tr:last-child td,
.dashboard .module table tr:last-child th,
.results table tr:last-child td,
.results table tr:last-child th {
    border-bottom: 0;
}

table thead th {
    color: #4b5563;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
}

table thead th,
table tbody td,
table tbody th {
    border-color: var(--line);
}

table thead th a,
table thead th .text a,
tbody tr a {
    color: var(--body-fg);
}

tbody tr:nth-child(odd),
tbody tr:nth-child(even) {
    background: #ffffff;
}

tbody tr:hover,
table tbody tr:hover {
    background: #f8fbfd;
}

#changelist-form .results,
#changelist .results {
    overflow-x: auto;
}

#changelist-search {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 0 0 16px;
}

#changelist-search input[type=text] {
    min-width: min(320px, 100%);
}

#changelist .actions {
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

#changelist-filter {
    padding-bottom: 10px;
}

#changelist-filter ul {
    padding: 10px 0;
}

#changelist-filter li.selected {
    border-left: 3px solid var(--primary);
    background: #f8fbfd;
}

#nav-sidebar {
    background: rgba(255, 255, 255, 0.88);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

#nav-sidebar .current-app .section,
#nav-sidebar .current-model {
    background: #eef8fb;
}

#toggle-nav-sidebar {
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
}

input,
textarea,
select,
.vTextField,
.vLargeTextField {
    color: var(--body-fg);
    border: 1px solid var(--line);
    background: #ffffff;
    border-radius: 10px;
    padding: 10px 12px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #8fc7d8;
    box-shadow: 0 0 0 3px rgba(35, 135, 168, 0.12);
}

textarea,
.vLargeTextField {
    min-height: 120px;
}

.button,
input[type=submit],
input[type=button],
.submit-row input,
a.button,
.object-tools a {
    color: #ffffff !important;
    border: 1px solid var(--primary);
    border-radius: 10px;
    background: var(--primary) !important;
    box-shadow: none;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.button.default,
input[type=submit].default,
.submit-row input.default {
    background: var(--primary) !important;
}

.button:hover,
input[type=submit]:hover,
input[type=button]:hover,
.submit-row input:hover,
a.button:hover,
.object-tools a:hover {
    color: #ffffff !important;
    background: var(--primary-deep) !important;
    border-color: var(--primary-deep);
    filter: none;
    transform: translateY(-1px);
}

.deletelink,
.button.deletelink,
a.deletelink {
    color: #ffffff !important;
    background: #b42318 !important;
    border-color: #b42318;
}

.deletelink:hover,
.button.deletelink:hover,
a.deletelink:hover {
    background: #912018 !important;
    border-color: #912018;
}

.object-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 16px;
}

.object-tools a:link,
.object-tools a:visited {
    color: #ffffff !important;
}

.submit-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
}

.submit-row input,
.submit-row a.deletelink {
    margin: 0;
}

.paginator {
    padding: 12px 16px;
}

.aligned .form-row,
div.form-row,
.form-row {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.aligned .form-row:last-child,
div.form-row:last-child,
.form-row:last-child {
    border-bottom: 0;
}

.fieldBox,
.aligned .fieldBox {
    float: none;
}

.help,
p.help,
form .help,
div.help,
div.help li {
    color: var(--muted);
}

.selector-available,
.selector-chosen {
    border-radius: 10px;
}

.selector select {
    min-height: 220px;
}

.calendar td.selected a,
.calendar td a:focus,
.timelist a:focus,
.calendar td a:hover,
.timelist a:hover {
    background: #e9f6fb;
}

.messagelist {
    margin-bottom: 18px;
}

.messagelist li {
    border: 1px solid var(--line);
    border-radius: 12px;
}

.messagelist li.success {
    background: var(--success-bg);
    border-color: #b8dfc2;
}

.messagelist li.warning {
    background: var(--warning-bg);
    border-color: #f0d199;
}

.messagelist li.error {
    background: var(--error-bg);
    border-color: #e7b2b2;
}

.login #container {
    width: min(440px, calc(100% - 24px));
    margin-top: 10vh;
}

.login #header {
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
}

.login #content {
    padding: 0;
}

.login #content-main form {
    padding: 28px;
    border-top: 0;
    border-radius: 0 0 20px 20px;
}

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

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

/* Custom admin home */
.admin-home-shell {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-hero,
.admin-panel,
.admin-kpi-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow);
}

.admin-hero,
.admin-panel {
    padding: 24px;
}

.admin-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
    gap: 20px;
}

.admin-overline {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.admin-hero h2,
.admin-panel h3,
.admin-module-card h4 {
    margin: 0;
    color: var(--body-fg);
}

.admin-hero p,
.admin-status-card p,
.admin-kpi-card p,
.admin-workflow-list,
.admin-module-title span {
    color: var(--muted);
    line-height: 1.7;
}

.admin-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.admin-primary-action,
.admin-secondary-action,
.admin-quick-list a,
.admin-add-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-weight: 600;
}

.admin-primary-action,
.admin-secondary-action {
    padding: 11px 16px;
}

.admin-primary-action {
    color: #ffffff !important;
    background: var(--primary);
}

.admin-secondary-action {
    color: var(--primary-deep) !important;
    border: 1px solid #b9dbe6;
    background: #eef8fb;
}

.admin-status-card,
.admin-status-grid article,
.admin-module-card,
.admin-kpi-card {
    padding: 16px 18px;
    background: var(--surface);
}

.admin-status-card strong,
.admin-status-grid strong,
.admin-kpi-card strong {
    display: block;
    margin-top: 6px;
    font-size: 20px;
    color: var(--body-fg);
}

.admin-status-grid,
.admin-kpi-grid,
.admin-section-grid,
.admin-module-grid {
    display: grid;
    gap: 16px;
}

.admin-status-grid {
    grid-template-columns: 1fr;
    margin-top: 16px;
}

.admin-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-kpi-card span,
.admin-status-card span,
.admin-status-grid span,
.admin-chip {
    color: var(--muted);
    font-size: 12px;
}

.admin-section-grid {
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.82fr);
}

.admin-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.admin-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #d7e6ed;
    background: #f7fbfd;
}

.admin-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-module-card {
    border: 1px solid var(--line-soft);
    border-radius: 18px;
}

.admin-module-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--line-soft);
}

.admin-module-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.admin-model-link {
    color: var(--body-fg) !important;
    font-weight: 600;
}

.admin-model-link.disabled {
    color: var(--muted) !important;
}

.admin-add-link {
    padding: 6px 10px;
    color: #ffffff !important;
    background: var(--primary);
    font-size: 12px;
}

.admin-side-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-quick-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-quick-list a {
    justify-content: flex-start;
    padding: 12px 14px;
    color: var(--body-fg) !important;
    border: 1px solid var(--line-soft);
    background: var(--surface-soft);
}

.admin-workflow-list {
    padding-left: 18px;
    margin: 0;
}

.admin-workflow-list li + li {
    margin-top: 10px;
}

.admin-app-table .app-analytics,
.admin-app-table .app-stocks,
.admin-app-table .app-trades,
.admin-app-table .app-cashflows,
.admin-app-table .app-portfolios,
.admin-app-table .app-quotes,
.admin-app-table .app-news,
.admin-app-table .app-recommendations {
    margin-bottom: 16px;
}

.admin-app-table .app-analytics:last-child,
.admin-app-table .app-stocks:last-child,
.admin-app-table .app-trades:last-child,
.admin-app-table .app-cashflows:last-child,
.admin-app-table .app-portfolios:last-child,
.admin-app-table .app-quotes:last-child,
.admin-app-table .app-news:last-child,
.admin-app-table .app-recommendations:last-child {
    margin-bottom: 0;
}

@media (max-width: 1200px) {
    .admin-hero,
    .admin-section-grid {
        grid-template-columns: 1fr;
    }

    .admin-kpi-grid,
    .admin-module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    #content {
        padding: 16px 12px 24px;
    }

    .brand-copy p {
        display: none;
    }

    .brand-entry {
        margin-left: 0;
    }

    .admin-kpi-grid,
    .admin-module-grid {
        grid-template-columns: 1fr;
    }

    .admin-panel-head,
    .admin-module-title,
    .admin-model-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .object-tools,
    .submit-row,
    #changelist-search {
        flex-direction: column;
        align-items: stretch;
    }

    .object-tools li {
        margin: 0;
    }

    #changelist-search input[type=text],
    .submit-row input {
        width: 100%;
    }

    .selector {
        overflow-x: auto;
    }
}
