/* App Theme Optimization */
:root {
    --navy: #0f172a;
    --blue: #0ea5e9;
    --teal: #10b981;
    --surface: #fff;
    --bg: #f3f6fb;
    --text: #172033;
    --muted: #64748b;
    --line: #e4eaf2;
}

body {
    font-family: Inter, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* Auth Shell / Guest */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at 15% 15%, rgba(14, 165, 233, .28), transparent 42%), linear-gradient(135deg, #0f172a, #0a4b78);
}
.auth-panel {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, .3);
}
.auth-hero {
    padding: 55px 44px;
    color: #fff;
    background: linear-gradient(145deg, #0ea5e9, #0f172a);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.auth-brand-logo {
    width: 84px;
    height: 108px;
    margin-bottom: 20px;
    padding: 5px;
    object-fit: contain;
    background: rgba(255, 255, 255, .96);
    border-radius: 10px;
}
.auth-brand-title {
    max-width: 430px;
    margin-bottom: 8px;
    font-size: 2rem;
    line-height: 1.18;
}
.auth-brand-subtitle {
    margin-bottom: 18px;
    color: rgba(255, 255, 255, .82);
    font-size: .88rem;
    font-weight: 600;
    letter-spacing: .04em;
}
.auth-card {
    padding: 55px 42px;
}
.form-control {
    min-height: 48px;
    border: 2px solid #e5e7eb;
    border-radius: 11px;
}
.btn-login {
    min-height: 48px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    color: white;
    font-weight: 700;
}
@media (max-width: 760px) {
    .auth-panel { grid-template-columns: 1fr; }
    .auth-hero { padding: 30px; }
    .auth-card { padding: 34px 25px; }
}

/* App Nav */
.app-nav {
    min-height: 72px;
    padding: 10px 0 !important;
    background: linear-gradient(110deg, #0f172a 0%, #103a5c 62%, #0b527c 100%);
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 7px 24px rgba(15, 23, 42, .16);
}
.app-nav .container-fluid {
    max-width: none;
    padding-left: 22px !important;
    padding-right: 22px !important;
}
.app-nav .navbar-brand {
    margin-right: 30px;
    color: #fff !important;
    font-size: 1.12rem;
    letter-spacing: -.01em;
}
.app-brand-logo {
    width: 36px;
    height: 46px;
    margin-right: 10px;
    padding: 2px;
    flex: 0 0 auto;
    object-fit: contain;
    background: rgba(255, 255, 255, .96);
    border-radius: 6px;
}
.app-nav .navbar-nav { gap: 6px; }
.app-nav .navbar-nav > .nav-item { flex-shrink: 0; }
.app-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 9px 14px !important;
    color: rgba(255, 255, 255, .82) !important;
    border-radius: 8px;
    font-size: .92rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background .18s ease, color .18s ease;
}
.app-nav .nav-link:hover, .app-nav .nav-link.active {
    color: #fff !important;
    background: rgba(255, 255, 255, .11);
}
.user-nav { margin-left: 12px; }
.app-nav .user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px !important;
    background: rgba(255, 255, 255, .09);
    border: 1px solid rgba(255, 255, 255, .16);
}
.app-nav .user-menu-toggle:hover, .app-nav .user-menu-toggle[aria-expanded=true] {
    background: rgba(255, 255, 255, .16);
}
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    color: #0f3b5d;
    background: #fff;
    border-radius: 9px;
}
.user-meta {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.15;
}
.user-name {
    max-width: 180px;
    overflow: hidden;
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-role {
    margin-top: 3px;
    color: rgba(255, 255, 255, .7);
    font-size: .68rem;
    font-weight: 500;
}
.user-nav .dropdown-toggle:after {
    margin-left: 4px;
    color: rgba(255, 255, 255, .7);
}

/* Dropdowns */
.user-dropdown {
    min-width: 230px;
    margin-top: 10px;
    padding: 8px;
    border: 0;
    border-radius: 11px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .2);
}
.user-dropdown-head { padding: 9px 11px; }
.user-dropdown-head strong {
    display: block;
    color: #0f172a;
    font-size: .86rem;
}
.user-dropdown-head span {
    display: block;
    margin-top: 3px;
    color: #64748b;
    font-size: .75rem;
}
.user-dropdown .dropdown-divider { margin: 6px 0; }
.user-dropdown .dropdown-item {
    padding: 9px 11px;
    color: #334155;
    border-radius: 7px;
    font-size: .84rem;
    font-weight: 600;
}
.user-dropdown .dropdown-item:hover {
    color: #dc2626;
    background: #fef2f2;
}

.settings-dropdown {
    min-width: 210px;
    margin-top: 10px;
    padding: 8px;
    border: 0;
    border-radius: 11px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .2);
}
.settings-dropdown .dropdown-item {
    padding: 10px 12px;
    color: #334155;
    border-radius: 7px;
    font-size: .86rem;
    font-weight: 600;
}
.settings-dropdown .dropdown-item i {
    width: 19px;
    color: #64748b;
    text-align: center;
}
.settings-dropdown .dropdown-item:hover, .settings-dropdown .dropdown-item.active {
    color: #0f3b5d;
    background: #eaf2fb;
}
.settings-dropdown .dropdown-item.active i { color: #2563eb; }

/* Content Wrap & Page Cards */
.content-wrap {
    max-width: 1450px;
    margin: auto;
    padding: 28px 22px;
}
.page-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 10px 35px rgba(15, 23, 42, .06);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.page-card:hover {
    box-shadow: 0 15px 45px rgba(15, 23, 42, .09);
}

/* UI Elements */
.btn-brand {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), #2563eb);
    border: 0;
    border-radius: 10px;
    font-weight: 700;
    padding: .65rem 1rem;
    transition: all 0.25s ease;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}
.btn-brand:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.25);
}
.form-control, .custom-select {
    border: 1px solid #d9e1ec;
    border-radius: 9px;
    min-height: 43px;
}
.form-control:focus, .custom-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 .2rem rgba(14, 165, 233, .12);
}
.section-title {
    font-size: 1rem;
    font-weight: 800;
    color: #0f3b5d;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
    margin: 4px 0 18px;
}
.required:after {
    content: " *";
    color: #e11d48;
}
.stat { border-left: 4px solid var(--blue); }
.muted { color: var(--muted); }
.table thead th {
    border-top: 0;
    background: #f8fafc;
    color: #475569;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* Date Picker */
.us-date-picker-wrap { position: relative; }
.us-date-picker-wrap > .us-date-input { border-radius: 9px 0 0 9px !important; }
.us-date-picker-button {
    display: flex;
    width: 43px;
    align-items: center;
    justify-content: center;
    color: #475569;
    background: transparent;
    border: 1px solid #d9e1ec;
    border-left: 0;
    border-radius: 0 9px 9px 0;
    cursor: pointer;
}
.us-date-picker-button:hover, .us-date-picker-button:focus {
    color: #2563eb;
    background: #eff6ff;
    outline: 0;
}
.us-date-picker-button:disabled {
    color: #94a3b8;
    background: #f1f5f9;
    cursor: not-allowed;
}
.us-date-picker-native {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Select2 Customizations */
.select2-container--default .select2-selection--single { position: relative; }
.select2-container--default .select2-selection--single .select2-selection__rendered { padding-right: 62px; }
.select2-container--default .select2-selection--single .select2-selection__clear {
    position: absolute !important;
    top: 50% !important;
    right: 26px !important;
    z-index: 4 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    float: none !important;
    width: 28px !important;
    height: 32px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    transform: translateY(-50%);
    cursor: pointer;
}
.select2-container--default .select2-selection--single .select2-selection__clear > span,
.select2-container--default .select2-selection--multiple .select2-selection__clear > span,
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove > span {
    display: block;
    line-height: 1;
    pointer-events: none;
}
.select2-container--default .select2-selection--multiple.select2-selection--clearable { padding-right: 38px; }
.select2-container--default .select2-selection--multiple .select2-selection__clear {
    top: 4px !important;
    right: 4px !important;
    z-index: 4 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 28px !important;
    height: 28px !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    cursor: pointer;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice { padding-left: 27px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 100%;
    padding: 0 !important;
    line-height: 1;
    cursor: pointer;
}

/* Party Selected Template */
.party-option-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 14px;
    align-items: center;
    padding: 4px 2px;
}
.party-option-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
}
.party-option-label {
    color: #94a3b8;
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .05em;
    line-height: 1.15;
    text-transform: uppercase;
}
.party-option-value {
    overflow: hidden;
    color: #334155;
    font-size: .84rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.party-selected-content {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 5px;
    overflow: hidden;
    white-space: nowrap;
}
.party-selected-content .party-option-label { flex: 0 0 auto; }
.party-selected-content .party-option-value { font-weight: 500; }
.party-selected-divider { margin: 0 5px; color: #cbd5e1; }

/* Case History */
.case-history-list { position: relative; }
.case-history-entry {
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 13px;
    padding-bottom: 18px;
}
.case-history-entry:not(:last-child):before {
    position: absolute;
    top: 34px;
    bottom: -4px;
    left: 17px;
    width: 2px;
    background: #dbe5ef;
    content: "";
}
.case-history-marker {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: #fff;
    border: 4px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #dbe5ef;
    font-size: .67rem;
}
.case-history-card {
    min-width: 0;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    box-shadow: 0 5px 18px rgba(15, 23, 42, .045);
}
.case-history-date {
    color: #334155;
    font-size: .8rem;
    font-weight: 600;
}
.case-history-changes { table-layout: fixed; }
.case-history-changes th {
    width: 25%;
    font-size: .72rem;
}
.case-history-changes td {
    overflow-wrap: anywhere;
    color: #475569;
    font-size: .8rem;
    white-space: pre-wrap;
}
.case-history-changes .history-old-value {
    color: #9f1239;
    background: #fff7f8;
}
.case-history-changes .history-new-value {
    color: #166534;
    background: #f5fcf7;
}

/* Tabs */
.case-detail-tabs {
    margin-bottom: 20px;
    border-bottom-color: #dbe5ef;
}
.case-detail-tabs .nav-link {
    color: #64748b;
    font-weight: 700;
}
.case-detail-tabs .nav-link.active {
    color: #2563eb;
    border-top: 2px solid #2563eb;
}

/* Case Register & Export */
.register-table-scroll {
    max-height: 520px;
    overflow-y: auto;
    scrollbar-gutter: stable;
}
.register-table-scroll .table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 #dfe5ee;
}
.export-modal .modal-content { border: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 24px 70px rgba(15, 23, 42, .24); }
.export-modal .modal-header { color: #fff; background: linear-gradient(115deg, #0f3b5d, #2563eb); border: 0; padding: 20px 24px; }
.export-modal .modal-header .modal-title { color: #fff !important; font-weight: 700 !important; line-height: 1.3; }
.export-modal .modal-header .modal-title i { color: #fff; }
.export-modal .modal-header .export-subtitle { color: #fff !important; opacity: .88; font-weight: 400; }
.export-modal .modal-header .close { color: #fff; text-shadow: none; opacity: .85; }
.export-modal .modal-body { max-height: 62vh; overflow-y: auto; padding: 22px 24px; background: #f8fafc; }
.export-field-group { height: 100%; padding: 16px; background: #fff; border: 1px solid #e2e8f0; border-radius: 11px; }
.export-field-group h6 { color: #0f3b5d; font-weight: 800; border-bottom: 1px solid #e8edf4; padding-bottom: 9px; margin-bottom: 12px; }
.export-field-group .custom-control { margin-bottom: 9px; }
.export-field-group .custom-control-label { color: #334155; font-size: .88rem; line-height: 1.45; }
.export-modal .modal-footer { padding: 15px 24px; border-top: 1px solid #e2e8f0; }
.register-case-reference { display: inline-flex; align-items: center; margin-bottom: 5px; padding: 3px 8px; color: #0f3b5d; background: #eaf2fb; border: 1px solid #c8dced; border-radius: 6px; font-size: .72rem; font-weight: 800; letter-spacing: .04em; }
.case-register-table { min-width: 1200px; table-layout: fixed; }
.case-register-table th, .case-register-table td { padding: .72rem .55rem; vertical-align: middle; }
.case-register-table tbody td { color: #243047; font-size: .84rem; line-height: 1.35; }
.case-register-table .case-select-column { width: 38px; text-align: center; }
.case-register-table .case-number-column { width: 42px; text-align: center; }
.case-register-table .case-identity-column { width: 220px; }
.case-register-table .case-title-column { width: 250px; }
.case-register-table .case-document-column { width: 110px; }
.case-register-table .case-status-column { width: 165px; }
.case-register-table .case-creator-column { width: 160px; }
.case-register-table .case-date-column { width: 112px; }
.case-register-table .case-actions-column { width: 158px; text-align: right; }
.case-register-table .case-court-number { display: block; overflow: hidden; font-size: .86rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.case-register-table .case-party-summary { display: block; overflow: hidden; margin-top: 4px; color: #64748b; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.case-register-table .case-title-text { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.case-register-table .badge { max-width: 100%; font-size: .68rem; white-space: normal; }
.case-register-table .case-action-button { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; padding: 0; }
.case-filter-grid { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)) auto; gap: 14px; align-items: end; }
.case-filter-grid .form-group { min-width: 0; margin-bottom: 16px; }
.case-filter-actions { display: flex; gap: 8px; margin-bottom: 16px; white-space: nowrap; }
.case-filter-actions .btn { margin: 0 !important; }

/* Responsive adjustments */
@media (min-width: 1200px) and (max-width: 1599px) {
    .app-nav .container-fluid { max-width: none; padding-right: 14px !important; padding-left: 14px !important; }
    .app-nav .navbar-brand { margin-right: 14px; font-size: .98rem; }
    .app-nav .navbar-nav { gap: 2px; }
    .app-nav .nav-link { padding-right: 9px !important; padding-left: 9px !important; font-size: .84rem; }
    .app-nav .nav-link > i { margin-right: 6px !important; }
    .user-nav { margin-left: 4px; }
    .app-nav .user-menu-toggle { gap: 7px; padding: 6px 8px !important; }
    .user-avatar { width: 30px; height: 30px; flex-basis: 30px; }
    .user-name { max-width: 110px; font-size: .76rem; }
    .user-role { font-size: .62rem; }
}
@media (max-width: 1199px) {
    .app-nav .container-fluid { padding-left: 16px !important; padding-right: 16px !important; }
    .app-nav .navbar-collapse { padding-top: 12px; }
    .app-nav .navbar-nav { align-items: stretch !important; gap: 3px; }
    .app-nav .navbar-brand { margin-right: 10px; font-size: 1rem; }
    .user-nav { margin: 8px 0 0; }
    .app-nav .user-menu-toggle { justify-content: flex-start; }
    .user-dropdown, .settings-dropdown { margin-top: 4px; }
    .user-name { max-width: none; }
    .case-register-table { min-width: 1060px; }
    .case-register-table .case-title-column { width: 210px; }
    .case-register-table .case-identity-column { width: 205px; }
    .case-filter-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
    .case-filter-actions { justify-content: flex-start; }
}
@media (max-width: 991px) {
    .app-nav .navbar-brand { font-size: .94rem; }
}
@media (max-width: 767px) {
    .content-wrap { padding: 18px 12px; }
    .register-table-scroll { max-height: 65vh; }
    .case-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .case-filter-actions { grid-column: 1 / -1; }
}
@media (max-width: 479px) {
    .case-filter-grid { grid-template-columns: 1fr; }
}
