:root {
    --bg: #f5f4f2;
    --surface: #ffffff;
    --surface-muted: #faf9f7;
    --border: #e7e3dd;
    --border-strong: #d8d3cb;
    --text: #1f2330;
    --text-muted: #6b7180;
    --accent: #e84e3c;
    --accent-hover: #d6402f;
    --accent-soft: #fdecea;
    --danger: #c53b2c;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Auth (login) ---------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 40px 36px 32px;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
}

.auth-title {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-error {
    background: var(--accent-soft);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.auth-error:empty {
    display: none;
}

.auth-error ul {
    margin: 0;
    padding-left: 18px;
}

.auth-footer {
    margin: 24px 0 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ---------- Form fields ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.field-input {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-input.input-validation-error {
    border-color: var(--danger);
}

.field-error {
    color: var(--danger);
    font-size: 12px;
    min-height: 1em;
}

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-muted);
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    margin: 0;
}

.link-muted {
    color: var(--text-muted);
}

.link-muted:hover {
    color: var(--text);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-outline {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-outline:hover {
    border-color: var(--text);
}

.btn-block {
    width: 100%;
    padding-block: 12px;
}

/* ---------- Plain page (dashboard placeholder) ---------- */

.page-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.page-card {
    width: 100%;
    max-width: 560px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 36px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.page-logo {
    width: 44px;
    height: 44px;
}

.page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.page-subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.page-body {
    color: var(--text-muted);
    margin: 16px 0 24px;
}

/* ---------- Authenticated app shell ---------- */

.app-body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: 80px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    background: var(--bg);
}

/* Sidebar */

.app-sidebar {
    grid-area: sidebar;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px 16px;
    position: relative;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0 20px;
}

.app-sidebar-brand img {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
}

.app-nav-item:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.app-nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.app-nav-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: currentColor;
}

.app-nav-group {
    margin-top: 2px;
}

.app-nav-group summary {
    list-style: none;
    cursor: pointer;
}

.app-nav-group summary::-webkit-details-marker {
    display: none;
}

.app-nav-summary {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-nav-chevron {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform 120ms ease;
    color: var(--text-muted);
}

.app-nav-group[open] .app-nav-chevron {
    transform: rotate(180deg);
}

.app-nav-sub {
    padding-left: 30px !important;
    font-size: 13px;
}

.app-recent {
    margin-top: 28px;
}

.app-recent-title {
    margin: 0 12px 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0.01em;
}

.app-recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-recent-list li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
}

.app-recent-list li a:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.app-recent-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    color: var(--text-muted);
}

.app-recent-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar-collapse {
    margin-top: auto;
    align-self: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.app-sidebar-collapse:hover {
    background: #fbdcd8;
}

.app-sidebar-collapse svg {
    width: 16px;
    height: 16px;
}

/* Collapsed sidebar: icons only, no labels or "Recently viewed". */

.app-body.sidebar-collapsed {
    grid-template-columns: 72px 1fr;
}

.sidebar-collapsed .app-sidebar {
    padding-left: 10px;
    padding-right: 10px;
}

.sidebar-collapsed .app-sidebar-brand img {
    width: 36px;
    height: 36px;
}

.sidebar-collapsed .app-nav-item,
.sidebar-collapsed .app-nav-summary {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-collapsed .app-nav-item > span {
    display: none;
}

.sidebar-collapsed .app-nav-chevron,
.sidebar-collapsed .app-nav-sub,
.sidebar-collapsed .app-recent {
    display: none;
}

.sidebar-collapsed .app-sidebar-collapse svg {
    transform: rotate(180deg);
}

/* Topbar */

.app-topbar {
    grid-area: topbar;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--bg);
    border-bottom: 1px solid transparent;
}

.app-search {
    flex: 0 1 360px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.app-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.app-search-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.app-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    color: var(--text);
}

.app-search-input::placeholder {
    color: var(--text-muted);
}

.app-create-menu {
    position: relative;
    display: inline-flex;
}

.app-create {
    height: 40px;
    padding: 0 16px;
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface);
    gap: 6px;
}

.app-create:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.app-create svg {
    width: 16px;
    height: 16px;
}

.app-topbar-spacer {
    flex: 1;
}

/* ---------- Top-bar case timer ---------- */

.app-timer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    padding: 0 4px 0 14px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    color: var(--accent);
    white-space: nowrap;
}

.app-timer-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
}

.app-timer-time {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.02em;
}

.app-timer-case {
    color: var(--accent);
    opacity: 0.85;
    font-size: 13px;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-timer-stop-form {
    display: inline-flex;
    margin: 0;
}

.app-timer-stop {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.app-timer-stop:hover {
    background: var(--accent-hover);
}

.app-timer-stop svg {
    width: 16px;
    height: 16px;
}

.case-timer-start-form {
    display: inline-flex;
    margin: 0;
}

.case-timer-start svg {
    width: 16px;
    height: 16px;
}

/* Idle "Start timer" control + its case-picker popover */

/* Reciprocal (incoming) related-company marker, shown instead of edit/delete */
.related-mirror {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
}

.related-mirror svg {
    width: 15px;
    height: 15px;
}

.app-timer-start {
    position: relative;
    display: inline-flex;
}

.app-timer-start-btn {
    height: 40px;
    padding: 0 16px;
    gap: 8px;
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface);
}

.app-timer-start-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

/* Compound selector so this padding beats the later, equal-specificity
   `.menu-list { padding: 4px }` base rule. */
.menu-list.menu-list-timer {
    width: 320px;
    gap: 14px;
    padding: 20px;
}

.menu-list-timer .timer-start-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
}

.menu-list-timer .field-label {
    margin-bottom: 2px;
}

.menu-list-timer .timer-start-submit {
    margin-top: 4px;
}

.app-bell {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-bell:hover {
    background: var(--surface);
    color: var(--text);
}

.app-bell svg {
    width: 20px;
    height: 20px;
}

.app-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 4px;
}

.app-user-name {
    font-size: 14px;
    color: var(--text);
}

.app-user-logout {
    display: inline-flex;
    margin: 0;
}

.app-user-logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-user-logout-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.app-user-logout-btn svg {
    width: 18px;
    height: 18px;
}

/* Main content */

.app-main {
    grid-area: main;
    padding: 0 24px 24px;
    overflow: auto;
}

.app-content-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    min-height: calc(100vh - 80px - 24px);
    padding: 32px;
}

/* ---------- Page-level chrome shared across feature pages ---------- */

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.page-toolbar .page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.page-toolbar .btn svg {
    width: 16px;
    height: 16px;
}

.page-help {
    color: var(--text-muted);
    margin: 0 0 24px;
    font-size: 14px;
}

.empty-state {
    color: var(--text-muted);
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 24px;
    text-align: center;
    font-size: 14px;
}

/* Empty message shown inside a table, so the headers (and column cog) stay available. */
.data-table td.empty-row {
    color: var(--text-muted);
    text-align: center;
    padding: 22px;
    font-size: 14px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead th {
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
}

.data-table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

/* ---------- Sortable table headers ---------- */

.data-table th.sortable {
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--text);
}

.data-table th.sortable .th-label {
    vertical-align: middle;
}

.data-table th.sortable .sort-ind {
    display: inline-flex;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.35;
    transition: opacity 120ms ease, transform 120ms ease;
}

.data-table th.sortable .sort-ind svg {
    width: 12px;
    height: 12px;
}

.data-table th.sortable:hover .sort-ind {
    opacity: 0.65;
}

.data-table th.sortable.is-asc .sort-ind,
.data-table th.sortable.is-desc .sort-ind {
    opacity: 1;
    color: var(--text);
}

.data-table th.sortable.is-asc .sort-ind {
    transform: rotate(180deg);
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 540px;
}

.form-actions {
    display: flex;
    gap: 12px;
}

.btn[disabled],
.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

select.field-input {
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---------- Searchable combobox ---------- */

.combobox {
    position: relative;
}

.combobox-input {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7180' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
}

.combobox-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    max-height: 320px;
    overflow-y: auto;
    z-index: 10;
    display: none;
}

.combobox.is-open .combobox-list {
    display: block;
}

.combobox-item.is-hidden,
.combobox-empty.is-hidden,
.combobox-list.is-hidden {
    display: none;
}

.combobox-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
}

.combobox-item:hover,
.combobox-item.is-active {
    background: var(--accent-soft);
}

.combobox-item-name {
    font-size: 14px;
    color: var(--text);
}

.combobox-item-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- Customer detail page ---------- */

.customer-detail {
    padding: 28px 32px 32px;
}

.customer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.customer-name {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.customer-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 14px;
}

.customer-meta strong {
    font-weight: 500;
    color: var(--text);
}

.customer-meta-sep {
    color: var(--border-strong);
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin: 0 0 24px;
    overflow-x: auto;
    /* Keep horizontal scrolling but hide the scrollbar (it overlaps the tab row). */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* old Edge/IE */
}

.tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.tab {
    flex: 0 0 auto;
    padding: 12px 18px;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    text-decoration: none;
    white-space: nowrap;
    transition: color 120ms ease, border-color 120ms ease;
}

a.tab:hover {
    color: var(--text);
    text-decoration: none;
}

.tab.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

.tab.is-disabled {
    color: var(--text-muted);
    cursor: default;
    opacity: 0.7;
}

.customer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: 24px;
    align-items: start;
}

/* Right column labels (project / documents info) need more room than the
   default split so they stay on one line, matching the design. */
.customer-grid-col + .customer-grid-col .info-row {
    grid-template-columns: minmax(150px, 1fr) minmax(0, 1.05fr);
}

@@media (max-width: 960px) {
    .customer-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.customer-grid-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
}

.info-card-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 600;
}

.info-list {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.info-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.6fr) minmax(0, 1fr);
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:first-child {
    padding-top: 4px;
}

.info-row:last-child {
    padding-bottom: 4px;
    border-bottom: none;
}

.info-card-title + .info-list .info-row:first-child {
    padding-top: 0;
}

.info-label {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.info-value {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    word-break: break-word;
}

.info-value a {
    color: var(--accent);
}

.info-empty {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.customer-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ---------- Section card (pink header strip + body) ---------- */

.section-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    overflow: hidden;
}

.section-card + .section-card {
    margin-top: 20px;
}

.docs-grid .section-card + .section-card {
    margin-top: 0;
}

.section-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: #f7f3f2;
    border-bottom: 1px solid var(--border);
}

.section-card-header svg {
    width: 18px;
    height: 18px;
    color: var(--text);
}

.section-card-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ---------- Section drag & drop reordering ---------- */

.tab[draggable="true"] {
    cursor: grab;
}

.tab.dragging {
    opacity: 0.4;
}

.tab.drop-target {
    background: var(--accent-soft);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.section-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: grab;
    flex: 0 0 auto;
}

.section-drag-handle:hover {
    background: var(--surface);
    color: var(--text);
}

.section-drag-handle:active {
    cursor: grabbing;
}

.section-card-header .section-drag-handle svg {
    width: 16px;
    height: 16px;
    color: inherit;
}

.section-anchor.dragging {
    opacity: 0.5;
}

.section-anchor.drop-target {
    outline: 2px dashed var(--accent);
    outline-offset: 3px;
    border-radius: var(--radius-md);
}

.section-card-body {
    padding: 20px;
}

/* ---------- Documents page ---------- */

.docs-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

@@media (max-width: 960px) {
    .docs-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.docs-grid .section-card {
    display: flex;
    flex-direction: column;
}

.docs-grid .section-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.docs-grid .dropzone-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0;
}

.docs-grid .dropzone {
    flex: 1;
}

.docs-grid .docs-review {
    /* docs-review IS the body, make it a flex column */
    display: flex;
    flex-direction: column;
}

.docs-review-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
}

.docs-card-action {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.dropzone-form {
    margin: 0;
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 28px 20px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    text-align: center;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.dropzone.is-drag-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.dropzone-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.dropzone-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.dropzone-browse svg {
    width: 16px;
    height: 16px;
}

.docs-review-count {
    margin: 0;
    color: var(--accent);
    font-size: 40px;
    font-weight: 600;
    line-height: 1.1;
}

.docs-review-caption {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.docs-card-action .btn svg {
    width: 14px;
    height: 14px;
}

/* Per-case review picker: one row per case waiting for review. */
.docs-review-cases {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.docs-review-case {
    justify-content: space-between;
    gap: 10px;
}

.docs-review-case-label {
    flex: 1;
    text-align: left;
}

.docs-review-case-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}

.docs-review-case svg {
    width: 14px;
    height: 14px;
}

.case-review-link {
    margin-top: 12px;
    width: 100%;
    justify-content: center;
    gap: 8px;
}

.case-review-link svg {
    width: 14px;
    height: 14px;
}

/* ---------- Upload progress ---------- */

/* Hide attribute beats display:flex on these elements */
.dropzone[hidden],
.docs-card-action[hidden],
.upload-progress[hidden] {
    display: none !important;
}

.upload-progress {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.upload-progress-headline {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

.upload-progress-bar {
    height: 8px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-bar-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 200ms ease;
}

.upload-progress-stats {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.upload-progress-errors {
    margin-top: 4px;
    padding: 10px 12px;
    background: var(--accent-soft);
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 12px;
    max-height: 220px;
    overflow-y: auto;
}

.upload-progress-errors ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.upload-progress-actions {
    display: flex;
    justify-content: center;
}

/* ---------- Modal ---------- */

.modal[hidden] {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    overflow: hidden;
}

.modal-form {
    margin: 0;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 28px 16px;
}

.modal-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-icon svg {
    width: 22px;
    height: 22px;
}

.modal-title {
    margin: 0 0 2px;
    font-size: 17px;
    font-weight: 600;
}

.modal-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.modal-divider {
    margin: 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 28px;
}

.field-required {
    color: var(--accent);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 28px 22px;
}

.modal-icon-warn {
    background: var(--accent-soft);
    color: var(--danger);
}

.modal-footer .btn kbd {
    margin-left: 6px;
}

/* ---------- Review page ---------- */

.review-shell {
    padding: 0;
    overflow: hidden;
}

.review-state {
    display: flex;
    flex-direction: column;
}

.review-state[hidden] {
    display: none !important;
}

.review-loading-text,
.review-empty-body {
    color: var(--text-muted);
    text-align: center;
    margin: 0 0 16px;
}

.review-empty-title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
}

.review-state[data-review-loading],
.review-state[data-review-empty],
.review-state[data-review-done] {
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 32px;
    gap: 8px;
}

.review-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    min-height: calc(100vh - 80px - 24px);
}

@@media (max-width: 1100px) {
    .review-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.review-preview {
    background: #f4f1ec;
    border-right: 1px solid var(--border);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.review-preview-frame {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.review-preview-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.review-preview-img {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
}

.review-preview-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.review-bbox {
    position: absolute;
    border-radius: 3px;
    mix-blend-mode: multiply;
    opacity: 0.32;
    pointer-events: none;
    transition: opacity 120ms ease, box-shadow 120ms ease;
}

.review-bbox.is-active {
    opacity: 0.65;
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.25);
}

.review-preview-fallback {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    margin: 0;
    padding: 24px;
}

/* Field colors, used both as input background AND bbox overlay color */
.field-c-doc-number .field-input,
.review-bbox.field-c-doc-number    { background: #fde4cd; }

.field-c-date .field-input,
.review-bbox.field-c-date          { background: #fcd5d8; }

.field-c-supplier-num .field-input,
.review-bbox.field-c-supplier-num  { background: #e3e3e3; }

.field-c-supplier-name .field-input,
.review-bbox.field-c-supplier-name { background: #fef3c7; }

.field-c-country .field-input,
.review-bbox.field-c-country       { background: #fecaca; }

.field-c-currency .field-input,
.review-bbox.field-c-currency      { background: #f3f4f6; }

.field-c-street .field-input,
.review-bbox.field-c-street        { background: #cfe7fb; }

.field-c-house .field-input,
.review-bbox.field-c-house         { background: #fef3c7; }

.field-c-postal .field-input,
.review-bbox.field-c-postal        { background: #d3d6f5; }

.field-c-city .field-input,
.review-bbox.field-c-city          { background: #e5d5f3; }

.field-c-taxable .field-input,
.review-bbox.field-c-taxable       { background: #cfdbe6; }

.field-c-vat .field-input,
.review-bbox.field-c-vat           { background: #d4eed8; }

.field-c-prorata .field-input,
.review-bbox.field-c-prorata       { background: #ffffff; }

.field-c-goods .field-input,
.review-bbox.field-c-goods         { background: #ffffff; }

/* Field grid (8-col on the right pane) */
.field-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 12px 14px;
    margin-bottom: 12px;
}

.field-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 8px 0 12px;
}

.review-progress-status {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}
.review-progress-status.is-ok   { color: #208a4f; }
.review-progress-status.is-warn { color: #b86300; }

@@media (max-width: 1300px) {
    .field-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .field-grid > .field {
        grid-column: span 4 !important;
    }
}

.review-actions {
    display: flex;
    flex-direction: column;
    padding: 24px 28px;
    gap: 16px;
    min-width: 0;
}

.review-actions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.review-doc-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.review-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
}

.review-back:hover {
    color: var(--text);
    text-decoration: none;
}

.review-back svg {
    width: 14px;
    height: 14px;
}

.review-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.review-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 500;
    font-size: 14px;
    background: var(--accent-soft);
}

.review-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.review-step-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.review-step-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.chip-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip-row .chip {
    flex: 1 1 calc(20% - 8px);
    min-width: 100px;
}

@@media (max-width: 1300px) {
    .chip-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@@media (max-width: 720px) {
    .chip-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    background: var(--surface);
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    line-height: 1.2;
    transition: background-color 120ms ease, color 120ms ease;
    min-height: 32px;
}

.chip:hover {
    background: var(--accent-soft);
}

.chip.is-selected {
    background: var(--accent);
    color: #fff;
}

.chip.is-selected .chip-badge {
    background: #fff;
    color: var(--accent);
}

.chip-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.chip-badge-empty {
    background: transparent;
}

.chip-label {
    white-space: nowrap;
}

.review-action-row {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: auto;
}

.btn-reject {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

.btn-reject:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-approve {
    background: #2e9b67;
    color: #fff;
    border: 1px solid #2e9b67;
}

.btn-approve:hover:not(:disabled) {
    background: #25855a;
    border-color: #25855a;
}

.btn-approve svg,
.btn-reject svg {
    width: 14px;
    height: 14px;
}

.review-hint {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.review-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: var(--surface-muted);
    font: inherit;
    font-size: 11px;
    color: var(--text);
    margin: 0 2px;
}

.modal-footer .btn kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: transparent;
    font: inherit;
    font-size: 11px;
}

.btn-outline kbd {
    border-color: var(--border-strong);
    color: var(--text-muted);
}

.docs-table .doc-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.doc-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: var(--text-muted);
}

.docs-table td.muted,
.data-table td.muted {
    color: var(--text-muted);
}

.data-table th.num,
.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---------- AI Usage page ---------- */

.usage-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.usage-stat {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px 18px;
}

.usage-stat-value {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.usage-stat-label {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

tr[data-row-link] {
    cursor: pointer;
    transition: background-color 120ms ease;
}

tr[data-row-link]:hover,
tr[data-row-link]:focus-visible {
    background: var(--surface-muted);
}

tr[data-row-link]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* ---------- existing combobox empty state ---------- */

.combobox-empty {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    z-index: 10;
}

.combobox:not(.is-open) .combobox-empty {
    display: none;
}

/* ---------- Customer detail: tabs as buttons ---------- */

button.tab {
    font: inherit;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

button.tab:hover {
    color: var(--text);
}

.tab-panel {
    display: block;
}

/* Single-page layout: nav scrolls to stacked sections. */
.tabs-sticky {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    margin-left: -32px;
    margin-right: -32px;
    padding-left: 32px;
    padding-right: 32px;
}

.section-anchor {
    scroll-margin-top: 70px;
}

.section-anchor + .section-anchor {
    margin-top: 24px;
}

.customer-grid {
    margin-bottom: 20px;
}

/* ---------- Reusable AJAX searchable select ---------- */

.ajax-select {
    position: relative;
}

.ajax-select-input {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7180' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
}

.ajax-select-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    max-height: 260px;
    overflow-y: auto;
    z-index: 30;
}

.ajax-select-list[hidden] {
    display: none;
}

.ajax-select-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
}

.ajax-select-item:hover,
.ajax-select-item.is-active {
    background: var(--accent-soft);
}

.ajax-select-item-label {
    font-size: 14px;
    color: var(--text);
}

.ajax-select-item-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.ajax-select-empty {
    padding: 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* Role badge in the contacts table (e.g. "Main contact", "CC"). */
.role-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.role-chip.is-paid {
    background: #d8f0df;
    border-color: #bfe6cb;
    color: #1f7a44;
}

/* ---------- Case detail page ---------- */

.status-badge-lg {
    padding: 11px 18px;
    font-size: 15px;
    border-radius: 10px;
}

/* The status badge doubles as the trigger button for the status picker. */
.status-picker {
    position: relative;
    display: inline-flex;
}

button.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    transition: filter 0.12s ease;
}

button.status-badge:hover {
    filter: brightness(0.96);
}

.status-caret {
    width: 15px;
    height: 15px;
    opacity: 0.7;
    transition: transform 0.15s ease;
}

button.status-badge[aria-expanded="true"] .status-caret {
    transform: rotate(180deg);
}

/* Status picker dropdown: each option is a full-width coloured pill. */
.status-menu {
    min-width: 250px;
    gap: 4px;
    padding: 8px;
}

.status-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    transition: filter 0.12s ease;
}

.status-option:hover {
    filter: brightness(0.95);
}

.status-option.is-current {
    box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.18);
}

.status-check {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.avatar-muted {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.responsible {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ext-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    font-weight: 500;
}

.ext-link svg {
    width: 14px;
    height: 14px;
}

a.ext-link:hover {
    text-decoration: underline;
}

/* ---------- Header split button + dropdown menu ---------- */

.split-btn {
    position: relative;
    display: inline-flex;
}

/* Outlined accent button used for the header "Edit" split control. */
.btn-edit {
    background: var(--surface);
    color: var(--accent);
    border-color: var(--accent);
}

.btn-edit:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.split-btn > .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.split-btn-caret {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid var(--accent);
    padding-left: 10px;
    padding-right: 10px;
}

.split-btn-caret svg {
    width: 16px;
    height: 16px;
}

.menu-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 230px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    padding: 4px;
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.menu-list[hidden] {
    display: none;
}

/* Left-anchored variant for menus whose trigger sits on the left (header Create). */
.menu-list-left {
    right: auto;
    left: 0;
    min-width: 180px;
}

.menu-item {
    display: block;
    text-align: left;
    text-decoration: none;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    color: var(--text);
}

.menu-item:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.menu-item[disabled] {
    color: var(--text-muted);
    cursor: default;
}

.menu-item[disabled]:hover {
    background: transparent;
    color: var(--text-muted);
}

/* Width:100% so a menu-item button inside a wrapping form still fills the menu. */
.menu-list form {
    margin: 0;
}

.menu-list form .menu-item {
    width: 100%;
}

.menu-item-danger {
    color: var(--danger);
}

.menu-item-danger:hover {
    background: var(--accent-soft);
    color: var(--danger);
}

.menu-item-icon {
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-item-icon svg {
    width: 16px;
    height: 16px;
}

.menu-divider {
    height: 0;
    margin: 4px 6px;
    border: none;
    border-top: 1px solid var(--border);
}

/* ---------- Editable info cards + icon buttons ---------- */

.info-card-editable {
    position: relative;
}

.card-edit-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms ease, background-color 120ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.info-card-editable:hover .card-edit-btn,
.card-edit-btn:focus-visible {
    opacity: 1;
}

.card-edit-btn:hover {
    background: var(--accent-soft);
}

.card-edit-btn svg {
    width: 16px;
    height: 16px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.icon-btn:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

.icon-btn-danger:hover {
    color: var(--danger);
    background: var(--accent-soft);
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.row-actions form {
    margin: 0;
    display: inline-flex;
}

/* ---------- Section card tools (in pink header) ---------- */

.section-card-header h2 {
    margin-right: auto;
}

.section-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.section-tool:hover {
    background: rgba(31, 35, 48, 0.06);
    color: var(--text);
}

.section-tool svg {
    width: 18px;
    height: 18px;
}

.section-collapse-btn svg {
    transition: transform 120ms ease;
}

/* ---------- Cases column settings (cog popover) ---------- */

.col-settings {
    position: relative;
    display: inline-flex;
}

/* Cog placement for full-page tables that have no section-card header. */
.table-tools-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.page-toolbar .col-settings.col-settings-toolbar {
    margin-left: 8px;
}

.col-settings-panel {
    /* Fixed so the card's overflow:hidden can't clip it; anchored to the cog in JS. */
    position: fixed;
    z-index: 200;
    width: 250px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(31, 35, 48, 0.16);
}

.col-settings-panel[hidden] {
    display: none;
}

.col-settings-title {
    margin: 2px 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.col-settings-hint {
    margin: 0 4px 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.col-settings-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}

.col-settings-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 4px;
    border-radius: var(--radius-sm);
}

.col-settings-item:hover {
    background: rgba(31, 35, 48, 0.05);
}

.col-settings-item.dragging {
    opacity: 0.5;
}

.col-drag-handle {
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    cursor: grab;
    flex: 0 0 auto;
}

.col-settings-item.dragging .col-drag-handle,
.col-drag-handle:active {
    cursor: grabbing;
}

.col-drag-handle svg {
    width: 16px;
    height: 16px;
}

.col-settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    flex: 1 1 auto;
}

.col-settings-label input {
    cursor: pointer;
}

.data-table th[hidden],
.data-table td[hidden] {
    display: none;
}

.section-card.is-collapsed .section-card-body {
    display: none;
}

.section-card.is-collapsed .section-collapse-btn svg {
    transform: rotate(180deg);
}

.section-card-body {
    overflow-x: auto;
}

.section-card + .section-card,
.tab-panel .section-card + .section-card {
    margin-top: 20px;
}

.section-note {
    margin: 0 0 14px;
    color: var(--text);
    font-size: 14px;
}

/* ---------- Label/value pair grid (overview sections) ---------- */

.pair-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 32px;
}

@@media (max-width: 760px) {
    .pair-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.pair {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}

.pair-label {
    color: var(--text-muted);
    font-size: 14px;
}

.pair-value {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

/* ---------- Contact row (overview side panel) ---------- */

.contact-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
}

.avatar svg {
    width: 16px;
    height: 16px;
}

.avatar-sm {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
}

.contact-name {
    color: var(--accent);
    font-weight: 500;
}

.contact-email {
    color: var(--text-muted);
}

.contact-name-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.bell-on {
    margin-left: auto;
    color: #e0a400;
    display: inline-flex;
}

[data-tooltip] {
    cursor: help;
}

/* ---------- Hover/focus tooltip (see js/tooltip.js) ---------- */

.tooltip-pop {
    position: fixed;
    z-index: 1000;
    max-width: 320px;
    padding: 8px 10px;
    background: #1f2330;
    color: #fff;
    font-size: 12.5px;
    line-height: 1.45;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    pointer-events: none;
}

.tooltip-pop[hidden] {
    display: none;
}

.bell-on svg {
    width: 18px;
    height: 18px;
}

.info-card-docs-received {
    margin-bottom: 20px;
}

.docs-received {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.docs-received form {
    margin: 0;
}

/* ---------- Status badges and chips ---------- */

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge.is-pending,   .status-option.is-pending   { background: #eceae6; color: #6b7180; }
.status-badge.is-approved,  .status-option.is-approved  { background: #d8f0df; color: #1f7a44; }
.status-badge.is-entered,   .status-option.is-entered   { background: #d6e8fb; color: #1d5fa8; }
.status-badge.is-sent,      .status-option.is-sent      { background: #cdeee0; color: #1b7d5a; }
.status-badge.is-partial,   .status-option.is-partial   { background: #f7e6b0; color: #8a6400; }
.status-badge.is-answered,  .status-option.is-answered  { background: #e2dcf7; color: #5b4aa8; }
.status-badge.is-closed,    .status-option.is-closed    { background: #e2e0db; color: #6b7180; }
.status-badge.is-allchecked,.status-option.is-allchecked{ background: #f6dcc0; color: #9a5b1d; }
.status-badge.is-waiting,   .status-option.is-waiting   { background: #d3ebf6; color: #1f6f93; }
.status-badge.is-questions, .status-option.is-questions { background: #f6d9e6; color: #a13c6e; }

.initials-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 24px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.deadline-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--danger);
    font-size: 12px;
    white-space: nowrap;
}

.currency-chip,
.type-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.nowrap {
    white-space: nowrap;
}

.paid-date {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cal-icon {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex: 0 0 16px;
}

.attachment-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

/* ---------- Customer settings toggles ---------- */

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

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

.setting-label {
    font-size: 14px;
    color: var(--text);
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex: 0 0 44px;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch-track {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background-color 150ms ease;
    pointer-events: none;
}

.switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
    transition: transform 150ms ease;
}

.switch input:checked + .switch-track {
    background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
    transform: translateX(20px);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Commission sub-tabs ---------- */

.subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.subtab {
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: 999px;
    font: inherit;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}

.subtab.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 16px;
}

.pagination[hidden] {
    display: none;
}

.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.page-btn.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Anchor page buttons (server-side history pagination). */
a.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

a.page-btn:hover {
    border-color: var(--text);
    text-decoration: none;
}

.page-info {
    align-self: center;
    padding: 0 4px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ---------- Modal multi-column field rows ---------- */

.modal-field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

@@media (max-width: 560px) {
    .modal-field-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

.modal-card {
    max-height: 90vh;
    overflow-y: auto;
}

/* ---------- Inline editing (customer master-data card) ---------- */

.inline-row {
    position: relative;
}

.inline-input {
    display: none;
}

.inline-row.is-editing .inline-input {
    display: block;
}

.inline-row.is-editing .inline-display {
    display: none;
}

/* A row holding two fields side by side (e.g. start/end month). The selects are
   hidden until the row enters edit mode, so the wrapper collapses in display mode. */
.inline-pair {
    display: flex;
    gap: 8px;
}

.inline-pair .inline-input {
    flex: 1;
    min-width: 0;
}

.inline-pencil {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms ease, background-color 120ms ease;
}

.inline-row:hover .inline-pencil,
.inline-pencil:focus-visible {
    opacity: 1;
}

.inline-pencil:hover {
    background: var(--accent-soft);
}

.inline-pencil svg {
    width: 15px;
    height: 15px;
}

.inline-row.is-editing .inline-pencil {
    display: none;
}

.inline-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* The display:flex above would otherwise override the hidden attribute. */
.inline-actions[hidden] {
    display: none;
}

/* ---------- Audit history ---------- */

.audit-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audit-item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.audit-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
}

.audit-entity {
    font-weight: 500;
    color: var(--text);
}

.audit-when,
.audit-who {
    font-size: 12px;
}

.audit-who {
    margin-left: auto;
}

.audit-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 8px;
    border-radius: 999px;
}

.audit-created {
    background: #e6f4ea;
    color: #1e7d34;
}

.audit-updated {
    background: var(--accent-soft);
    color: var(--accent);
}

.audit-deleted {
    background: #fdecea;
    color: var(--danger);
}

.audit-changes {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.audit-changes li {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.audit-field {
    min-width: 140px;
    color: var(--text-muted);
}

.audit-old {
    color: var(--text-muted);
    text-decoration: line-through;
}

.audit-new {
    color: var(--text);
    font-weight: 500;
}

.audit-arrow {
    color: var(--text-muted);
}

/* ---------- Case emails section ---------- */

.email-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.email-actions-left {
    display: flex;
    gap: 8px;
}

.email-actions .btn {
    white-space: nowrap;
}

.email-search {
    max-width: 280px;
}

.email-client {
    display: flex;
    gap: 16px;
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.email-list {
    flex: 0 0 320px;
    max-height: 520px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.email-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.email-row:hover {
    background: var(--surface-muted);
}

/* display:flex above would otherwise override the hidden attribute set by search. */
.email-row[hidden] {
    display: none;
}

.email-row.is-active {
    background: var(--accent-soft);
}

.email-dir {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: var(--surface-muted);
}

.email-dir svg {
    width: 15px;
    height: 15px;
}

.email-dir-in {
    color: #1d5fa8;
}

.email-dir-out {
    color: #1f7a44;
}

.email-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.email-row-title {
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-row-sub {
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-row-meta {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.email-clip {
    width: 14px;
    height: 14px;
}

.email-badge-failed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--danger, #c0392b);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.email-detail {
    flex: 1;
    min-width: 0;
    padding: 18px 20px;
    overflow-y: auto;
    max-height: 520px;
}

.email-detail-empty {
    color: var(--text-muted);
    font-size: 13px;
}

.email-detail-titlerow {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.email-detail-subject {
    margin: 0;
    font-size: 17px;
}

.email-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
}

.email-reply-btn svg {
    width: 16px;
    height: 16px;
}

.email-detail-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.email-meta-label {
    color: var(--text-muted);
    font-weight: 500;
}

.email-detail-date {
    white-space: nowrap;
}

.email-failed-note {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: #fdecea;
    color: #8a1c10;
    font-size: 12.5px;
}

.email-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.email-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 12.5px;
    text-decoration: none;
    max-width: 240px;
}

.email-attachment-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.email-attachment-chip svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.email-attachment-chip span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-body {
    margin-top: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13.5px;
    line-height: 1.55;
}

.email-compose-error {
    margin: 4px 0 0;
    color: var(--danger, #c0392b);
    font-size: 13px;
}

@media (max-width: 760px) {
    .email-client { flex-direction: column; }
    .email-list { flex-basis: auto; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---------- Case dashboard: deadlines / follow-ups / time entries / activity ---------- */

.case-extra-grid {
    margin-top: 18px;
}

.deadline-chip.is-overdue {
    background: #fdecea;
    color: #c0392b;
    font-weight: 600;
}

.days-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f7e6b0;
    color: #8a6400;
    font-size: 12px;
    white-space: nowrap;
}

/* Finished circle toggle (empty circle / filled green check). */
.finish-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1.6px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    color: #fff;
    cursor: pointer;
    padding: 0;
}

.finish-toggle:hover {
    border-color: var(--text-muted);
}

.finish-toggle.is-on {
    background: #1f7a44;
    border-color: #1f7a44;
}

.finish-toggle svg {
    width: 13px;
    height: 13px;
}

tr.is-finished td:not(.row-actions) {
    opacity: 0.55;
}

/* Inline case timer. */
.case-timer-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
    margin-bottom: 14px;
    background: #fdecea;
    border-radius: var(--radius-sm);
}

.case-timer-form { margin: 0; }

.case-timer-stop {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--danger, #c0392b);
    color: #fff;
    border: none;
}

.case-timer-stop svg { width: 13px; height: 13px; }

.case-timer-time {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--danger, #c0392b);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.case-timer-time svg { width: 16px; height: 16px; }

.case-track-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--accent);
    border-color: var(--accent);
    margin-bottom: 14px;
}

.case-track-btn svg { width: 14px; height: 14px; }

/* Activity feed. */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-card {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.activity-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.activity-title {
    font-weight: 600;
    font-size: 14px;
}

.activity-meta {
    flex-shrink: 0;
    font-size: 12.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.activity-line {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text);
}

.activity-line-due { color: var(--danger, #c0392b); }

.activity-line-subject { color: var(--accent); }

.activity-note-actions {
    display: none;
    gap: 10px;
    margin-top: 8px;
}

.activity-card.activity-note { background: #fffaf0; }

[data-activity].is-managing .activity-note-actions {
    display: flex;
}

.activity-note-edit,
.activity-note-del {
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 12.5px;
    padding: 0;
}

.activity-note-edit { color: var(--accent); }
.activity-note-del { color: var(--danger, #c0392b); }

.activity-note-form {
    margin-top: 8px;
}

.activity-note-formactions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ---------- Document screening (Step 1) ---------- */

.docs-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@@media (max-width: 1100px) {
    .docs-grid-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.screen-group {
    margin-bottom: 22px;
}

.screen-group-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.screen-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.screen-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    transition: border-color .12s, background .12s, box-shadow .12s;
}

.screen-chip:hover {
    border-color: var(--accent);
}

.screen-chip.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.screen-chip-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    flex: none;
}

.screen-chip-label {
    line-height: 1;
}

.screen-empty {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.screening-add-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.screening-add-form .field-input {
    flex: 1;
    min-width: 180px;
}

.screening-add-form .combobox {
    flex: 1;
    min-width: 180px;
}

/* Reusable single-line, drag-to-reorder list (screening countries, document categories). */
.sortable-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.sortable-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px;
    background: #fff;
    border-top: 1px solid var(--border);
}

.sortable-row:first-child {
    border-top: none;
}

.sortable-row.dragging {
    opacity: 0.5;
}

.sortable-drag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: grab;
    flex: 0 0 auto;
}

.sortable-row:active .sortable-drag {
    cursor: grabbing;
}

.sortable-drag svg {
    width: 16px;
    height: 16px;
}

.sortable-index {
    width: 1.5rem;
    color: var(--text-muted);
    font-size: 13px;
    flex: 0 0 auto;
}

.sortable-label {
    flex: 1;
}

.sortable-delete {
    margin-left: auto;
    flex: 0 0 auto;
    opacity: 0;
    transition: opacity .12s;
}

.sortable-row:hover .sortable-delete,
.sortable-delete:focus-within {
    opacity: 1;
}

.sortable-empty {
    list-style: none;
    padding: 10px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- User management (admin) ---------- */

.alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert-success {
    background: #e8f6ee;
    border-color: #bfe6cb;
    color: #1f7a44;
}

.alert-error {
    background: var(--accent-soft);
    border-color: #f3c6c0;
    color: var(--danger);
}

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

.table-search {
    margin-bottom: 14px;
}

.app-search-inline {
    max-width: 360px;
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    margin: 2px 4px 2px 0;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.col-actions .icon-btn,
.col-actions .inline-form {
    display: inline-flex;
    vertical-align: middle;
}

.user-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    margin-bottom: 16px;
}

@@media (max-width: 720px) {
    .user-form-grid {
        grid-template-columns: 1fr;
    }
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    padding-top: 4px;
}

.form-subcard {
    margin-top: 20px;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #a82f22;
}
