/* === Fonts === */
@font-face {
    font-family: 'Civil Premium';
    src: url('/assets/fonts/Civil Premium Regular.woff2') format('woff2'),
         url('/assets/fonts/Civil Premium Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Civil Premium';
    src: url('/assets/fonts/Civil Premium Medium.woff2') format('woff2'),
         url('/assets/fonts/Civil Premium Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Civil Premium';
    src: url('/assets/fonts/Civil Premium Bold.woff2') format('woff2'),
         url('/assets/fonts/Civil Premium Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* === Variables === */
:root {
    --color-primary: #00b199;
    --color-primary-dark: #009980;
    --color-primary-light: #cef9f5;
    --color-primary-mid: #e0f7f4;
    --color-bg: #f9f9f6;
    --color-surface: #ffffff;
    --color-text: var(--color-primary);
    --color-border: #e0e0e0;
    --color-warning: #f39c12;
    --color-error: #dc3545;
    --color-success: #27ae60;
    --nav-height: 5rem;
    --border-radius: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --content-padding: 4rem;
    --scrollbarBG: var(--color-bg);
    --thumbBG: var(--color-primary);
    --color-modal-border: rgba(0, 177, 153, 0.2);
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    font-family: 'Civil Premium', Arial, sans-serif;
    line-height: 1.3;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: var(--color-bg); }
*::-webkit-scrollbar-thumb { background-color: var(--color-primary); border-radius: 3px; }

body {
    color: var(--color-primary);
    background: var(--color-bg);
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Hidden === */
.hidden {
    display: none;
    visibility: hidden;
    height: 0;
    overflow: hidden;
}

/* === Navigation === */
nav {
    position: absolute;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    background: var(--color-primary);
    box-shadow: var(--shadow-md);
    z-index: 20;
}

.logo {
    position: absolute;
    top: 0.5rem;
    left: var(--content-padding);
    z-index: 10;
    padding-left: 10px;
    display: inline-block;
}

.logo-nav {
    display: block;
    height: calc(var(--nav-height) - 2rem);
}

.nav-user {
    position: absolute;
    bottom: 0.4rem;
    right: var(--content-padding);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: white;
    font-size: 0.9rem;
    opacity: 0.85;
}

.nav-user a { color: white; text-decoration: none; display: flex; align-items: center; }
.nav-user a:hover { text-decoration: none; }

.nav-user:hover { text-decoration: none; }

.nav-role {
    font-size: 0.75rem;
    opacity: 0.7;
    padding: 0.1rem 0.4rem;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 3px;
}

.nav-links {
    position: absolute;
    bottom: 0.4rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.7;
    text-decoration: none;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-bottom: 2px solid transparent;
    padding-bottom: 0.15rem;
}

a.nav-link:hover { opacity: 1; text-decoration: none; }

.nav-link-active {
    opacity: 1;
    border-bottom-color: white;
}

.nav-link-icon {
    width: 0.85em;
    height: 0.85em;
    color: white;
}

.nav-logout-icon {
    width: 1rem;
    height: 1rem;
    color: white;
    opacity: 0.85;
    cursor: pointer;
    transition: opacity 0.2s;
}

.nav-logout-icon:hover { opacity: 1; }

.nav-impersonate-icon {
    width: 1rem;
    height: 1rem;
    color: white;
    opacity: 0.85;
    cursor: pointer;
    transition: opacity 0.2s;
}

.nav-impersonate-icon:hover { opacity: 1; }

/* === Loading Ring === */
.lds-ring {
    display: inline-block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    z-index: 2000;
}

.lds-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 64px;
    height: 64px;
    margin: 8px;
    border: 8px solid var(--color-primary);
    border-radius: 50%;
    animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: var(--color-primary) transparent transparent transparent;
}

.lds-ring div:nth-child(1) { animation-delay: -0.45s; }
.lds-ring div:nth-child(2) { animation-delay: -0.3s; }
.lds-ring div:nth-child(3) { animation-delay: -0.15s; }

.lds-ring.hidden {
    display: none;
    visibility: hidden;
    height: 0;
    overflow: hidden;
}

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

/* === Backdrop === */
#backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 15;
}

#backdrop.hidden {
    display: none;
    visibility: hidden;
    height: 0;
    overflow: hidden;
}

/* === Toast === */
#toast {
    visibility: hidden;
    min-width: 250px;
    background: var(--color-primary);
    color: #ffffff;
    text-align: center;
    padding: 0.8rem 1.2rem;
    position: fixed;
    z-index: 400;
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

#toast.show {
    visibility: visible;
    animation: fadein 0.5s;
}

#toast.toast-err {
    background: var(--color-error);
}

.toast-icon {
    width: 16px;
    height: 16px;
    color: #ffffff;
    flex-shrink: 0;
}

@keyframes fadein {
    from { bottom: 0; opacity: 0; }
    to { bottom: 30px; opacity: 1; }
}

/* === Footer === */
footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3rem;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 1.5rem 1.5rem 0 0;
    z-index: 5;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === FAB / CTA === */
cta {
    position: fixed;
    display: block;
    margin: auto;
    background-color: var(--color-primary);
    width: 5rem;
    height: 5rem;
    z-index: 10;
    bottom: 0;
    border-radius: 50%;
    border: 0.25rem solid white;
    left: calc(50% - 2.5rem);
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s, box-shadow 0.2s;
}

cta:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(0,0,0,0.18);
}

cta icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    cursor: pointer;
}

cta icon svg,
cta icon svg.icon,
.fab-icon {
    width: 3.2rem;
    height: 3.2rem;
    color: white;
}

/* === Version String === */
version {
    position: absolute;
    display: block;
    font-size: 0.7rem;
    color: var(--color-primary);
    opacity: 0.6;
    bottom: 0.5rem;
    right: 0.5rem;
}

/* === Search === */
.search-wrap {
    position: relative;
    margin-bottom: 0.8rem;
}

.search-icon {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1rem;
    height: 1rem;
    pointer-events: none;
}

input[type=text].search-input {
    width: 100%;
    height: 2.4rem;
    border: 2px solid var(--color-primary);
    border-radius: 0 0 8px 8px;
    outline: none;
    padding: 0 2.2rem 0 2.2rem;
    font-size: 0.95rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    color: var(--color-primary);
    background: var(--color-surface);
    box-sizing: border-box;
}

input[type=text].search-input::placeholder {
    color: var(--color-primary);
    opacity: 0.4;
}

input[type=text].search-input:focus {
    box-shadow: 0 0 0 3px rgba(0,177,153,0.15);
    border-color: var(--color-primary);
}

.search-clear {
    position: absolute;
    right: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-primary);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    line-height: 1;
    transition: opacity 0.15s;
}

.search-clear:hover { opacity: 1; }

/* === Main Content === */
main {
    position: absolute;
    top: var(--nav-height);
    left: var(--content-padding);
    right: var(--content-padding);
    padding: 1rem;
    padding-bottom: 7rem;
    color: var(--color-primary);
}

main h1 {
    font-weight: 600;
    font-size: 1.6rem;
    color: var(--color-primary);
}

/* === List Table === */
.list-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.list-table thead th {
    text-align: left;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--color-primary);
    opacity: 0.7;
    padding: 0.6rem;
    color: var(--color-primary);
    user-select: none;
    white-space: nowrap;
}

.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 1.2rem;
}

.sortable:hover { opacity: 1; }

.sorted-asc::after {
    content: '\25B2';
    position: absolute;
    right: 0;
    font-size: 0.6rem;
}

.sorted-desc::after {
    content: '\25BC';
    position: absolute;
    right: 0;
    font-size: 0.6rem;
}

.list-table th,
.list-table td {
    vertical-align: top;
    padding: 0.6rem 0.5rem;
    white-space: normal;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-table td {
    border-bottom: 1px solid var(--color-border);
}

.list-table td:last-child {
    overflow: visible;
}

tr.row-highlight {
    cursor: pointer;
    transition: background-color 0.15s;
}

tr.row-highlight:hover {
    background-color: var(--color-primary-light) !important;
}

/* === Actions Column === */
.th-actions {
    text-align: right !important;
}

.th-actions .icon {
    vertical-align: middle;
    margin-left: 6px;
}

/* === Search/Filter Highlight === */
mark {
    background-color: #fff3b0;
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

html.dark mark {
    background-color: rgba(255, 243, 176, 0.25);
}

.text-match-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 0.4rem;
    color: var(--color-warning);
    opacity: 0.7;
    vertical-align: middle;
}

.text-match-badge .icon {
    width: 12px;
    height: 12px;
}

/* === Column Filters === */
.filter-row.filter-hidden { display: none; }

.filter-row th {
    padding: 0.3rem 0.5rem;
    border-bottom: none;
}

.filter-wrap {
    position: relative;
    display: block;
}

input[type=text].filter-input {
    width: 100%;
    height: 1.8rem;
    border: 1px solid var(--color-primary);
    border-radius: 0 0 6px 6px;
    outline: none;
    padding: 0 1.4rem 0 0.4rem;
    font-size: 0.8rem;
    color: var(--color-primary);
    box-sizing: border-box;
    background: var(--color-surface);
}

input[type=text].filter-input::placeholder {
    color: var(--color-primary);
    opacity: 0.4;
}

input[type=text].filter-input:focus {
    box-shadow: 0 0 0 2px rgba(0,177,153,0.15);
    border-color: var(--color-primary);
}

.filter-wrap .filter-clear {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-primary);
    cursor: pointer;
    opacity: 0.6;
    display: none;
    transition: opacity 0.15s;
    font-size: 0.9rem;
    line-height: 1;
}

.filter-wrap .filter-clear:hover { opacity: 1; }
.filter-wrap.has-value .filter-clear { display: block; }

html.dark input[type=text].filter-input {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--theme-color);
}

/* === Search Bar Animation === */
.search-bar {
    position: absolute;
    bottom: 2px;
    left: 2px;
    height: 5px;
    width: 0;
    background: var(--color-primary);
    opacity: 0.85;
    border-radius: 0 0 6px 6px;
    pointer-events: none;
}

.search-bar.animating {
    transition: width 1s linear;
    width: 0;
}

.search-wrap.has-value .search-clear { display: block; }

/* === Icon Row === */
.icon-row {
    display: flex;
    gap: 0.2rem;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.icon-row .icon {
    box-sizing: content-box;
    width: 1.1rem;
    height: 1.1rem;
    padding: 0.15rem;
    border-radius: 25%;
    transition: background-color 0.15s, transform 0.2s;
}

.icon-row .icon:hover {
    background-color: rgba(0,177,153,0.08);
}

/* === Row Count === */
.row-count {
    font-size: 0.85rem;
    color: var(--color-primary);
    opacity: 0.6;
    padding: 0.6rem 0;
}

/* === Status Badges === */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-icon {
    width: 0.85em;
    height: 0.85em;
    flex-shrink: 0;
}

.status-draft { background: #e2e3e5; color: #383d41; }
.status-processing { background: #fff3cd; color: #856404; }
.status-done { background: #d4edda; color: #155724; }
.status-error { background: #f8d7da; color: #721c24; }

/* === Detail Status Badges === */
.detail-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
}

.detail-status-draft { background: #e2e3e5; color: #383d41; }
.detail-status-processing { background: #fff3cd; color: #856404; }
.detail-status-done { background: #d4edda; color: #155724; }
.detail-status-error { background: #f8d7da; color: #721c24; }

/* === Buttons === */
.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.4rem;
    background: var(--color-primary);
    color: #ffffff;
    border: none;
    border-radius: 0 0 8px 8px;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.cta-button:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
    text-decoration: none;
}

.cta-button-secondary {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.cta-button-secondary:hover {
    background: var(--color-primary-light);
}

.cta-button-secondary .btn-icon {
    color: var(--color-primary);
}

.cta-button-danger {
    background: var(--color-error);
}

.cta-button-danger:hover {
    background: #c82333;
    transform: translateY(-1px);
}

/* === Button Icon === */
.btn-icon {
    width: 0.95rem;
    height: 0.95rem;
    display: block;
    transform: translateY(-0.05em);
}

/* === Form Actions === */
.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* === Edit Form === */
#edit-form {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: calc(var(--nav-height) + 2rem);
}

/* === Wizard Container === */
#wizard-container {
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem;
    width: 60rem;
    max-width: 90vw;
    max-height: calc(100vh - var(--nav-height) - 6rem);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

/* === Wizard Header === */
.wizard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.wizard-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* === Form Row === */
.form-row {
    margin-bottom: 1rem;
}

.form-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--color-primary);
}

/* === Input Wrap & Clear === */
.input-wrap {
    position: relative;
    display: block;
}

.input-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-primary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.input-clear:hover { opacity: 1; }

.input-wrap.has-value .input-clear {
    display: block;
}

.input-wrap .wizard-input {
    padding-right: 1.6rem;
}

/* === Wizard Input === */
.wizard-input {
    display: block;
    width: 100%;
    height: 2.2rem;
    border: 2px solid var(--color-primary);
    border-radius: 0 0 8px 8px;
    padding: 0 0.5rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-size: 0.9rem;
    color: var(--color-primary);
    background: var(--color-surface);
    outline: none;
    transition: box-shadow 0.2s ease;
}

.wizard-input:focus {
    box-shadow: 0 0 0 3px rgba(0,177,153,0.15);
}

.wizard-input::placeholder {
    color: var(--color-primary);
    opacity: 0.55;
}

/* === Wizard Textarea === */
.wizard-textarea {
    display: block;
    width: 100%;
    height: auto;
    min-height: 20rem;
    border: 2px solid var(--color-primary);
    border-radius: 0 0 8px 8px;
    padding: 0.4rem 0.5rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-size: 0.9rem;
    color: var(--color-primary);
    background: var(--color-surface);
    outline: none;
    resize: vertical;
    transition: box-shadow 0.2s ease;
}

.wizard-textarea:focus {
    box-shadow: 0 0 0 3px rgba(0,177,153,0.15);
}

.wizard-textarea::placeholder {
    color: var(--color-primary);
    opacity: 0.55;
}

/* === Entity Settings === */
.wizard-header-actions {
    display: flex;
    align-items: center;
    gap: 0;
}

.entity-settings {
    background: var(--color-primary-light);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
}

.entity-settings-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.6rem;
}

.redaction-mode {
    background: var(--color-primary-light);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
}

.redaction-mode-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.6rem;
}

.redaction-mode-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.6rem;
}

.redaction-mode-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.5);
    transition: border-color 0.1s ease, background 0.1s ease;
}

.redaction-mode-option:has(input:checked) {
    border-color: var(--color-primary);
    background: #fff;
}

.redaction-mode-option:has(input:disabled) {
    opacity: 0.45;
    cursor: not-allowed;
}

.redaction-mode-option input[type="radio"] {
    margin-top: 0.15rem;
    accent-color: var(--color-primary);
}

.redaction-mode-label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.redaction-mode-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
}

.redaction-mode-desc {
    font-size: 0.78rem;
    color: var(--color-text);
    opacity: 0.75;
    line-height: 1.3;
}

.entity-settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4rem 1rem;
}

.entity-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-primary);
}

.entity-checkbox input[type="checkbox"] {
    appearance: none;
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid var(--color-primary);
    border-radius: 3px;
    background: var(--color-surface);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.entity-checkbox input[type="checkbox"]:checked {
    background: var(--color-primary);
}

.entity-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 45%;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: translate(-50%, -55%) rotate(45deg);
}

.entity-checkbox-desc {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* === Upload Zone === */
.upload-zone {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.attachment-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border: 1px dashed var(--color-border);
    border-radius: 4px;
    background: var(--color-bg);
    color: var(--color-primary);
    font-size: 12px;
    cursor: pointer;
}

.attachment-upload-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.attachment-upload-btn .icon {
    width: 14px;
    height: 14px;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--color-primary);
    opacity: 0.5;
}

.upload-file-name {
    font-size: 0.85rem;
    color: var(--color-primary);
    font-weight: 600;
}

.wizard-textarea.drag-over {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(0,177,153,0.15);
}

/* === Searchable Combo === */
.combo-hidden { display: none; }

.combo-wrap { position: relative; display: block; }

input.combo-input {
    display: block;
    width: 100%;
    height: 2.2rem;
    border: 2px solid var(--color-primary);
    border-radius: 0 0 8px 8px;
    outline-color: var(--color-primary);
    padding: 0 2rem 0 0.5rem;
    font-size: 0.9rem;
    text-align: left;
    box-sizing: border-box;
    color: var(--color-primary);
    background-color: var(--color-surface);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300b199' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 1.2rem;
    cursor: pointer;
}

input.combo-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,177,153,0.15);
    border-color: var(--color-primary);
}

input.combo-input::placeholder {
    color: var(--color-primary);
    opacity: 0.55;
}

.combo-clear {
    position: absolute;
    right: 1.8rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    color: var(--color-primary);
    cursor: pointer;
    opacity: 0.5;
    z-index: 1;
}

.combo-clear:hover { opacity: 1; }

.combo-wrap.has-value .combo-clear { display: block; }

.combo-list {
    display: none;
    position: fixed;
    max-height: 14rem;
    overflow-y: auto;
    background: var(--color-surface);
    border: 2px solid var(--color-primary);
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 2000;
}

.combo-list.open { display: block; }

.combo-item {
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    color: var(--color-primary);
    cursor: pointer;
}

.combo-item:hover,
.combo-item.highlighted {
    background-color: var(--color-primary-light);
}

.combo-item.active {
    font-weight: 600;
    background-color: var(--color-primary-light);
}

/* === Detail Panel === */
#detail-panel {
    position: fixed;
    z-index: 250;
    left: 15%;
    width: 70%;
    top: calc(var(--nav-height) + 2rem);
    max-height: calc(100vh - var(--nav-height) - 6rem);
    overflow-y: auto;
}

/* === Detail Container === */
#detail-container {
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

/* === Detail Header === */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    padding: 1rem 1.5rem 0.8rem;
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 5;
}

.detail-header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    min-width: 0;
}

.detail-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* === Detail Meta Row === */
.detail-meta-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--color-primary);
    opacity: 0.7;
    margin-bottom: 1.25rem;
}

.detail-meta-sep { opacity: 0.4; }

.detail-meta-updated::before { content: '(upraveno '; }
.detail-meta-updated::after { content: ')'; }
.detail-meta-updated:empty { display: none; }

/* === Detail Info Grid === */
.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-info-grid.single {
    grid-template-columns: 1fr;
}

.detail-info-3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.detail-field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 0.2rem;
}

.detail-info-value {
    background: var(--color-primary-light);
    border: 2px solid var(--color-primary);
    border-radius: 0 0 8px 8px;
    padding: 0.4rem;
    min-height: 2.2rem;
    color: var(--color-primary);
    white-space: pre-line;
    font-size: 0.9rem;
}

/* === Detail Section Title === */
.detail-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 0.3rem;
    margin-top: 1.5rem;
    margin-bottom: 0.8rem;
}

/* === Summary Section === */
.summary-section {
    background: var(--color-primary-light);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
}

.summary-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--color-primary);
}

.summary-section-chevron {
    font-size: 0.85rem;
    color: var(--color-primary);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.summary-section.expanded .summary-section-chevron {
    transform: rotate(90deg);
}

.summary-section-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-primary);
}

.summary-section-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.summary-section.expanded .summary-section-body {
    max-height: 2000px;
    opacity: 1;
    margin-top: 0.8rem;
}

/* === Detail Text Content === */
.detail-text-content {
    background: var(--color-surface);
    border: 2px solid var(--color-primary);
    border-radius: 0 0 8px 8px;
    padding: 0.6rem 0.8rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-size: 0.9rem;
    color: var(--color-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
    max-height: 20rem;
    overflow-y: auto;
}

.detail-text-anon {
    border-left: 4px solid var(--color-success);
}

/* === Mapping / Entity Table === */
.mapping-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.mapping-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.8rem;
    border-bottom: 2px solid var(--color-primary);
    color: var(--color-primary);
    opacity: 0.7;
    font-weight: 600;
}

.mapping-table td {
    padding: 0.45rem 0.8rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    font-size: 0.9rem;
}

.mapping-table tr {
    cursor: pointer;
    transition: background-color 0.15s;
}

.mapping-table tbody tr:hover {
    background-color: var(--color-primary-light);
}

.mapping-table tbody tr.mapping-active {
    background-color: var(--color-primary-mid);
}

.mapping-table .mapping-original {
    color: var(--color-error);
    font-weight: 500;
}

.mapping-table .mapping-placeholder {
    color: var(--color-primary);
    font-weight: 600;
}

.mapping-table .mapping-type {
    color: var(--color-primary);
    opacity: 0.6;
    font-size: 0.8rem;
}

.mapping-table .mapping-pages {
    display: inline-block;
    margin-left: 0.4rem;
    color: var(--color-text);
    opacity: 0.55;
    font-size: 0.75rem;
    font-weight: 400;
}

/* === Text Highlights === */
.highlight-original {
    background-color: #f8d7da;
    border-radius: 2px;
    padding: 0 2px;
}

.highlight-placeholder {
    background-color: #d4edda;
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

/* === Mapping Table === */
.mapping-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.mapping-table thead th {
    text-align: left;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--color-primary);
    opacity: 0.7;
    border-bottom: 2px solid var(--color-primary);
    padding: 0.5rem;
    font-weight: 500;
}

.mapping-table tbody td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.mapping-table .old-value {
    background: #fff0f0;
}

.mapping-table .new-value {
    background: #f0fff0;
}

/* === Mini Modal === */
.mini-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.mini-modal-container {
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem;
    width: 30rem;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

modal-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.confirm-message {
    font-size: 0.95rem;
    color: var(--color-primary);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

/* === Download Options === */
.download-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.download-options .download-opt {
    justify-content: flex-start;
    width: 100%;
}

/* === Landing Page === */
.banner {
    display: block;
    width: 750px;
    max-width: 90%;
    margin-top: 10%;
    margin-left: auto;
    margin-right: auto;
}

.landing-buttons {
    position: absolute;
    bottom: 8%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.landing-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1.6rem;
    border-radius: 2rem;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.15s;
    cursor: pointer;
    min-width: 260px;
    justify-content: center;
}

.landing-btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.landing-btn-secondary {
    background-color: var(--color-surface);
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
}

.landing-btn-secondary:hover {
    background-color: #f0faf8;
}

.landing-btn-icon {
    height: 1.2em;
    width: auto;
    vertical-align: middle;
    flex-shrink: 0;
}

.landing-btn-secondary .landing-btn-icon {
    color: var(--color-primary);
}

.landing-footer {
    position: fixed;
    bottom: 1rem;
    right: 1.5rem;
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--color-primary);
    opacity: 0.6;
}

/* === Impersonate Modal === */
.impersonate-modal {
    position: absolute;
    top: var(--nav-height);
    right: var(--content-padding);
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 0 0 8px 8px;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 25;
    min-width: 20rem;
}

.impersonate-modal modal-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.impersonate-modal .form-actions {
    margin-top: 0.75rem;
}

/* === Icon Styles === */
svg.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.svg-theme { color: var(--color-primary); }
img.svg-theme { filter: invert(58%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(79%) contrast(103%); }
.svg-red { color: var(--color-error); }
.svg-green { color: var(--color-success); }
.svg-orange { color: var(--color-warning); }

.clickable {
    cursor: pointer;
    transition: transform 0.15s ease;
}

.clickable:hover {
    transform: scale(1.2);
}

svg.icon-button {
    width: 3rem;
    height: 3rem;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-primary);
}

/* === Stats Cards === */
.stats-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.stats-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.2rem;
}

.stats-card-wide {
    grid-column: 1 / -1;
}

.stats-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-primary);
    opacity: 0.7;
    margin-bottom: 0.8rem;
}

.stats-card-big {
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
}

.stats-status-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.stats-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.stats-count {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-primary);
}

.stats-bar-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.35rem;
}

.stats-bar-label {
    width: 8rem;
    flex-shrink: 0;
    font-size: 0.85rem;
    color: var(--color-primary);
    text-align: right;
}

.stats-bar-track {
    flex: 1;
    height: 1.2rem;
    background: var(--color-bg);
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}

.stats-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 0 0 4px 4px;
    min-width: 2px;
    transition: width 0.3s ease;
}

.stats-bar-value {
    width: 2.5rem;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
}

/* === Dark Mode Toggle === */
.dark-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.dark-toggle:hover { background: rgba(255,255,255,0.2); }

.dark-toggle-svg {
    color: white;
    opacity: 0.85;
    width: 16px;
    height: 16px;
}

.dark-toggle:hover .dark-toggle-svg { opacity: 1; }

.d-none { display: none !important; }

/* === Dark Mode === */
html.dark {
    --theme-color: #1dd1a1;
    --color-primary: #1dd1a1;
    --color-primary-dark: #17b891;
    --color-primary-light: rgba(29,209,161,0.12);
    --color-primary-mid: rgba(29,209,161,0.18);
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-text: #e0e0e0;
    --color-border: #2a2a4a;
    --color-warning: #ffb81c;
    --color-error: #ff6b6b;
    --color-success: #51cf66;
    --color-modal-border: rgba(29,209,161,0.25);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    color-scheme: dark;
}

html.dark body { color: var(--color-text); }

html.dark nav { background-color: #0f3460; }

html.dark #toast {
    background-color: var(--color-surface);
    color: var(--color-text);
}

html.dark .backdrop { background: rgba(0,0,0,0.4); }

html.dark .cta-button { background-color: var(--theme-color); }
html.dark .cta-button:hover { background-color: #17b891; }
html.dark .cta-button-secondary {
    background-color: var(--color-surface);
    color: var(--theme-color);
}
html.dark .cta-button-secondary:hover { background-color: var(--color-primary-light); }
html.dark .cta-button-secondary .btn-icon { color: var(--theme-color); }

html.dark .wizard-input,
html.dark .wizard-textarea,
html.dark input.combo-input {
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--theme-color);
}

html.dark .wizard-input::placeholder,
html.dark .wizard-textarea::placeholder,
html.dark input.combo-input::placeholder {
    color: var(--theme-color);
}

html.dark input.combo-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231dd1a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

html.dark .combo-list { background: var(--color-surface); }
html.dark .combo-item { color: var(--color-text); }
html.dark .combo-item:hover,
html.dark .combo-item.highlighted { background-color: var(--color-primary-light); }

html.dark .list-table thead th { color: var(--theme-color); border-bottom-color: var(--theme-color); }
html.dark .list-table td { border-bottom-color: var(--color-border); }
html.dark tr.row-highlight:hover { background-color: var(--color-primary-light) !important; }

html.dark .detail-info-value {
    background-color: var(--color-primary-light);
    color: var(--color-text);
    border-color: var(--theme-color);
}

html.dark .summary-section { background-color: var(--color-primary-light); }
html.dark .detail-text-content {
    background: var(--color-surface);
    border-color: var(--theme-color);
    color: var(--color-text);
}

html.dark .entity-settings { background: var(--color-primary-light); }
html.dark .redaction-mode { background: var(--color-primary-light); }
html.dark .redaction-mode-option { background: rgba(0,0,0,0.15); }
html.dark .redaction-mode-option:has(input:checked) { background: var(--color-surface); }
html.dark .entity-checkbox input[type="checkbox"] {
    background: var(--color-surface);
    border-color: var(--theme-color);
}
html.dark .entity-checkbox input[type="checkbox"]:checked { background: var(--theme-color); }

html.dark .status-badge.status-draft { background: rgba(255,255,255,0.1); color: #aaa; }
html.dark .status-badge.status-processing { background: rgba(255,184,28,0.15); color: #ffb81c; }
html.dark .status-badge.status-done { background: rgba(81,207,102,0.15); color: #51cf66; }
html.dark .status-badge.status-error { background: rgba(255,107,107,0.15); color: #ff6b6b; }

html.dark .detail-status-draft { background: rgba(255,255,255,0.1); color: #aaa; }
html.dark .detail-status-processing { background: rgba(255,184,28,0.15); color: #ffb81c; }
html.dark .detail-status-done { background: rgba(81,207,102,0.15); color: #51cf66; }
html.dark .detail-status-error { background: rgba(255,107,107,0.15); color: #ff6b6b; }

html.dark .mapping-table th { color: var(--theme-color); border-bottom-color: var(--theme-color); }
html.dark .mapping-table td { border-bottom-color: var(--color-border); }
html.dark .mapping-table .mapping-original { color: var(--color-error); }
html.dark .mapping-table .mapping-placeholder { color: var(--theme-color); }
html.dark .mapping-table tbody tr:hover { background-color: var(--color-primary-light); }
html.dark .mapping-table tbody tr.mapping-active { background-color: var(--color-primary-mid); }

html.dark .highlight-original { background-color: rgba(255,107,107,0.2); }
html.dark .highlight-placeholder { background-color: rgba(81,207,102,0.2); }

html.dark footer { background-color: rgba(22,33,62,0.9); }
html.dark cta { border-color: var(--color-surface); }

html.dark .mini-modal-container { background: var(--color-surface); }
html.dark .impersonate-modal { background: var(--color-surface); }

html.dark .search-input {
    background: var(--color-surface) !important;
    color: var(--color-text);
    border-color: var(--theme-color);
}

html.dark .upload-zone .attachment-upload-btn {
    background: var(--color-surface);
    border-color: var(--color-border);
}
html.dark .upload-zone .attachment-upload-btn:hover {
    background: var(--color-primary-light);
    border-color: var(--theme-color);
}

html.dark .landing-btn-secondary {
    background-color: var(--color-surface);
    color: var(--theme-color);
}

html.dark img.svg-theme {
    filter: invert(68%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(95%) contrast(90%) !important;
}

/* === Responsive === */
@media (max-width: 768px) {
    :root {
        --content-padding: 1rem;
    }

    main {
        left: 1rem;
        right: 1rem;
    }

    #detail-panel {
        left: 0;
        width: 100%;
    }

    #wizard-container {
        width: 100%;
        max-width: 100vw;
    }

    .form-actions {
        flex-direction: column;
    }

    .detail-info-grid {
        grid-template-columns: 1fr;
    }
}

/* === Portrait === */
@media (orientation: portrait) {
    :root {
        --content-padding: 2rem;
    }
}
