@font-face {
    font-family: 'Civil Premium';
    src: url('../fonts/Civil Premium Regular.woff2') format('woff2'),
         url('../fonts/Civil Premium Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Civil Premium';
    src: url('../fonts/Civil Premium Medium.woff2') format('woff2'),
         url('../fonts/Civil Premium Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Civil Premium';
    src: url('../fonts/Civil Premium Bold.woff2') format('woff2'),
         url('../fonts/Civil Premium Bold.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --theme-color: #00b199;
    --theme-color-light: #cef9f5;
    --theme-color-mid: #e0f7f4;
    --nav-height: 5rem;
    --content-padding: 4rem;
    --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);
    --radius: 8px;
    --color-border: #e0e0e0;
    --color-warning: #f39c12;
    --color-error: #dc3545;
    --color-success: #27ae60;
    --color-bg: #f9f9f6;
    --color-surface: #ffffff;
    --color-text: #00b199;
    --color-text-secondary: #4dbfae;
    --color-input-bg: #ffffff;
    --color-hover-bg: rgba(0,177,153,0.08);
    --color-modal-border: rgba(0,177,153,0.2);
    --color-table-border: #eee;
    --color-other-month: #f5f5f2;
    --color-other-month-text: #bbb;
    --color-cal-record-text: var(--theme-color);
    --color-bar-track: #f0f0ed;
    --color-diff-old-bg: #fff0f0;
    --color-diff-new-bg: #f0fff0;
    --color-muted: #66cdb9;
    --color-scheme: light;
}

@media screen and (orientation: landscape) {
    :root {
        --content-padding: 4rem;
    }
}

@media screen and (orientation: portrait) {
    :root {
        --content-padding: 2rem;
    }
}

* {
    margin: 0;
    padding: 0;
    --foreground-text: var(--color-text);
    --background-color: var(--color-bg);
    font-family: 'Civil Premium', Arial, sans-serif;
    line-height: 1.3;
}

html {
    font-size: 14px;
}

html, body {
    min-height: 100% !important;
    height: 100%;
    width: 100%;
    overflow: auto;
    color: var(--foreground-text);
}

/* Themed scrollbars — all scrollable elements */
*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--theme-color);
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: #009e88;
}

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

/* Text selection */
::selection {
    background-color: var(--theme-color);
    color: #fff;
}

nav {
    position: absolute;
    display: block;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    background-color: var(--theme-color);
    box-shadow: var(--shadow-md);
    z-index: 20;
}

footer {
    display: block;
    width: 100%;
    height: 4rem;
    background-color: var(--theme-color-light);
}

content {
    position: absolute;
    top: var(--nav-height);
    display: block;
    left: var(--content-padding);
    padding: 1rem;
    padding-bottom: 7rem;
    width: calc(100% - var(--content-padding) * 2);
}

.logo {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    left: calc(var(--content-padding) + 1rem);
    display: inline-block;
}

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

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

.nav-user a {
    display: flex;
    align-items: center;
}

.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-login-link {
    color: white;
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-login-link:hover {
    opacity: 1;
}

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

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

.nav-toolbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.nav-toolbar-icon:hover {
    background: rgba(255,255,255,0.2);
}

.nav-toolbar-icon.active {
    background: rgba(255,255,255,0.25);
}

.nav-toolbar-svg {
    color: white;
    opacity: 0.85;
}

.nav-toolbar-icon:hover .nav-toolbar-svg {
    opacity: 1;
}

.nav-separator {
    width: 1px;
    height: 1rem;
    background: rgba(255,255,255,0.3);
    margin: 0 0.2rem;
}

.nav-link-placeholder {
    opacity: 0.5;
    cursor: default;
    font-style: italic;
}

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

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

.impersonate-modal {
    position: absolute;
    top: calc(var(--nav-height) - 0.4rem);
    right: var(--content-padding);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 25;
    width: 20rem;
}

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

.impersonate-modal .inter-input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.6rem;
}

.impersonate-modal .form-actions {
    justify-content: flex-end;
}

.impersonate-modal .icon-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.nav-links {
    position: absolute;
    bottom: 0.4rem;
    left: calc(var(--content-padding) + 7rem);
    right: 16rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.nav-link {
    color: white;
    font-size: 0.85rem;
    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 {
    height: 0.85em;
    width: auto;
    color: white;
}

/* Navigation dropdown menus */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-chevron {
    height: 0.65em;
    width: auto;
    color: white;
    margin-left: -0.1rem;
    transition: transform 0.2s;
}

.nav-dropdown:hover .nav-chevron {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 0.35rem 0;
    min-width: 10rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 30;
}

.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -0.35rem;
    left: 0;
    right: 0;
    height: 0.35rem;
}

.nav-dropdown:hover .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--theme-color);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.nav-dropdown-item .nav-link-icon {
    color: var(--theme-color);
    opacity: 0.6;
}

.nav-dropdown-item:hover {
    background: var(--theme-color-light);
    text-decoration: none;
}

.nav-dropdown-item:hover .nav-link-icon {
    opacity: 1;
}

.nav-dropdown-item-active {
    color: var(--theme-color);
    background: var(--theme-color-light);
}

.nav-dropdown-item-active .nav-link-icon {
    color: var(--theme-color);
    opacity: 1;
}

.landing-btn-icon {
    height: 1.2em;
    width: auto;
}

.landing-btn-primary .landing-btn-icon {
    filter: brightness(0) invert(1);
}

.landing-btn-secondary .landing-btn-icon {
    filter: invert(58%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(79%) contrast(103%);
}

.topics-table .icon-disabled {
    pointer-events: auto;
    cursor: not-allowed;
}

.topics-table .icon-disabled:hover {
    transform: none;
}

/* Citizens table column widths */
.citizens-table col:nth-child(1) { width: 35%; }
.citizens-table col:nth-child(2) { width: 25%; }
.citizens-table col:nth-child(3) { width: 20%; }
.citizens-table col:nth-child(4) { width: 20%; }

.citizens-table td:last-child {
    padding-left: 1rem;
}

.citizens-table .icon-disabled {
    pointer-events: auto;
    cursor: not-allowed;
}

.citizens-table .icon-disabled:hover {
    transform: none;
}

.oh-hai {
    cursor: pointer;
    align-self: flex-end;
    margin-left: auto;
    padding-right: 1rem;
    text-align: right;
}

.oh-access {
    cursor: pointer;
    align-self: flex-start;
    padding-left: 1rem;
}

.link-cotainer {
    position: absolute;
    bottom: 5%;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    gap: 0.5rem;
}

.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-family: 'Civil Premium', Arial, sans-serif;
    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 {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.landing-btn-primary {
    background-color: var(--theme-color);
    color: white;
}

.landing-btn-primary:hover {
    background-color: #009e88;
}

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

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

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

a {
    color: var(--theme-color);
    text-decoration: underline;
    text-underline-offset: 0.2rem;
}

.banner {
    display: block;
    max-width: 550px;
    margin-top: 10%;
    margin-left: auto;
    margin-right: auto;
}

.table-mandatory {
    padding-top: 1rem;
    border-collapse: separate;
    border-spacing: 0 1rem;
}

.table-mandatory tr {

}

.table-mandatory th {
    text-align: left;
    vertical-align: top;
    padding-right: 2rem;
    width: 30%;
}

.th-sub {
    padding-left: 1rem;
}

.table-mandatory td {
    padding-right: 2rem;
    width: fit-content;
    white-space: pre-wrap;
}

.pre-wrap {
    padding-right: 2rem;
    width: fit-content;
    white-space: pre-wrap;
}

.no-padding {
    padding-left: 0 !important;
    white-space: normal !important;
}

h1 {
    font-weight: 600;
    font-size: 1.6rem;
    margin-top: 0.5rem;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

ul {
    margin-left: 2rem;
}

th {
    font-weight: 600;
    text-align: left;
}

.link-table thead th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.6rem 0.5rem;
    border-bottom: 2px solid var(--theme-color);
    color: color-mix(in srgb, var(--theme-color) 70%, transparent);
    position: sticky;
    top: 0;
    background-color: var(--color-surface);
    z-index: 2;
    /* border-bottom is dropped on sticky cells with border-collapse; redraw via inset shadow */
    box-shadow: inset 0 -2px 0 var(--theme-color);
}

.link-table .filter-row th {
    top: 2.3rem;
    box-shadow: none;
}

.link-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.2rem;
}

.link-table thead th.sortable:hover {
    color: var(--theme-color);
}

.link-table thead th.sorted-asc::after {
    content: '\25B2';
    position: absolute;
    right: 0.2rem;
    opacity: 0.9;
    font-size: 0.6rem;
}

.link-table thead th.sorted-desc::after {
    content: '\25BC';
    position: absolute;
    right: 0.2rem;
    opacity: 0.9;
    font-size: 0.6rem;
}

.link-list {
    line-height: 1.6rem;
}

.link-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.link-table col:nth-child(1) { width: 8%; }
.link-table col:nth-child(2) { width: 10%; }
.link-table col:nth-child(3) { width: 10%; }
.link-table col:nth-child(4) { width: 20%; }
.link-table col:nth-child(5) { width: 13%; }
.link-table col:nth-child(6) { width: 15%; }
.link-table col:nth-child(7) { width: 10%; }
.link-table col:nth-child(8) { width: 14%; }

.link-table.viewer-mode col:nth-child(4) { width: 22%; }
.link-table.viewer-mode col:nth-child(5) { width: 15%; }
.link-table.viewer-mode col:nth-child(6) { width: 17%; }
.link-table.viewer-mode col:nth-child(7) { width: 12%; }
.link-table.viewer-mode col:nth-child(8) { width: 3%; }

/* Topics table: name column fills remaining space */
.topics-table { table-layout: auto; }
.topics-table col:nth-child(1) { width: auto; }
.topics-table col:nth-child(2) { width: 120px; }

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

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

.link-table tbody tr[data-published="1"] {
    background-color: var(--theme-color-mid);
}

.link-table tfoot td {
    font-size: 0.8rem;
    opacity: 0.6;
    padding-top: 0.8rem;
    border: none;
}

.align-center {
    text-align: center;
}

.align-right {
    text-align: right;
}

svg.svg-theme { color: var(--theme-color); }
svg.svg-red { color: #dc3545; }
svg.svg-orange { color: #f39c12; }
svg.svg-green { color: #27ae60; }
svg.svg-grey { color: #999; }

img.svg-theme {
    filter: invert(58%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(79%) contrast(103%) !important;
}

img.svg-red {
    filter: invert(19%) sepia(95%) saturate(6932%) hue-rotate(358deg) brightness(100%) contrast(110%) !important;
}

img.svg-orange {
    filter: invert(62%) sepia(92%) saturate(1752%) hue-rotate(1deg) brightness(104%) contrast(106%) !important;
}

img.svg-grey {
    filter: invert(50%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(90%) contrast(90%) !important;
}

.icon-disabled {
    opacity: 0.3;
    pointer-events: none;
}

.clickable {
    cursor: pointer;
    transition: transform .2s;
}

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

svg.icon {
    width: 1em;
    height: 1em;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    overflow: visible;
}

.icon {
    width: 1rem;
    height: 1rem;
    color: var(--theme-color);
}

.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

.spinner {
    position: fixed;
    display: block;
    left: calc(50% - 2.5rem);
    top: calc(50% - 2.5rem);
    width: 80px;
    height: 80px;
    z-index: 1000;
}

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

}

.spinner div:nth-child(1) {
    animation-delay: -0.45s;
}

.spinner div:nth-child(2) {
    animation-delay: -0.3s;
}

.spinner div:nth-child(3) {
    animation-delay: -0.15s;
}

@keyframes spinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.backdrop {
    display: block;
    backdrop-filter: blur(6px);
    background: rgba(0,0,0,0.1);
    position: fixed;
    _position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    width: 100%;
    height: 100%;
}

#toast {
    visibility: hidden;
    min-width: 250px;
    background-color: var(--color-surface);
    color: var(--theme-color);
    text-align: center;
    border: 1px solid var(--color-modal-border);
    border-radius: 12px;
    outline-color: var(--theme-color);
    padding: 16px;
    position: fixed !important;
    z-index: 10000 !important;
    left: 50% !important;
    transform: translateX(-50%);
    top: unset !important;
    bottom: 30px !important;
    box-shadow: var(--shadow-md);
    font-weight: 500;
}

#toast.show {
    visibility: visible;
    -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;
    animation: fadein 0.5s, fadeout 0.5s 2.5s;
}

#check {
    float: right;
    padding-right: 0.5rem;
}

#toast-icon-ok, #toast-icon-err {
    float: left;
    padding-left: 0.5rem;
}

.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
}

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

footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3rem;
    background-color: var(--color-footer-bg, 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;
    min-width: 25rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

cta {
    position: fixed;
    display: block;
    margin: auto;
    background-color: var(--theme-color);
    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.cta-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto;
}

cta.cta-disabled:hover {
    transform: none;
    box-shadow: var(--shadow-lg);
}

cta.cta-disabled icon {
    cursor: not-allowed;
}

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

.fab-icon {
    width: 2.8rem;
    height: 2.8rem;
    color: #fff;
}

version {
    position: absolute;
    display: block;
    font-size: 0.7rem;
    color: var(--theme-color);
    opacity: 0.6;
    bottom: 0.5rem;
    right: 0.5rem;
}

/* Animations to fade the snackbar in and out */
@-webkit-keyframes fadein {
    from {
        bottom: 0;
        opacity: 0;
    }
    to {
        bottom: 30px;
        opacity: 1;
    }
}

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

@-webkit-keyframes fadeout {
    from {
        bottom: 30px;
        opacity: 1;
    }
    to {
        bottom: 0;
        opacity: 0;
    }
}

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

.message {
    text-align: center;
    width: 100%;
    margin-top: 10%;
}

.ok {
    color: #00b199;
}

.error {
    color: #ff0000;
}

.warning {
    color: #ffcc00;
}

.message-text {
    font-size: 4rem;
    font-weight: bold;
    margin-top: 1rem;
}

.about {
    position: absolute;
    bottom: 0;
    right: 0;
    margin-right: 1rem;
    margin-bottom: 1rem;
    color: var(--theme-color);
    font-size: small;
}

.oh-login {
    cursor: pointer;
    text-align: center;
    justify-content: center;
    color: var(--theme-color);
    font-size: small;
    width: 100%;
}

a {
    color: var(--theme-color);
    text-decoration: none;
    text-underline-offset: 0.2rem;
}

a:hover {
    text-decoration: underline;
}

input[type=text], input[type=date] {
    position: relative;
    display: block;
    text-align: center;
    height: 2.4rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    outline-color: var(--theme-color);
    padding-left: 4rem;
    padding-right: 4rem;
    width: calc(100% - 8rem);
}

.permit-icon {
    float: right;
    padding-right: 0.5rem;
    position: relative;
    top: -1.5rem;
}

.permit-button {
    float: right;
    padding-left: 0.5rem;
    text-align: center;
}

.icon-button {
    width: 2rem;
    height: 2rem;
    color: var(--theme-color);
}

#edit-form {
    position: fixed;
    display: block;
    z-index: 1000;
    left: 20%;
    width: 60%;
    top: calc(var(--nav-height) + 2rem);
    max-height: calc(100vh - var(--nav-height) - 4rem);
    overflow-y: auto;
}

#detail-modal {
    position: fixed;
    display: block;
    z-index: 1000;
    left: 15%;
    width: 70%;
    top: calc(var(--nav-height) + 2rem);
    max-height: calc(100vh - var(--nav-height) - 4rem);
    overflow-y: auto;
}

.detail-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.detail-history-row {
    display: flex;
    gap: 0.8rem;
    padding: 0.4rem;
    border-bottom: 1px solid var(--theme-color-light);
    font-size: 0.85rem;
    align-items: baseline;
    cursor: pointer;
}

.detail-history-row:hover {
    background-color: var(--theme-color-light);
}

.detail-history-row:last-child {
    border-bottom: none;
}

.detail-history-action {
    font-weight: 600;
    flex-shrink: 0;
    color: var(--theme-color);
}

.detail-history-subject {
    flex: 2;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-history-user {
    opacity: 0.7;
    flex-shrink: 0;
    text-align: right;
}

.detail-history-time {
    opacity: 0.7;
    flex-shrink: 0;
    font-size: 0.8rem;
    text-align: right;
}

.history-diff-container {
    width: 38rem;
    max-width: 90vw;
}

.history-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.history-diff-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--theme-color);
    padding: 0.4rem 0.5rem;
    border-bottom: 2px solid var(--theme-color);
}

.history-diff-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.history-diff-table td:first-child {
    font-weight: 600;
    color: var(--theme-color);
    white-space: nowrap;
}

.history-diff-old {
    background-color: var(--color-diff-old-bg);
    color: var(--color-error);
}

.history-diff-new {
    background-color: var(--color-diff-new-bg);
    color: var(--color-success);
}

.history-empty, .detail-docs-empty {
    color: var(--color-muted);
    font-style: italic;
    padding: 0.5rem 0;
}

.detail-bottom-actions {
    margin-top: 2.5rem;
}

#inter-form-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

#inter-form label,
#inter-form .detail-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--theme-color);
}

.form-row {
    margin-bottom: 1rem;
}

label.required::after {
    content: ' *';
    color: var(--theme-color);
    font-weight: 600;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    user-select: none;
}

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

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

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

.form-row-half {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row-half > .form-col {
    flex: 1;
}

.form-col {
    display: flex;
    flex-direction: column;
}

.inter-input {
    display: block;
    width: 100%;
    height: 2.4rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    outline-color: var(--theme-color);
    padding: 0 0.5rem;
    font-size: 0.9rem;
    box-sizing: border-box;
    font-family: 'Civil Premium', Arial, sans-serif;
    text-align: left;
    color: var(--theme-color);
}

input[type=text].inter-input {
    width: 100%;
    padding: 0 0.5rem;
    box-sizing: border-box;
    text-align: left;
}

input[type=date].inter-input {
    height: 2.4rem;
    padding: 0 0.5rem;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
    color-scheme: var(--color-scheme);
}

input[type=number].inter-input {
    width: 100%;
    padding: 0 0.5rem;
    box-sizing: border-box;
    text-align: left;
    -moz-appearance: textfield;
}

input[type=number].inter-input::-webkit-inner-spin-button,
input[type=number].inter-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=time].inter-input {
    height: 2.4rem;
    padding: 0 0.5rem;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
    color-scheme: var(--color-scheme);
}

input[type=time].inter-input::-webkit-calendar-picker-indicator {
    filter: invert(58%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(79%) contrast(103%);
}

input[type=time].inter-input::-webkit-datetime-edit {
    color: var(--theme-color);
    font-family: 'Civil Premium', Arial, sans-serif;
}

input[type=time].inter-input::-webkit-datetime-edit-text {
    color: var(--theme-color);
    opacity: 0.55;
}

input[type=date].inter-input::-webkit-calendar-picker-indicator {
    filter: invert(58%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(79%) contrast(103%);
}

input[type=date].inter-input::-webkit-datetime-edit,
input[type=datetime-local].inter-input::-webkit-datetime-edit {
    color: var(--theme-color);
    font-family: 'Civil Premium', Arial, sans-serif;
}

input[type=date].inter-input::-webkit-datetime-edit-text,
input[type=datetime-local].inter-input::-webkit-datetime-edit-text {
    color: var(--theme-color);
    opacity: 0.55;
}

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

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

.inter-input::placeholder,
input.combo-input::placeholder {
    color: var(--theme-color);
    opacity: 0.55;
}

select.inter-input {
    appearance: none;
    -webkit-appearance: none;
    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='%2300b199'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 1.2rem;
    padding-right: 2rem;
    cursor: pointer;
}

.inter-display {
    background-color: var(--theme-color-light);
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
    color: var(--theme-color);
    min-height: 1.4rem;
}

.inter-display a {
    color: var(--theme-color);
    text-decoration: underline;
}

.inter-display a:hover {
    opacity: 0.7;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0.5rem;
}

.lds-ring {
    position: fixed;
    display: block;
    left: calc(50% - 2.5rem);
    top: calc(50% - 2.5rem);
    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 #fff;
    border-radius: 50%;
    animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: var(--theme-color) 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;
}

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

.copy-link {
    cursor: pointer;
}

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

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

tr.row-archived {
    opacity: 0.45;
}

.link-table td a {
    text-decoration: underline;
}

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

.icon-row {
    display: flex;
    gap: 2px;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

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

.icon-row .icon:not(.icon-disabled):hover {
    background-color: var(--color-hover-bg);
}

/* Searchable combobox */
.combo-wrap {
    position: relative;
}

select.combo-hidden {
    display: none;
}

.combo-clear {
    position: absolute;
    right: 1.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--theme-color);
    font-size: 1.5rem;
    font-weight: 300;
    display: none;
    opacity: 0.5;
    line-height: 1;
    z-index: 1;
    cursor: pointer;
}

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

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

input.combo-input {
    display: block;
    width: 100%;
    height: 2.4rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    outline-color: var(--theme-color);
    padding: 0 2rem 0 0.5rem;
    font-size: 0.9rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    text-align: left;
    box-sizing: border-box;
    color: var(--theme-color);
    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='%2300b199'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 1.2rem;
    cursor: pointer;
}

.combo-list {
    display: none;
    position: fixed;
    max-height: 14rem;
    overflow-y: auto;
    background: var(--color-surface);
    border: 2px solid var(--theme-color);
    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(--theme-color);
    cursor: pointer;
}

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

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

/* Pill multiselect */
.pill-container { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.3rem; }
.pill-container:empty { margin-bottom: 0; }
.pill { display: inline-flex; align-items: baseline; gap: 0.3rem; padding: 0.35rem 0.6rem;
        border-radius: 1rem; font-size: 0.85rem; font-weight: 600;
        background-color: var(--color-surface); color: var(--theme-color); border: 2px solid var(--theme-color); }
.pill .pill-remove { cursor: pointer; font-size: 1rem; line-height: 1; opacity: 0.6; }
.pill .pill-remove:hover { opacity: 1; }
/* Combobox with add button */
.label-with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.75rem;
}
.label-with-action .detail-label {
    margin: 0;
    line-height: 2.2rem;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-att-action {
    width: 2.2rem;
    flex-shrink: 0;
    text-align: center;
}

.combo-with-add {
    display: flex;
    gap: 0.4rem;
    align-items: stretch;
}
.combo-with-add:has(.pill-container) { align-items: center; }

.combo-with-add select.inter-input,
.combo-with-add .combo-wrap {
    flex: 1;
    min-width: 0;
}

.combo-add-btn {
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--theme-color);
    font-size: 1.6rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
    line-height: 2.2rem;
    padding: 0;
}

.combo-add-btn:hover {
    transform: scale(1.2);
}

/* Mini-modal for inline creation */
#responder-add-modal, #req-attachment-add-modal, #cancel-reason-modal, #confirm-modal { z-index: 1600; }
.mini-modal {
    position: fixed;
    z-index: 1500;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: calc(var(--nav-height) + 2rem);
    padding-bottom: 2rem;
    overflow: hidden;
}

.mini-modal-container {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem 1.5rem 2.5rem;
    box-sizing: border-box;
    width: 30rem;
    max-width: 90vw;
    max-height: 100%;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.mini-modal-container label,
.mini-modal-container .detail-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.75rem;
    margin-bottom: 0.3rem;
    color: var(--theme-color);
}

.mini-modal-container label:first-of-type,
.mini-modal-container .detail-label:first-child {
    margin-top: 0;
}

.mini-modal-container .inter-input {
    margin-bottom: 0.5rem;
}

.reassign-source-name {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.6rem;
    background: var(--theme-color-mid);
    border-radius: 4px;
}

/* Confirm message */
.confirm-message {
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Modal title */
modal-title {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--theme-color);
}

/* Wide text modal */
.text-modal-wide {
    width: 40rem;
}

/* Textarea styled like inter-input */
.inter-textarea {
    display: block;
    width: 100%;
    height: auto;
    min-height: 4rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    outline-color: var(--theme-color);
    font-size: 0.9rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    color: var(--theme-color);
    box-sizing: border-box;
    resize: vertical;
    padding: 0.4rem 0.5rem;
    line-height: 1.4;
}

/* Toggle buttons for questioner type */
.toggle-buttons {
    display: flex;
    gap: 0;
}

.toggle-btn {
    flex: 1;
    height: 2.2rem;
    border: 2px solid var(--theme-color);
    background: var(--color-surface);
    color: var(--theme-color);
    font-size: 0.9rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.toggle-btn:first-child {
    border-radius: 0 0 0 8px;
}

.toggle-btn:last-child {
    border-radius: 0 0 8px 0;
    border-left: none;
}

.toggle-btn.active {
    background-color: var(--theme-color);
    color: #fff;
}

.toggle-btn:focus-visible {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

/* Questioner fields spacing */
.questioner-fields {
    margin-top: 0.5rem;
}

.questioner-fields.hidden {
    display: none !important;
}

/* Datetime-local input */
input[type=datetime-local].inter-input {
    height: 2.2rem;
    padding: 0 0.5rem;
    width: 100%;
    text-align: left;
    box-sizing: border-box;
    color-scheme: var(--color-scheme);
}

input[type=datetime-local].inter-input::-webkit-calendar-picker-indicator {
    filter: invert(58%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(79%) contrast(103%);
}

/* Attachment rows */
.attachment-group {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--theme-color-light);
}

.attachment-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
    border: 2px dashed rgba(0, 177, 153, 0.4);
    border-radius: 8px;
    background-color: rgba(0, 177, 153, 0.04);
    color: var(--theme-color);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    outline: none;
}

.attachment-dropzone:hover,
.attachment-dropzone:focus {
    background-color: var(--theme-color-light);
    border-color: var(--theme-color);
}

.attachment-dropzone.dragover {
    background-color: var(--theme-color-light);
    border-color: var(--theme-color);
    border-style: solid;
}

.attachment-dropzone * {
    pointer-events: none;
}

.attachment-dropzone-text {
    font-size: 0.85rem;
    opacity: 0.9;
}

.attachment-dropzone-input {
    display: none;
}

.attachment-group:last-child {
    border-bottom: none;
}

.attachment-row-type {
    margin-top: 0.35rem;
}

.attachment-row-type select {
    width: 100%;
}

.attachment-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.attachment-row input[type=file] {
    flex: 1;
    min-width: 0;
    height: 2.4rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    outline-color: var(--theme-color);
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    color: var(--theme-color);
    box-sizing: border-box;
    cursor: pointer;
}

.attachment-row input[type=text] {
    flex: 1;
    min-width: 0;
    height: 2.4rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 8px 8px;
    outline-color: var(--theme-color);
    padding: 0 0.5rem;
    font-size: 0.85rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    color: var(--theme-color);
    box-sizing: border-box;
    text-align: left;
    width: auto;
    display: flex;
}

.attachment-row input[type=file]::file-selector-button {
    background: var(--theme-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.6rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    margin-right: 0.5rem;
}

.attachment-remove-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--theme-color);
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 0;
    width: 1.5rem;
}

.attachment-remove-btn:hover {
    transform: scale(1.2);
}

.attachment-existing-heading {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-color);
    margin-top: 0.3rem;
    margin-bottom: 0.2rem;
}

.attachment-existing-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0;
    font-size: 0.857rem;
    opacity: 0.7;
}

.attachment-existing-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.attachment-existing-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.857rem;
}

.attachment-existing-filename {
    font-size: 0.75rem;
    opacity: 0.7;
}

.attachment-existing-type {
    font-size: 0.7rem;
    color: var(--theme-color);
}

.attachment-existing-actions {
    flex-shrink: 0;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0.6rem;
}

.attachment-existing-size {
    flex-shrink: 0;
    font-size: 0.857rem;
    align-self: center;
}

#attachment-existing:not(:empty) {
    margin-bottom: 0.7rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

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

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

#detail-panel-container label,
#detail-panel-container .detail-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--theme-color);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.detail-header modal-title {
    margin-bottom: 0;
}

.detail-section {
    margin-top: 1.5rem;
}

.detail-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--theme-color);
    border-bottom: 2px solid var(--theme-color);
    padding-bottom: 0.3rem;
    margin-bottom: 0.8rem;
}

.detail-section-with-action {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.detail-section-add {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--theme-color);
    cursor: pointer;
    user-select: none;
}

.detail-section-add:hover {
    text-decoration: underline;
}

.detail-text-card {
    background-color: var(--theme-color-light);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.8rem;
}

.detail-text-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}

.detail-text-chevron {
    font-size: 0.85rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.detail-text-card.expanded .detail-text-chevron {
    transform: rotate(90deg);
}

.detail-text-type {
    font-weight: 700;
    font-size: 0.95rem;
}

.detail-text-who {
    font-size: 0.85rem;
    opacity: 0.8;
}

.detail-text-meta {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-left: auto;
}

.detail-text-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.detail-text-card.expanded .detail-text-body {
    max-height: 2000px;
    opacity: 1;
}

.detail-text-questioner {
    font-style: italic;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.detail-text-content {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-top: 0.5rem;
}

.detail-attachment-zip {
    display: flex;
    justify-content: flex-end;
    padding: 0.25rem 0;
}

.detail-attachment-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--theme-color-light);
}

.detail-attachment-row:last-child {
    border-bottom: none;
}

.detail-attachment-icon {
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
}

.detail-attachment-info {
    flex: 1;
    min-width: 0;
}

.detail-attachment-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.detail-attachment-filename {
    font-size: 0.8rem;
    opacity: 0.7;
}

.detail-attachment-size {
    font-size: 0.8rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.detail-attachment-download {
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.detail-attachment-download:hover {
    transform: scale(1.2);
}

.detail-history-row {
    display: flex;
    gap: 0.8rem;
    padding: 0.4rem 0.4rem;
    border-bottom: 1px solid var(--theme-color-light);
    font-size: 0.85rem;
    align-items: baseline;
}

.detail-history-row.clickable {
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.detail-history-row.clickable:hover {
    background-color: var(--theme-color-light);
    transform: none;
}

.detail-history-row:last-child {
    border-bottom: none;
}

.detail-history-action {
    font-weight: 600;
    flex-shrink: 0;
    min-width: 6.5rem;
}

.detail-history-subject {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.detail-history-user {
    opacity: 0.7;
    flex-shrink: 0;
}

.detail-history-time {
    opacity: 0.7;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.detail-empty {
    font-style: italic;
    font-size: 0.9rem;
    color: var(--color-muted);
}

#list tr[data-gid] {
    cursor: pointer;
}

/* Full-text search */
.search-wrap {
    position: relative;
    margin-top: 0.8rem;
}

input[type=text].search-input {
    width: 100%;
    height: 2.4rem;
    border: 2px solid var(--theme-color);
    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(--theme-color);
    box-sizing: border-box;
    text-align: left;
}

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

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

.search-wrap .search-icon {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.5;
}

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

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

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

.search-bar {
    position: absolute;
    bottom: 2px;
    left: 2px;
    height: 5px;
    width: 0;
    background: var(--theme-color);
    opacity: 0.85;
    border-radius: 0 0 6px 6px;
    pointer-events: none;
}

.search-bar.animating {
    transition: width 1000ms linear;
    width: 0;
}

.search-status {
    font-size: 0.8rem;
    color: var(--theme-color);
    opacity: 0.6;
    margin-top: 0.3rem;
    min-height: 1.2rem;
}

/* Year filter */
.year-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.8rem;
}

.year-btn {
    flex: none;
    height: 2.2rem;
    padding: 0 1rem;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 6px 6px;
    background: var(--color-surface);
    color: var(--theme-color);
    font-size: 0.9rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.year-btn:not(.active):hover {
    background-color: var(--theme-color-light);
}

.year-btn.active {
    background-color: var(--theme-color);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.year-btn.active .cal-list-icon {
    color: #fff;
}

.year-btn:focus-visible {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

.status-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.3;
}
.status-orange { background: #fff3e0; color: #e65100; }
.status-green { background: #e8f5e9; color: #2e7d32; }
.status-red { background: #fce4ec; color: #c62828; }

#meeting-filter {
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

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

.link-table .filter-row th {
    padding: 0.4rem 0.5rem 0.4rem;
    border-bottom: none;
    text-transform: none;
    letter-spacing: normal;
    opacity: 1;
}

.link-table thead tr:first-child th:last-child {
    text-align: right;
}

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

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

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

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

input[type=text].filter-input {
    width: 100%;
    height: 1.8rem;
    border: 1px solid var(--theme-color);
    border-radius: 0 0 6px 6px;
    outline: none;
    padding: 0 1.4rem 0 0.4rem;
    font-size: 0.8rem;
    font-family: 'Civil Premium', Arial, sans-serif;
    color: var(--theme-color);
    box-sizing: border-box;
    text-align: left;
}

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

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

#filter-toggle {
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
}

#filter-toggle:hover {
    opacity: 0.8;
}

#filter-toggle.active {
    opacity: 1;
}

/* History diff modal */
.history-diff-container {
    width: 38rem;
}

.history-diff-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.history-diff-table th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.6rem;
    border-bottom: 2px solid var(--theme-color);
    color: var(--theme-color);
    opacity: 0.7;
    text-align: left;
}

.history-diff-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--color-table-border);
    vertical-align: top;
    word-break: break-word;
}

.history-diff-table td:first-child {
    font-weight: 600;
    white-space: nowrap;
    width: 8rem;
}

.history-diff-old {
    background-color: var(--color-diff-old-bg);
}

.history-diff-new {
    background-color: var(--color-diff-new-bg);
}

/* Input clear button (modal text inputs) */
.input-wrap {
    position: relative;
    display: block;
    margin-bottom: 0.5rem;
}
.input-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--theme-color);
    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 .inter-input { padding-right: 1.6rem; margin-bottom: 0; }
.input-wrap input[type=date].inter-input,
.input-wrap input[type=time].inter-input,
.input-wrap input[type=datetime-local].inter-input { padding-right: 2.6rem; }
.input-wrap input[type=date].inter-input + .input-clear,
.input-wrap input[type=time].inter-input + .input-clear,
.input-wrap input[type=datetime-local].inter-input + .input-clear { right: 1.5rem; }
.form-row .input-wrap { margin-bottom: 0; }
.form-row-half .input-wrap { margin-bottom: 0; flex: 1; }
.form-row-half .input-wrap .inter-input { width: 100%; }
.input-wrap .inter-textarea + .input-clear {
    top: 0.4rem;
    transform: none;
}
.attachment-row .input-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
}

/* Responsive: horizontal scroll for table on narrow screens */
@media (max-width: 900px) {
    content.main {
        overflow-x: auto;
    }
    .link-table {
        min-width: 800px;
    }
}

/* Statistics page */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.stats-card {
    background: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

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

.stats-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--theme-color);
    border-bottom: 2px solid var(--theme-color);
    padding-bottom: 0.3rem;
    margin-bottom: 1rem;
}

.stats-empty {
    font-style: italic;
    font-size: 0.9rem;
    opacity: 0.5;
    padding: 1rem 0;
}

/* Bar chart */
.bar-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.bar-label {
    flex: 0 0 10rem;
    font-size: 0.85rem;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bar-label-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.bar-label-link:hover {
    text-decoration: underline;
    color: var(--theme-color);
}

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

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.bar-count {
    flex: 0 0 2.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

/* Donut chart */
.donut-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 1rem 0;
}

.donut {
    position: relative;
    width: 10rem;
    height: 10rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.donut-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.donut-total {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--theme-color);
    line-height: 1.2;
}

.donut-total-label {
    font-size: 0.75rem;
    opacity: 0.6;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.donut-legend-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.donut-legend-link:hover .donut-legend-name {
    text-decoration: underline;
    color: var(--theme-color);
}

.donut-legend-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    flex-shrink: 0;
}

.donut-legend-name {
    font-weight: 600;
}

.donut-legend-count {
    opacity: 0.7;
    font-size: 0.85rem;
}

/* Year bars (vertical) */
.year-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0.8rem;
    height: 10rem;
    padding: 0.5rem 0;
}

.year-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 5rem;
    height: 100%;
    justify-content: flex-end;
}

.year-bar-count {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--theme-color);
}

.year-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s ease;
}

.year-bar-label {
    font-size: 0.8rem;
    margin-top: 0.3rem;
    opacity: 0.7;
}

.year-bar-active .year-bar-label {
    font-weight: 700;
    opacity: 1;
}

.year-bar-active .year-bar-count {
    font-weight: 700;
}

@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .bar-label {
        flex: 0 0 7rem;
        font-size: 0.8rem;
    }
    .donut-wrap {
        flex-direction: column;
        gap: 1rem;
    }
    .donut {
        width: 8rem;
        height: 8rem;
    }
    .donut-hole {
        width: 5rem;
        height: 5rem;
    }
    .donut-total {
        font-size: 1.3rem;
    }
}

/* FOI table column widths */
.foi-table col:nth-child(1) { width: 5%; }
.foi-table col:nth-child(2) { width: 30%; }
.foi-table col:nth-child(3) { width: 20%; }
.foi-table col:nth-child(4) { width: 12%; }
.foi-table col:nth-child(5) { width: 18%; }
.foi-table col:nth-child(6) { width: 15%; }

/* Case row click styles */
.case-row { cursor: pointer; }
.case-row:hover { background-color: var(--color-surface, #f8f9fa); }
.row-expanded { background-color: var(--color-surface, #f0f4f8) !important; }

/* Document detail sub-row */
.doc-detail-row td {
    padding: 0 0.5rem 1rem;
    background-color: var(--color-bg, #fafbfc);
    border-bottom: 2px solid var(--color-border, #dee2e6);
}

.doc-detail-loading,
.doc-detail-empty {
    padding: 1rem;
    text-align: center;
    color: var(--color-muted);
    font-style: italic;
}

.doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.doc-table thead th {
    background-color: var(--theme-color);
    color: #fff;
    padding: 0.35rem 0.5rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.8rem;
}

.doc-table tbody td {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--color-border, #dee2e6);
}

.doc-table tbody tr:last-child td {
    border-bottom: none;
}

.doc-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* CTA buttons (matching bezo/souhlasy) */
.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.4rem;
    background-color: var(--theme-color);
    color: #fff;
    border: none;
    border-radius: 0 0 8px 8px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Civil Premium', Arial, sans-serif;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
}

.cta-button:hover {
    background-color: #009e88;
    transform: translateY(-1px);
}

.cta-button:focus-visible {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

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

.cta-button-secondary:hover {
    background-color: var(--theme-color-light, rgba(0, 177, 153, 0.06));
    transform: translateY(-1px);
}

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

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

.cta-button-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    height: 2.4rem;
    box-sizing: border-box;
    flex-shrink: 0;
}

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

.cta-button .btn-icon {
    color: #fff;
}

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

.archive-reason-wrap {
    margin-top: 0.75rem;
}
.archive-reason-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--theme-color);
    margin-bottom: 0.3rem;
}

/* ── Labels ── */
.label-pill {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.4;
    margin: 0.1rem 0.15rem;
    vertical-align: middle;
}
.label-pills-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
}
.label-cloud-container {
    max-width: 32rem;
    width: 90%;
}
.label-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
}
.label-cloud-item {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
    border: 2px solid transparent;
}
.label-cloud-item.assigned {
    color: #fff;
}
.label-cloud-item.unassigned {
    background: transparent !important;
    color: var(--theme-color);
    opacity: 0.5;
}
.label-cloud-item:hover {
    opacity: 1;
}

.sync-note {
    font-size: 0.9rem;
    color: var(--theme-color);
    opacity: 0.7;
    margin: 0.5rem 0;
}
.sync-muted {
    opacity: 0.5;
}
.sync-select-all {
    float: right;
    font-size: 0.8rem;
    font-weight: 400;
    cursor: pointer;
}

/* Invite overlay */
.invite-event-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--theme-color);
    margin: 0 0 0.75rem;
}
.invite-recipients-label {
    font-size: 0.85rem;
    color: var(--theme-color);
    opacity: 0.7;
    margin: 0 0 0.25rem;
}
.invite-recipients {
    margin: 0;
    padding: 0 0 0 1.2rem;
    font-size: 0.85rem;
    color: var(--theme-color);
    max-height: 30vh;
    overflow-y: auto;
}
.invite-recipients li {
    margin-bottom: 0.15rem;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-surface);
    padding: 0.25rem 0;
}

.form-header h2 {
    margin: 0;
}

svg.icon-button {
    width: 2rem;
    height: 2rem;
    padding: 0.25rem;
    color: var(--theme-color);
}

.clickable {
    cursor: pointer;
    transition: transform 0.2s;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* Row count below table */
.row-count {
    font-size: 0.85rem;
    color: var(--theme-color);
    opacity: 0.6;
    padding: 0.6rem 0;
}

/* Action column */
.th-actions {
    text-align: right !important;
}

.icon-row {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

/* Merge checkbox */
.merge-cb {
    appearance: none;
    -webkit-appearance: none;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--theme-color);
    border-radius: 3px;
    background: var(--color-surface);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
}

.merge-cb:checked {
    background-color: var(--theme-color);
    border-color: var(--theme-color);
}

.merge-cb:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.merge-cb:hover {
    border-color: #009e88;
}

.merge-cb:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,177,153,0.15);
}

tr.merge-selected {
    background-color: var(--theme-color-light) !important;
}

/* Requests table column widths */
.requests-table { table-layout: auto; }
.requests-table col:nth-child(1) { width: 13%; }
.requests-table col:nth-child(2) { width: 16%; }
.requests-table col:nth-child(3) { width: auto; }
.requests-table col:nth-child(4) { width: 20%; }
.requests-table col:nth-child(5) { width: 9%; }
.requests-table col:nth-child(6) { width: 5%; }

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

#req-detail-panel-container {
    background-color: var(--color-surface);
    border: 1px solid var(--color-modal-border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

#req-detail-panel-container label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--theme-color);
}

/* Request state badges */
.request-state {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}

.state-pending {
    background-color: #fff3cd;
    color: #856404;
}

.state-accepted {
    background-color: #d4edda;
    color: #155724;
}

.state-converted {
    background-color: #cce5ff;
    color: #004085;
}

.state-cancelled {
    background-color: #f8d7da;
    color: #721c24;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-green {
    background-color: #d4edda;
    color: #155724;
}

.badge-orange {
    background-color: #fff3cd;
    color: #856404;
}

.badge-grey {
    background-color: #e2e3e5;
    color: #383d41;
}

/* Sub-records in expanded rows */
.sub-records {
    padding: 0.5rem 1rem 1rem;
}

.sub-records h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 1rem 0 0.3rem;
    color: var(--theme-color);
}

.sub-records h3:first-child {
    margin-top: 0.3rem;
}

/* Detail info grid (matching 106/bezo/souhlasy/interpelace) */
.detail-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem 1.5rem;
    margin-bottom: 1.5rem;
}

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

.detail-info-field {
    display: flex;
    flex-direction: column;
}

.detail-info-field.full-width {
    grid-column: 1 / -1;
}

.detail-info-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--theme-color);
}

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

.detail-section-with-action {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.detail-section-add {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--theme-color);
    cursor: pointer;
    user-select: none;
}

.detail-section-add:hover {
    text-decoration: underline;
}

.history-empty, .detail-docs-empty {
    color: var(--color-muted);
    font-style: italic;
    padding: 0.5rem 0;
}

.detail-history-row {
    display: flex;
    gap: 0.8rem;
    padding: 0.4rem;
    border-bottom: 1px solid var(--theme-color-light);
    font-size: 0.85rem;
    align-items: baseline;
    cursor: pointer;
}

.detail-history-row:hover {
    background-color: var(--theme-color-light);
}

.detail-history-row:last-child {
    border-bottom: none;
}

.detail-history-action {
    font-weight: 600;
    flex-shrink: 0;
    color: var(--theme-color);
}

.detail-history-subject {
    flex: 2;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-history-user {
    opacity: 0.7;
    flex-shrink: 0;
    text-align: right;
}

.detail-history-time {
    opacity: 0.7;
    flex-shrink: 0;
    font-size: 0.8rem;
    text-align: right;
}

.detail-attachment-zip {
    display: flex;
    justify-content: flex-end;
    padding: 0.25rem 0;
}

.detail-attachment-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--theme-color-light);
}

.detail-attachment-row:last-child {
    border-bottom: none;
}

.detail-attachment-icon {
    width: 1.2rem;
    height: 1.2rem;
    flex-shrink: 0;
}

.detail-attachment-info {
    flex: 1;
    min-width: 0;
}

.detail-attachment-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.detail-attachment-filename {
    font-size: 0.8rem;
    opacity: 0.7;
}

.detail-attachment-type {
    font-size: 0.75rem;
    color: var(--theme-color);
    opacity: 0.8;
}

.detail-attachment-size {
    font-size: 0.8rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.detail-attachment-download {
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s;
}

.detail-attachment-download:hover {
    transform: scale(1.2);
}

/* Sub-record actions */
.sub-actions {
    white-space: nowrap;
    text-align: right;
}

.sub-edit, .sub-delete {
    display: inline-block;
    font-size: 0.85rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.sub-edit {
    color: var(--theme-color);
}

.sub-edit:hover {
    background-color: var(--theme-color-light);
}

.sub-delete {
    color: var(--color-error);
}

.sub-delete:hover {
    background-color: rgba(220,53,69,0.1);
}

.sub-records h3.detail-section-with-action {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

/* Text alignment */
.text-right {
    text-align: right;
}

/* Toolbar */
.toolbar-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
}

.toolbar-actions .icon {
    width: 1.1rem;
    height: 1.1rem;
    padding: 0.15rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.toolbar-actions .icon:hover {
    opacity: 0.9;
}

/* Print styles */
@page { size: landscape; margin: 1cm; }
@media print {
    nav, footer, cta, #backdrop, #confirm-modal, #edit-form,
    #detail-modal, #history-diff-modal, #toast,
    .toolbar-actions, .year-filter, .th-actions,
    .icon-row, .sub-actions, .filter-row, #progress,
    .detail-bottom-actions, .sub-records, .alert-widget, .dot-legend {
        display: none !important;
    }

    html, body { height: auto !important; overflow: visible !important; }
    body { margin: 0; padding: 0; }
    content, content.main {
        position: static;
        left: auto;
        width: 100%;
        padding: 0;
        margin: 0;
        overflow: visible;
    }
    h1 { font-size: 14pt; margin-bottom: 0.3cm; }

    .link-table { font-size: 9pt; table-layout: auto; width: 100%; }
    .link-table colgroup { display: none; }
    .link-table th { background-color: #00b199 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .link-table td { padding: 0.15cm 0.2cm; white-space: normal; word-break: break-word; }

    .row-count { font-size: 8pt; margin-top: 0.2cm; }
    .calendar-view { display: none !important; }
    .search-wrap { display: none !important; }
    .vehicle-filter { display: none !important; }
    .validity-dots { display: none !important; }
}

/* ── Calendar View ── */

.calendar-view {
    margin-top: 1rem;
}

.calendar-view.hidden {
    display: none !important;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.calendar-nav .cal-month-label {
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 10rem;
    text-align: center;
}

.calendar-nav button.cal-arrow {
    background: none;
    border: 2px solid var(--theme-color);
    border-radius: 0 0 6px 6px;
    height: 2.2rem;
    padding: 0 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.calendar-nav button.cal-arrow:hover {
    background: var(--theme-color-light);
}

.calendar-nav button.cal-arrow .icon {
    width: 16px;
    height: 16px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-grid .cal-header {
    background: var(--theme-color);
    color: #fff;
    text-align: center;
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.calendar-grid .cal-day {
    background: var(--color-surface);
    min-height: 5.5rem;
    padding: 0.35rem;
    position: relative;
    vertical-align: top;
}

.calendar-grid .cal-day.cal-other-month {
    background: var(--color-other-month);
    color: var(--color-other-month-text);
}

.calendar-grid .cal-day.cal-today {
    background: var(--theme-color-mid);
}

.cal-day-number {
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cal-day-add {
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    background: var(--theme-color);
    position: relative;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.cal-day-add::before,
.cal-day-add::after {
    content: '';
    position: absolute;
    background: #fff;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 1px;
}
.cal-day-add::before {
    width: 10px;
    height: 2px;
}
.cal-day-add::after {
    width: 2px;
    height: 10px;
}
.cal-day:hover .cal-day-add {
    opacity: 0.7;
}
.cal-day-add:hover {
    opacity: 1 !important;
}

.cal-day-records {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cal-record {
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 3px;
    background: var(--theme-color-light);
    color: var(--color-cal-record-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background 0.15s;
}

.cal-record:hover {
    background: var(--theme-color);
    color: #fff;
}

.cal-more {
    font-size: 0.65rem;
    color: var(--theme-color);
    cursor: pointer;
    font-weight: 500;
    margin-top: 2px;
}

.cal-more:hover {
    text-decoration: underline;
}

/* ── Week view ── */
.cal-week-grid {
    border: 1px solid var(--color-modal-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.cal-week-header {
    display: flex;
    background: var(--theme-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}
.cal-week-header .cal-week-time-col {
    width: 3rem;
    flex-shrink: 0;
}
.cal-week-header .cal-week-day-col {
    flex: 1;
    text-align: center;
    padding: 0.4rem 0;
}
.cal-week-header .cal-week-day-col.cal-today {
    background: rgba(255,255,255,0.2);
    font-weight: 700;
}
.cal-week-body {
    position: relative;
    height: 40rem;
    overflow-y: auto;
}
.cal-week-row {
    display: flex;
    min-height: 2.5rem;
    border-bottom: 1px solid rgba(0,177,153,0.08);
}
.cal-week-time-col {
    width: 3rem;
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--theme-color);
    opacity: 0.6;
    padding: 0.15rem 0.3rem;
    text-align: right;
}
.cal-week-cell {
    flex: 1;
    border-left: 1px solid rgba(0,177,153,0.06);
}
.cal-week-blocks {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}
.cal-week-block {
    position: absolute;
    background: var(--theme-color);
    color: #fff;
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.85;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.cal-week-block:hover {
    opacity: 1;
    z-index: 2;
}

/* ── Day view ── */
.cal-day-grid {
    position: relative;
    border: 1px solid var(--color-modal-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.cal-day-row {
    display: flex;
    min-height: 3rem;
    border-bottom: 1px solid rgba(0,177,153,0.08);
}
.cal-day-time-col {
    width: 3rem;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--theme-color);
    opacity: 0.6;
    padding: 0.2rem 0.3rem;
    text-align: right;
}
.cal-day-content {
    flex: 1;
    border-left: 1px solid rgba(0,177,153,0.06);
}
.cal-day-blocks {
    position: absolute;
    top: 0;
    left: 3rem;
    right: 0;
    bottom: 0;
    pointer-events: none;
}
.cal-day-block {
    position: absolute;
    background: var(--theme-color);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.85;
    line-height: 1.3;
}
.cal-day-block:hover {
    opacity: 1;
    z-index: 2;
}
.cal-day-block strong {
    font-weight: 700;
}
.cal-list-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
}

.cal-day-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    z-index: 1001;
    max-width: 28rem;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
}

.cal-day-modal .form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.cal-day-modal h3 {
    font-size: 1rem;
    margin: 0;
}

.cal-day-modal .cal-day-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cal-day-modal .cal-day-item {
    padding: 0.5rem;
    background: var(--theme-color-light);
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.cal-day-modal .cal-day-item strong {
    color: var(--theme-color);
}

.btn-calendar-active {
    background: var(--theme-color-light);
    border-radius: 4px;
}

.filter-back-pill {
    display: inline-block;
    margin-left: 1rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    background: var(--theme-color-light);
    color: var(--theme-color);
    border-radius: 12px;
    text-decoration: none;
    vertical-align: middle;
}

.filter-back-pill:hover {
    background: var(--theme-color);
    color: #fff;
}

/* ── Cost Summary ── */

.cost-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
.cost-summary-table th {
    text-align: left;
    font-weight: 600;
    color: var(--theme-color);
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid rgba(0,177,153,0.2);
    font-size: 0.75rem;
    text-transform: uppercase;
}
.cost-summary-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.cost-year {
    font-weight: 600;
    color: var(--theme-color);
}
.cost-num {
    text-align: right;
    white-space: nowrap;
}
.cost-total {
    font-weight: 700;
}
.cost-grand-total td {
    border-top: 2px solid var(--theme-color);
    font-weight: 700;
    padding-top: 0.5rem;
}
.cost-bar-col {
    width: 30%;
}
.cost-bar-cell {
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
}
.cost-bar {
    display: flex;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    background: rgba(0,0,0,0.03);
}
.cost-bar-fuel {
    background: var(--theme-color);
}
.cost-bar-expense {
    background: #f39c12;
}
.cost-bar-insurance {
    background: #e74c3c;
}
.cost-legend {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--theme-color);
    opacity: 0.7;
    margin-top: 0.3rem;
}
.cost-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.cost-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

/* ── Dark Mode ── */

html.dark {
    --theme-color: #1dd1a1;
    --theme-color-light: rgba(29,209,161,0.12);
    --theme-color-mid: rgba(29,209,161,0.18);
    --color-bg: #1a1a2e;
    --color-surface: #16213e;
    --color-border: #2a2a4a;
    --color-text: #e0e0e0;
    --color-warning: #ffb81c;
    --color-error: #ff6b6b;
    --color-success: #51cf66;
    --color-input-bg: #16213e;
    --color-hover-bg: rgba(29,209,161,0.12);
    --color-modal-border: rgba(29,209,161,0.25);
    --color-table-border: #2a2a4a;
    --color-other-month: #12121f;
    --color-other-month-text: #555;
    --color-cal-record-text: #ccc;
    --color-bar-track: #222240;
    --color-diff-old-bg: rgba(255,107,107,0.15);
    --color-diff-new-bg: rgba(81,207,102,0.15);
    --color-muted: #5bbfa8;
    --color-footer-bg: rgba(22,33,62,0.9);
    --color-scheme: dark;
    --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);
}

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

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

html.dark .nav-dropdown-menu {
    background: var(--color-surface);
}

html.dark .nav-dropdown-item {
    color: var(--color-text);
}

html.dark .nav-dropdown-item .nav-link-icon {
    color: var(--theme-color);
}

html.dark .nav-dropdown-item:hover {
    background: var(--theme-color-light);
}

html.dark .nav-dropdown-item-active {
    color: var(--color-text);
    background: var(--theme-color-light);
}

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

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

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

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

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

html.dark .inter-input,
html.dark input.combo-input,
html.dark .inter-textarea {
    background-color: var(--color-input-bg);
    color: var(--color-text);
}

html.dark select.inter-input {
    background-color: var(--color-input-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231dd1a1'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

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='%231dd1a1'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

html.dark .combo-list {
    background: var(--color-surface);
}

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

html.dark .pill {
    background-color: var(--color-surface);
    color: var(--theme-color);
}

html.dark .toggle-btn {
    background: var(--color-surface);
    color: var(--color-text);
}

html.dark .toggle-btn.active {
    background-color: var(--theme-color);
    color: #fff;
}

html.dark .year-btn {
    background: var(--color-surface);
    color: var(--color-text);
}

html.dark .year-btn.active {
    background-color: var(--theme-color);
    color: #fff;
}

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(--theme-color-light);
}

html.dark cta {
    border-color: var(--color-surface);
}

html.dark .checkbox-label input[type="checkbox"] {
    background: var(--color-input-bg);
}

html.dark .checkbox-label input[type="checkbox"]:checked {
    background: var(--color-input-bg);
}

html.dark .merge-cb {
    background: var(--color-input-bg);
}

html.dark .status-orange { background: rgba(255,184,28,0.15); color: #ffb81c; }
html.dark .status-green { background: rgba(81,207,102,0.15); color: #51cf66; }
html.dark .status-red { background: rgba(255,107,107,0.15); color: #ff6b6b; }

html.dark .state-pending { background: rgba(255,184,28,0.15); color: #ffb81c; }
html.dark .state-accepted { background: rgba(81,207,102,0.15); color: #51cf66; }
html.dark .state-converted { background: rgba(100,149,237,0.15); color: #6495ed; }
html.dark .state-cancelled { background: rgba(255,107,107,0.15); color: #ff6b6b; }

html.dark .badge-green { background: rgba(81,207,102,0.15); color: #51cf66; }
html.dark .badge-orange { background: rgba(255,184,28,0.15); color: #ffb81c; }
html.dark .badge-grey { background: rgba(255,255,255,0.1); color: #aaa; }

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

html.dark .inter-display {
    background-color: var(--theme-color-light);
    color: var(--color-text);
}

html.dark .detail-text-card {
    background-color: var(--theme-color-light);
}

html.dark .cal-day-modal .cal-day-item {
    background: var(--theme-color-light);
}

html.dark .reassign-source-name {
    background: var(--theme-color-mid);
}

html.dark .doc-detail-loading,
html.dark .doc-detail-empty {
    color: var(--color-muted);
}


html.dark .doc-table tbody tr:hover {
    background-color: rgba(255,255,255,0.03);
}

html.dark .attachment-row input[type=file]::file-selector-button {
    background: var(--theme-color);
}

html.dark .history-diff-old {
    color: var(--color-error);
}

html.dark .history-diff-new {
    color: var(--color-success);
}

html.dark .cost-summary-table td {
    border-bottom-color: rgba(255,255,255,0.08);
}
html.dark .cost-bar {
    background: rgba(255,255,255,0.08);
}
html.dark .cost-legend {
    color: #999;
}

html.dark .cal-record:hover {
    background: var(--theme-color);
    color: #fff;
}

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

html.dark input[type=time].inter-input::-webkit-calendar-picker-indicator,
html.dark input[type=date].inter-input::-webkit-calendar-picker-indicator,
html.dark input[type=datetime-local].inter-input::-webkit-calendar-picker-indicator {
    filter: invert(68%) sepia(85%) saturate(953%) hue-rotate(124deg) brightness(95%) contrast(90%);
}

/* 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;
}

/* ── Filter match highlight ── */

mark {
    background-color: #fff3b0;
    color: inherit;
    padding: 0;
    border-radius: 2px;
}

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

/* ── Expiration alert widget ── */

.alert-widget {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.dot-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--theme-color);
    opacity: 0.7;
}
.dot-legend-title {
    font-weight: 600;
    opacity: 1;
}
.dot-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.dot-legend-sep {
    opacity: 0.3;
}

.alert-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 0.5rem 0.7rem;
    border-left: 4px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.alert-card-ok { border-left-color: var(--color-success); }
.alert-card-warn { border-left-color: var(--color-warning); }
.alert-card-crit { border-left-color: var(--color-error); }

.alert-card-label {
    font-size: 0.75rem;
    opacity: 0.7;
    font-weight: 500;
}

.alert-card-count {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
}

.alert-card-ok .alert-card-count { color: var(--color-success); }
.alert-card-warn .alert-card-count { color: var(--color-warning); }
.alert-card-crit .alert-card-count { color: var(--color-error); }

/* Validity dots in table row */
.validity-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    vertical-align: middle;
    margin-left: 0.3rem;
}

.validity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.validity-dot-green { background-color: var(--color-success); }
.validity-dot-orange { background-color: var(--color-warning); }
.validity-dot-red { background-color: var(--color-error); }
.validity-dot-grey { background-color: var(--color-muted); }

/* ── Hamburger Menu (hidden on desktop) ── */

.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    z-index: 25;
    padding: 0.5rem;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
}

.nav-hamburger.open span:nth-child(2) {
    opacity: 0;
}

.nav-hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(4px, -4px);
}

/* ── Mobile Responsive ── */

@media (max-width: 768px) {
    :root {
        --nav-height: 3.5rem;
        --content-padding: 1rem;
    }

    .nav-hamburger {
        display: flex;
    }

    /* Logo smaller on mobile */
    .logo {
        left: 1rem;
    }

    .logo-nav {
        height: calc(var(--nav-height) - 1rem);
    }

    /* Nav links become vertical drawer */
    .nav-links {
        position: fixed !important;
        top: var(--nav-height) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: var(--color-surface);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 0;
        gap: 0;
        overflow-y: auto;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        z-index: 25;
    }

    .nav-links.mobile-open {
        transform: translateX(0);
    }

    .nav-link {
        color: var(--color-text);
        opacity: 1;
        font-size: 1rem;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--color-border);
    }

    .nav-link-active {
        border-bottom-color: var(--color-border);
        color: var(--theme-color);
        font-weight: 700;
    }

    .nav-link-icon {
        color: var(--theme-color);
    }

    .nav-chevron {
        color: var(--theme-color);
    }

    /* Dropdowns: click to expand on mobile */
    .nav-dropdown-menu {
        position: static;
        transform: none;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0 0 0 1.5rem;
        min-width: 0;
        display: none;
        background: transparent;
    }

    .nav-dropdown:hover .nav-dropdown-menu {
        opacity: 1;
        visibility: visible;
        display: none;
    }

    .nav-dropdown.mobile-expanded .nav-dropdown-menu {
        display: block;
    }

    .nav-dropdown-menu::before {
        display: none;
    }

    .nav-dropdown-item {
        padding: 0.6rem 1rem;
        font-size: 0.95rem;
        min-height: 44px;
        color: var(--color-text);
    }

    .nav-dropdown-item .nav-link-icon {
        color: var(--theme-color);
    }

    .nav-dropdown-item:hover {
        background: var(--theme-color-light);
    }

    .nav-dropdown-item-active {
        color: var(--theme-color);
        background: var(--theme-color-light);
    }

    /* Nav user section: hide from main nav, keep icons visible */
    .nav-user {
        position: absolute;
        right: 3.5rem;
        bottom: auto;
        top: 50%;
        transform: translateY(-50%);
        gap: 0.3rem;
    }

    .nav-user > svg.nav-link-icon,
    .nav-user .nav-role,
    .nav-user .nav-impersonate-icon {
        display: none;
    }

    /* Page title */
    h1 {
        font-size: 1.2rem;
    }

    /* Tables: card view */
    .link-table {
        min-width: 0 !important;
    }

    .link-table colgroup,
    .link-table thead {
        display: none;
    }

    .link-table tbody tr {
        display: block;
        background: var(--color-surface);
        border: 1px solid var(--color-modal-border);
        border-radius: var(--radius);
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        box-shadow: var(--shadow-sm);
    }

    .link-table tbody tr.row-highlight:hover {
        background-color: var(--color-surface) !important;
    }

    .link-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        padding: 0.2rem 0;
        border-bottom: none;
        font-size: 0.9rem;
    }

    .link-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--theme-color);
        opacity: 0.7;
        flex-shrink: 0;
        margin-right: 0.5rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .link-table tbody td:empty {
        display: none;
    }

    .link-table tbody td[data-label=""]::before,
    .link-table tbody td:last-child::before {
        display: none;
    }

    .link-table tbody td:last-child {
        justify-content: flex-end;
        padding-top: 0.5rem;
        margin-top: 0.3rem;
        border-top: 1px solid var(--color-table-border);
    }

    /* Filter row: hide on mobile (search bar is enough) */
    .filter-row {
        display: none !important;
    }

    content.main {
        overflow-x: hidden;
    }

    /* Forms: full-width */
    #edit-form {
        left: 0 !important;
        width: 100% !important;
        top: var(--nav-height) !important;
        max-height: calc(100vh - var(--nav-height)) !important;
    }

    #inter-form-container {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .form-row-half {
        flex-direction: column;
        gap: 0;
    }

    .form-row-half > .form-col {
        margin-bottom: 0.75rem;
    }

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

    .form-actions .cta-button {
        width: 100%;
        justify-content: center;
    }

    /* Detail modals: full-width */
    #detail-modal,
    #detail-panel,
    #req-detail-panel {
        left: 0 !important;
        width: 100% !important;
        top: var(--nav-height) !important;
        max-height: calc(100vh - var(--nav-height)) !important;
    }

    .detail-container,
    #detail-panel-container,
    #req-detail-panel-container {
        border-radius: 0;
        border: none;
    }

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

    /* Mini modals */
    .mini-modal {
        padding-top: var(--nav-height);
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .mini-modal-container {
        width: 100%;
        max-width: 100%;
    }

    .history-diff-container {
        width: 100%;
    }

    .detail-history-row {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .detail-history-action {
        min-width: auto;
    }

    /* Touch-friendly tap targets */
    .icon-row .icon {
        width: 2rem;
        height: 2rem;
        padding: 0.4rem;
    }

    .icon-row {
        gap: 4px;
    }

    .toolbar-actions .icon {
        width: 2rem;
        height: 2rem;
        padding: 0.4rem;
    }

    .clickable:hover {
        transform: none;
    }

    .year-btn {
        min-height: 2.4rem;
        padding: 0 0.6rem;
        font-size: 0.8rem;
    }

    .year-filter {
        gap: 0.25rem;
    }

    /* FAB — keep desktop size for easy tap */

    /* Combobox items taller for touch */
    .combo-item {
        padding: 0.6rem 0.5rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    /* Calendar */
    .calendar-grid .cal-day {
        min-height: 3.5rem;
        padding: 0.2rem;
    }

    .cal-day-number {
        font-size: 0.7rem;
    }

    .cal-record {
        font-size: 0.6rem;
        padding: 1px 3px;
    }

    .calendar-grid .cal-header {
        font-size: 0.7rem;
        padding: 0.3rem 0.15rem;
    }

    .cal-day-modal {
        max-width: 95vw;
        width: 95%;
    }

    /* Footer */
    footer {
        min-width: 0;
    }

    version {
        font-size: 0.6rem;
    }

    /* Search */
    .search-wrap {
        margin-top: 0.5rem;
    }

    /* Landing page */
    .banner {
        max-width: 80vw;
        margin-top: 5%;
    }
}

@media (max-width: 480px) {
    .year-btn {
        font-size: 0.75rem;
        padding: 0 0.4rem;
        min-height: 2.2rem;
    }

    .nav-user {
        right: 3rem;
    }

    .nav-user .dark-toggle,
    .nav-user .nav-separator,
    .nav-user .nav-logout-icon {
        display: flex;
    }

    .nav-user .nav-toolbar-icon {
        display: none;
    }
}

