/* Portscope dark theme: shared contrast and surface rules. */
body.theme-midnight {
    --page: #07151e;
    --white: #112a36;
    --ink: #f2f7f9;
    --muted: #a9bbc3;
    --line: #2b4652;
    --shadow: 0 14px 38px rgba(0, 0, 0, .24);
    background: var(--page);
    color: var(--ink);
    color-scheme: dark;
}

body.theme-midnight .app-main,
body.theme-midnight .app-content {
    background: var(--page);
}

body.theme-midnight .app-content > form.settings-form {
    max-width: none;
    padding: 0;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.theme-midnight .app-topbar {
    background: rgba(9, 28, 38, .96);
    border-color: var(--line);
    color: var(--ink);
}

body.theme-midnight .topbar-context strong,
body.theme-midnight .page-heading h1,
body.theme-midnight .section-head h2,
body.theme-midnight .surface-card h2,
body.theme-midnight .surface-card h3,
body.theme-midnight .surface-card h4,
body.theme-midnight .form-section h2,
body.theme-midnight .form-section h3,
body.theme-midnight .empty-state strong,
body.theme-midnight .operation-main strong,
body.theme-midnight .operation-time strong,
body.theme-midnight .entity-cell strong,
body.theme-midnight .user-cell strong,
body.theme-midnight .task-item strong,
body.theme-midnight .overview-item-list strong,
body.theme-midnight .cargo-facts strong,
body.theme-midnight .info-card dd {
    color: var(--ink);
}

body.theme-midnight .page-heading p,
body.theme-midnight .muted,
body.theme-midnight .field small,
body.theme-midnight .form-hint,
body.theme-midnight .help-text,
body.theme-midnight .operation-main span,
body.theme-midnight .operation-time span,
body.theme-midnight .entity-cell small,
body.theme-midnight .user-cell small,
body.theme-midnight .overview-item-list small,
body.theme-midnight .task-item p,
body.theme-midnight .task-meta,
body.theme-midnight .timeline-meta span,
body.theme-midnight .timeline-content > span,
body.theme-midnight .cargo-facts small,
body.theme-midnight .finance-stat small,
body.theme-midnight .finance-overview small,
body.theme-midnight .finance-summary-mini small,
body.theme-midnight .info-card dt {
    color: var(--muted) !important;
}

body.theme-midnight .surface-card,
body.theme-midnight .metric-card,
body.theme-midnight .filter-bar,
body.theme-midnight .settings-card,
body.theme-midnight .form-section,
body.theme-midnight .operation-form-nav,
body.theme-midnight .finance-overview article,
body.theme-midnight .task-item,
body.theme-midnight .document-item,
body.theme-midnight .item-card,
body.theme-midnight .card-form,
body.theme-midnight .legacy-card,
body.theme-midnight .card {
    background: #112a36;
    border-color: var(--line);
    color: var(--ink);
}

body.theme-midnight .section-head,
body.theme-midnight .app-table th,
body.theme-midnight .app-table td,
body.theme-midnight .operation-row,
body.theme-midnight .info-card dl div,
body.theme-midnight .cargo-notes,
body.theme-midnight .finance-form,
body.theme-midnight .finance-summary-mini,
body.theme-midnight .overview-item-list article,
body.theme-midnight .task-item,
body.theme-midnight .document-item,
body.theme-midnight .form-section-head {
    border-color: var(--line) !important;
}

body.theme-midnight .filter-bar,
body.theme-midnight .finance-strip,
body.theme-midnight .finance-summary-mini,
body.theme-midnight .cargo-notes,
body.theme-midnight .timeline-content,
body.theme-midnight .item-card-header,
body.theme-midnight .field-info,
body.theme-midnight .operation-form-nav,
body.theme-midnight .settings-tabs,
body.theme-midnight .subnav,
body.theme-midnight .segmented,
body.theme-midnight .operation-tabs {
    background: #0d2531;
    color: var(--ink);
}

body.theme-midnight .finance-strip {
    border-color: var(--line);
}

body.theme-midnight .finance-strip h2,
body.theme-midnight .finance-strip strong:not(.text-income):not(.text-expense) {
    color: var(--ink);
}

body.theme-midnight .field > span,
body.theme-midnight .form-group > label,
body.theme-midnight .form-label,
body.theme-midnight label.control-label,
body.theme-midnight .filter-label {
    color: #c7d5da !important;
}

body.theme-midnight input,
body.theme-midnight select,
body.theme-midnight textarea,
body.theme-midnight .field input,
body.theme-midnight .field select,
body.theme-midnight .field textarea,
body.theme-midnight .filter-bar input,
body.theme-midnight .filter-bar select,
body.theme-midnight .live-select > input,
body.theme-midnight .mini-select,
body.theme-midnight .form-control,
body.theme-midnight .form-select {
    background-color: #0a202b !important;
    border-color: #35515d !important;
    color: #f5f9fa !important;
}

body.theme-midnight input::placeholder,
body.theme-midnight textarea::placeholder,
body.theme-midnight .live-select > input::placeholder {
    color: #8298a2 !important;
    opacity: 1;
}

body.theme-midnight input:focus,
body.theme-midnight select:focus,
body.theme-midnight textarea:focus,
body.theme-midnight .live-select > input:focus {
    border-color: #45b8ad !important;
    box-shadow: 0 0 0 3px rgba(69, 184, 173, .18) !important;
}

body.theme-midnight select option {
    background: #0a202b;
    color: #f5f9fa;
}

body.theme-midnight input[type="date"]::-webkit-calendar-picker-indicator,
body.theme-midnight input[type="datetime-local"]::-webkit-calendar-picker-indicator,
body.theme-midnight input[type="time"]::-webkit-calendar-picker-indicator {
    filter: none;
    opacity: .82;
}

body.theme-midnight .live-select-list,
body.theme-midnight .live-select-option {
    background: #102a36 !important;
    border-color: var(--line) !important;
    color: var(--ink) !important;
}

body.theme-midnight .live-select-option:hover,
body.theme-midnight .live-select-option.is-active,
body.theme-midnight .live-select-create:hover {
    background: #193946 !important;
    color: #ffffff !important;
}

body.theme-midnight .live-select-create {
    background: #12313b !important;
    border-color: var(--line) !important;
    color: #63d1c5 !important;
}

body.theme-midnight .app-table th {
    background: #0b222d;
    color: #b8c8ce;
}

body.theme-midnight .app-table td {
    background: #112a36;
    color: var(--ink);
}

body.theme-midnight .app-table tbody tr:hover td,
body.theme-midnight .operation-row:hover {
    background: #17343f;
}

body.theme-midnight .table-primary,
body.theme-midnight .entity-cell,
body.theme-midnight .sort-link,
body.theme-midnight .row-action,
body.theme-midnight .text-button {
    color: #eaf4f6;
}

body.theme-midnight .row-action,
body.theme-midnight .secondary-button,
body.theme-midnight .icon-button,
body.theme-midnight .language-switcher,
body.theme-midnight .per-page-select select {
    background: #173440;
    border-color: #36535f;
    color: #eef7f8;
}

body.theme-midnight .row-action:hover,
body.theme-midnight .secondary-button:hover,
body.theme-midnight .icon-button:hover {
    background: #204653;
    color: #ffffff;
}

body.theme-midnight .icon-button.danger,
body.theme-midnight .row-action.danger {
    background: rgba(239, 114, 95, .13);
    border-color: rgba(239, 114, 95, .42);
    color: #ff9c8d;
}

body.theme-midnight .entity-icon,
body.theme-midnight .user-avatar,
body.theme-midnight .person b,
body.theme-midnight .vessel-avatar,
body.theme-midnight .document-icon,
body.theme-midnight .metric-icon.navy {
    background: #1a3a47;
    color: #dcecef;
}

body.theme-midnight .metric-icon.coral { background: rgba(239, 114, 95, .16); }
body.theme-midnight .metric-icon.teal { background: rgba(46, 156, 145, .18); }
body.theme-midnight .metric-icon.sand { background: rgba(232, 199, 125, .14); color: #f0cf84; }

body.theme-midnight .tag-chip,
body.theme-midnight .role-badge,
body.theme-midnight .permission-preview span,
body.theme-midnight .count-link,
body.theme-midnight .count-badge,
body.theme-midnight .step-badge,
body.theme-midnight .operation-tab-count,
body.theme-midnight .operation-tabs .tab-count {
    background: #1b3b47;
    border-color: #36535f;
    color: #dce9ed;
}

body.theme-midnight .status-pill {
    background: color-mix(in srgb, var(--status-color) 22%, #102a36);
    border: 1px solid color-mix(in srgb, var(--status-color) 40%, #36535f);
    color: color-mix(in srgb, var(--status-color) 42%, #ffffff);
}

body.theme-midnight .direction-pill.loading,
body.theme-midnight .direction-pill.income {
    background: rgba(46, 156, 145, .2);
    color: #77d7cd;
}

body.theme-midnight .direction-pill.discharge,
body.theme-midnight .direction-pill.expense {
    background: rgba(239, 114, 95, .18);
    color: #ffa395;
}

body.theme-midnight .direction-pill.service,
body.theme-midnight .payment-pill {
    background: rgba(117, 146, 214, .18);
    color: #b8c9f4;
}

body.theme-midnight .operation-tabs a,
body.theme-midnight .operation-tabs button,
body.theme-midnight .settings-tabs a,
body.theme-midnight .subnav a,
body.theme-midnight .operation-form-nav a {
    color: #afc1c8;
}

body.theme-midnight .operation-tabs a:hover,
body.theme-midnight .operation-tabs button:hover,
body.theme-midnight .settings-tabs a:hover,
body.theme-midnight .subnav a:hover,
body.theme-midnight .operation-form-nav a:hover {
    background: #193b47;
    color: #ffffff;
}

body.theme-midnight .operation-tabs .active,
body.theme-midnight .settings-tabs .active,
body.theme-midnight .subnav .active,
body.theme-midnight .operation-form-nav .active {
    background: var(--teal);
    color: #ffffff;
}

body.theme-midnight .operation-form-progress,
body.theme-midnight .progress-track {
    background: #28434f;
}

body.theme-midnight .segmented input:checked + span {
    background: #1b3e4a;
    color: #6ad2c6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

body.theme-midnight .timeline-item::before {
    background: #34515d;
}

body.theme-midnight .timeline-content p {
    color: #b8c7cc;
}

body.theme-midnight .cargo-notes p {
    color: #b4c4ca;
}

body.theme-midnight .operation-detail-head {
    background: #0a202b;
    border-color: var(--line);
}

body.theme-midnight .operation-detail-head p,
body.theme-midnight .operation-detail-head .operation-meta {
    color: #afc0c7;
}

body.theme-midnight .task-item.overdue {
    background: rgba(239, 114, 95, .09);
    border-color: rgba(239, 114, 95, .4) !important;
}

body.theme-midnight .warning-text {
    color: #f1c56f;
}

body.theme-midnight .app-alert-success {
    background: #10372f;
    border-color: #2f7467;
    color: #a6eadc;
}

body.theme-midnight .app-alert-danger {
    background: #3b2022;
    border-color: #754045;
    color: #ffc0b8;
}

body.theme-midnight .pagination-wrap,
body.theme-midnight .pagination,
body.theme-midnight .page-link {
    border-color: var(--line);
}

body.theme-midnight .page-link {
    background: #112a36;
    color: #dce9ed;
}

body.theme-midnight .page-item.active .page-link {
    background: var(--teal);
    border-color: var(--teal);
    color: #ffffff;
}

body.theme-midnight :focus-visible {
    outline-color: #59c9bd;
}
