:root {
    /* Семантичні аліаси → brand.css */
    --bg:          var(--color-bg);
    --panel:       var(--color-panel);
    --ink:         var(--color-ink);
    --muted:       var(--color-muted);
    --line:        var(--color-line);
    --accent:      var(--color-accent);
    --accent-dark: var(--color-accent-dark);
    --accent-soft: var(--color-accent-soft);
    --danger:      var(--color-danger);
    --radius:      var(--radius-lg);
    --radius-btn:  var(--radius-md);
    /* --focus-ring наслідується з brand.css */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    /* TEST: патерн зверху, що згасає до сірого (відкат: прибрати position+body::before, лишити background: var(--bg);) */
    position: relative;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TEST: декоративний патерн-смуга зверху (точний зразок патерну), що плавно згасає у сірий фон до середини першого екрану */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60vh;
    background: url("../img/pattern-scales.5e2781ae07eb.svg") repeat;
    background-size: 1150px auto;
    opacity: 0.092;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.55) 45%, rgba(0,0,0,0) 100%);
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.55) 45%, rgba(0,0,0,0) 100%);
    pointer-events: none;
    z-index: -1;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    line-height: var(--leading-snug);
}

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

a:hover {
    text-decoration: underline;
}

/* ─── Navbar ─────────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 24px;
    height: 72px;
    background: #fff;
    border-bottom: 0.5px solid #e8e8e8;
}

.nav-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

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

.nav-logo-img {
    height: 52px;
    width: auto;
    display: block;
}

.nav-center {
    display: flex;
    gap: 2px;
    justify-content: center;
    align-self: stretch;      /* блок меню — на всю висоту навбару */
    align-items: stretch;     /* пункти теж на всю висоту */
}

.nav-link {
    display: inline-flex;
    align-items: center;      /* текст по центру повної висоти */
    font-size: 13px;
    color: #555;
    padding: 0 14px;          /* лише горизонтальний відступ; висота — на всю кнопку */
    border-radius: 0;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.1s, color 0.1s;
}

.nav-link:hover {
    background: #f5f5f5;
    color: #1a1a1a;
    text-decoration: none;
}

.nav-emoji {
    font-size: 14px;
    margin-right: 2px;
    line-height: 1;
}

.nav-link.is-active {
    background: #f0f0ff;
    color: var(--accent);
    font-weight: 500;
}

.nav-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.nav-create-wrap {
    position: relative;
}

.nav-create-button,
.nav-email-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-btn);
    font-weight: 800;
    line-height: 1;
}

.nav-create-button {
    color: #ffffff;
    background: var(--accent);
    border: 1px solid var(--accent);
    cursor: pointer;
    font-size: 24px;
}

.nav-create-button:hover,
.nav-create-button[aria-expanded="true"] {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.nav-create-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 290px;
    background: #fff;
    border: 0.5px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    z-index: 250;
}

.nav-create-menu.visible {
    display: block;
}

/* ── Settings dropdown (nav-center) ── */
.nav-settings-wrap {
    position: relative;
    display: inline-flex;     /* тогл «Налаштування» — на всю висоту навбару */
    align-items: stretch;
}
.nav-settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    color: #555;
}
.nav-settings-toggle .nav-caret {
    transition: transform 0.15s;
}
.nav-settings-toggle[aria-expanded="true"] .nav-caret {
    transform: rotate(180deg);
}
.nav-settings-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 210px;
    background: #fff;
    border: 0.5px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    padding: 6px;
    z-index: 250;
}
.nav-settings-menu.visible {
    display: block;
}
.nav-settings-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border-radius: 7px;
    font-size: 13.5px;
    color: #333;
    text-decoration: none;
    transition: background 0.1s;
}
.nav-settings-item:hover {
    background: #f3f4ff;
    color: var(--accent);
    text-decoration: none;
}
.nav-settings-item svg {
    color: var(--accent);
    flex-shrink: 0;
}

.nav-email-icon {
    position: relative;
    color: var(--accent);
    background: #f3f3ff;
    border: 1px solid #d0d2f5;
    font-size: 17px;
    cursor: default;
}

.nav-email-icon::after {
    content: attr(data-email);
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    display: none;
    padding: 7px 10px;
    color: #ffffff;
    background: #1e1e2e;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    z-index: 300;
}

.nav-email-icon:hover::after {
    display: block;
}

.nav-logout {
    font-size: 13px;
    color: #555;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.1s, color 0.1s;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-logout:hover {
    background: #f5f5f5;
    color: #1a1a1a;
    text-decoration: none;
}

.nav-burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    padding: 6px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
}

.nav-burger:hover { background: #f5f5f5; }

.nav-burger span {
    display: block;
    height: 2px;
    background: #555;
    border-radius: 2px;
}

/* ─── Page ───────────────────────────────────────────────────── */
.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.page-content {
    flex: 1;
}

/* ─── Footer ─────────────────────────────────────────────────── */
.footer {
    background: #1e1e2e;
    color: #fff;
    margin-top: auto;
    padding: 40px 0 24px;
}

.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 40px;
}

.footer-brand {
    display: flex;
    flex-direction: column;
}

.footer-logo-img {
    height: 44px;
    width: auto;
    display: block;
    margin-bottom: 8px;
    margin-left: 0;
    filter: brightness(0) invert(1);
    align-self: flex-start;
}

.footer-desc {
    font-size: 13px;
    color: #8888aa;
    line-height: 1.6;
    margin-bottom: 24px;
    max-width: 240px;
}

.footer-copy {
    font-size: 12px;
    color: #555566;
    margin-top: auto;
}

.footer-col-title {
    font-size: 11px;
    font-weight: 600;
    color: #8888aa;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
}

.footer-link {
    display: block;
    font-size: 13px;
    color: #ccccdd;
    text-decoration: none;
    margin-bottom: 8px;
    transition: color 0.15s;
}

.footer-link:hover {
    color: #fff;
    text-decoration: none;
}

.about-hero {
    max-width: 760px;
    margin: 0 auto;
    padding: 34px 24px;
    text-align: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.about-hero h1 {
    color: var(--accent);
    font-size: 42px;
}

.about-subtitle {
    margin: 8px 0 18px;
    color: var(--muted);
    font-size: 18px;
    font-weight: 750;
}

.about-hero p:not(.eyebrow):not(.about-subtitle) {
    max-width: 620px;
    margin: 0 auto;
    color: var(--ink);
}

.about-actions {
    justify-content: center;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.15;
}

h2 {
    font-size: 18px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.panel {
    margin-bottom: 16px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

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

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 10px 8px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

tbody tr {
    transition: background 0.08s;
}

tbody tr:hover td {
    background: #f6f8ff;
}

tr.row-clickable {
    cursor: pointer;
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 13px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}

.button:hover,
button.button:hover {
    text-decoration: none;
    background: var(--accent-soft);
    border-color: #c0c8ff;
}

.button.primary,
button.button.primary {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.button.primary:hover,
button.button.primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.button.ghost,
button.button.ghost {
    color: var(--muted);
    background: transparent;
    border-color: transparent;
}

.button.ghost:hover,
button.button.ghost:hover {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-dark);
}

.button.outline {
    color: var(--accent);
    background: #ffffff;
    border-color: var(--accent);
}

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

.button.danger-button,
button.button.danger-button {
    color: var(--danger);
    background: #fff7f5;
    border-color: #ffc9c0;
}

.button.danger-button:hover,
button.button.danger-button:hover {
    color: #ffffff;
    background: var(--danger);
    border-color: var(--danger);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}

.actions.compact {
    margin-top: 0;
}

.header-actions {
    flex: 0 0 auto;
}

.save-button {
    min-height: 44px;
    padding: 10px 18px;
    box-shadow: var(--shadow-md);
}

.save-button:hover {
    box-shadow: var(--shadow-lg);
}

.messages {
    margin-bottom: 14px;
}

.message {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 11px 11px 11px 13px;
    background: var(--accent-soft);
    border: 1px solid var(--brand-blue-200);
    border-radius: var(--radius-sm);
}

.message.error {
    color: var(--danger);
    background: #fff0ed;
    border-color: #ffc9c0;
}

.message-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.message-close:hover {
    color: var(--ink);
    background: var(--accent-soft);
}

/* ── Message with doc_saved actions ───────────────────────── */
.msg-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.msg-text {
    font-weight: 500;
    flex-shrink: 0;
}
.msg-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.msg-btn-home {
    height: 32px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    background: #fff;
    border: 1px solid var(--brand-blue-200);
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.msg-btn-home:hover {
    background: var(--accent-soft);
    text-decoration: none;
    color: var(--accent);
}
.msg-create-wrap {
    position: relative;
}
.msg-btn-create {
    height: 32px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
}
.msg-btn-create:hover { background: var(--accent-dark); }
.msg-create-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.10);
    padding: 6px;
    z-index: 200;
}
.msg-create-menu.open { display: block; }
.msg-drop-item {
    display: block;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--ink);
    text-decoration: none;
    transition: background 0.1s;
}
.msg-drop-item:hover {
    background: var(--accent-soft);
    text-decoration: none;
    color: var(--accent);
}
@media (max-width: 640px) {
    .msg-content { gap: 10px; }
    .msg-actions { gap: 6px; }
    .msg-text { font-size: 13px; }
}

.form-panel {
    max-width: 980px;
}

/* Зона видалення під формою редагування */
.danger-zone {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-color: #f3c6c6;
    background: #fdf6f6;
}
.danger-zone-title {
    color: #b42318;
    font-size: 14px;
}
.danger-zone-note {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.invoice-form {
    max-width: none;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.form-grid > label {
    align-self: start;
}

.invoice-form-layout {
    display: grid;
    gap: 14px;
}

.party-field > span {
    color: var(--ink);
}

.notes-field {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid #cfd8d4;
    border-radius: var(--radius-btn);
    font: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

textarea {
    min-height: 78px;
    resize: vertical;
}

/* select: custom chevron arrow */
select.input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2366706c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

.checkbox {
    width: 18px;
    height: 18px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.field-with-tool {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 20px;
    font-weight: 800;
}

.icon-button:hover {
    color: #ffffff;
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    text-decoration: none;
}

.icon-button.is-disabled {
    color: #9aa4a0;
    background: #eef2f0;
    border-color: var(--line);
    pointer-events: none;
}

.inline-form {
    display: inline;
}

.link-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    color: var(--accent-dark);
    background: transparent;
    border: 0;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.icon-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.link-button:hover {
    text-decoration: underline;
}

.danger-link {
    color: var(--danger);
}

/* Square icon-only button (detail headers) — matches .button height */
.button.icon-only,
button.button.icon-only {
    width: 40px;
    min-width: 40px;
    padding: 0;
    gap: 0;
}

/* Compact icon action for table/list rows — proper tap target */
.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-btn);
    color: var(--accent-dark);
    background: transparent;
    border: 1.5px solid var(--line);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-action svg {
    width: 18px;
    height: 18px;
}

.icon-action:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    text-decoration: none;
}

.icon-action.danger {
    color: var(--danger);
}

.icon-action.danger:hover {
    background: #fff1ee;
    border-color: #ffc9c0;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filters-bar {
    margin-bottom: 16px;
    padding: 14px 20px;
    background: #fff;
    border: 0.5px solid #e8e8e8;
    border-radius: 12px;
}

.document-filter-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filters-row--types,
.filters-row--search {
    width: 100%;
}

.type-group {
    display: flex;
    gap: 6px;
    width: 100%;
}

.type-chip {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 0;
    color: #555;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: var(--radius-btn);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.type-chip input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

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

.type-chip.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.type-chip:focus-visible,
.type-chip:has(input:focus-visible) {
    outline: 3px solid var(--brand-blue-200);
    outline-offset: 2px;
}

.filters-row--search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    color: #bbb;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

.date-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.date-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-label {
    color: #aaa;
    font-size: 12px;
    white-space: nowrap;
}

.date-input {
    width: 132px;
    height: 38px;
    min-width: 0;
    padding: 0 10px;
    color: #1a1a1a;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    outline: none;
}

.date-input:focus {
    border-color: var(--accent);
}

.date-control .input {
    width: 132px;
    height: 38px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 13px;
}

.reset-btn {
    flex-shrink: 0;
    padding: 4px 6px;
    color: #aaa;
    background: none;
    border: 0;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.reset-btn:hover {
    color: var(--accent);
    text-decoration: none;
}

/* Перемикач сортування на сторінці документів (спершу нові / старі) */
.sort-control {
    flex-shrink: 0;
    margin: 0;
}
.sort-select {
    min-width: 150px;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* Порожні «Вхідні» — ознайомчий екран із мокапом надсилання */
.inbox-onboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
    padding: 40px 20px;
    max-width: 560px;
    margin: 0 auto;
}
.inbox-illu {
    position: relative;
    width: 100%;
    max-width: 440px;
    padding: 22px 16px;
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(45, 45, 142, 0.08);
}
.inbox-illu-badge {
    position: absolute;
    top: -10px;
    left: 16px;
    padding: 2px 10px;
    border-radius: 99px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.inbox-illu-caption {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    margin-bottom: 10px;
}
.inbox-illu-row {
    display: flex;
    gap: 8px;
}
.inbox-illu-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
}
.inbox-illu-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 12px;
}
.inbox-illu-btn--hl {
    color: var(--text);
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px rgba(45, 45, 142, 0.12);
}
.inbox-illu-pointer {
    position: absolute;
    right: 16px;
    bottom: -12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-dark);
    background: #fff;
    padding: 1px 8px;
    border-radius: 99px;
    border: 1px solid var(--line);
    white-space: nowrap;
}
.inbox-onboard-title {
    margin: 0;
    font-size: 20px;
}
.inbox-onboard-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}
.inbox-onboard-hint {
    margin: 0;
    max-width: 460px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.55;
}

/* Перемикач напряму документів: Вихідні / Вхідні */
.direction-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 16px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.dir-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: 0;
    background: none;
    border-radius: 7px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.dir-pill:hover {
    color: var(--text);
    text-decoration: none;
}
.dir-pill.is-active {
    background: var(--accent);
    color: #fff;
}
.dir-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}
.dir-pill.is-active .dir-badge {
    background: rgba(255, 255, 255, 0.3);
}
/* Посилання «Усі …» над таблицею на дашборді */
.db-dir-link {
    text-align: right;
    margin-bottom: 8px;
    font-size: 13px;
}

@media (min-width: 900px) {
    .document-filter-form {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
    }

    .filters-row--types {
        display: flex;
        align-items: center;
        width: auto;
        flex-shrink: 0;
    }

    .filters-row--types::after {
        content: "";
        display: block;
        width: 1px;
        height: 32px;
        margin-left: 12px;
        background: #e8e8e8;
    }

    .type-group {
        width: auto;
    }

    .type-chip {
        flex: none;
        padding: 7px 14px;
    }

    .filters-row--search {
        flex: 1;
    }
}

@media (max-width: 639px) {
    .filters-bar {
        padding: 12px;
    }

    .filters-row--search {
        flex-wrap: wrap;
    }

    .search-wrap {
        width: 100%;
        flex: none;
    }

    .date-group {
        flex: 1;
        min-width: 0;
    }

    .date-control {
        flex: 1;
        min-width: 0;
    }

    .date-input {
        width: 100%;
    }

    .date-control .input {
        width: 100%;
    }
}

.field-error,
.form-errors {
    color: var(--danger);
    font-size: 13px;
}

.field-hint {
    color: var(--muted);
    font-weight: 500;
}

.counterparty-picker-field {
    position: relative;
}

.counterparty-picker {
    position: relative;
    display: grid;
    gap: 6px;
}

.counterparty-selected {
    display: grid;
    gap: 2px;
    min-height: 46px;
    padding: 8px 12px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.counterparty-selected strong {
    font-size: 15px;
}

.counterparty-selected span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.counterparty-selected.is-generic-payer {
    background: var(--accent-soft);
    border-color: #bfc7ff;
}

.counterparty-results {
    display: none;
    position: absolute;
    left: -1px;
    right: -1px;
    top: calc(100% + 6px);
    z-index: 100;
    max-height: 310px;
    overflow: auto;
    padding: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
}

.counterparty-results.is-open {
    display: grid;
    gap: 4px;
}

.counterparty-result,
.counterparty-more,
.counterparty-empty {
    width: 100%;
    padding: 9px 10px;
    color: var(--ink);
    text-align: left;
    background: #ffffff;
    border: 0;
    border-radius: 5px;
    font: inherit;
}

.counterparty-result {
    display: grid;
    gap: 2px;
    cursor: pointer;
}

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

.counterparty-result span {
    color: var(--muted);
    font-size: 13px;
}

.counterparty-result.is-generic-payer {
    border: 1px solid #bfc7ff;
}

.counterparty-more {
    color: var(--accent-dark);
    font-weight: 800;
    cursor: pointer;
}

.counterparty-empty {
    color: var(--muted);
}

.items-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
}

.items-head p {
    margin: 0;
    color: var(--muted);
}

.catalog-panel,
.invoice-lines-panel {
    min-width: 0;
    padding: 14px;
    background: #f9fbfa;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.catalog-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.catalog-head p,
.items-head p {
    margin: 4px 0 0;
    color: var(--muted);
}

.catalog-search {
    margin-bottom: 10px;
}

.catalog-meta {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}

.catalog-list {
    display: grid;
    gap: 8px;
    max-height: 290px;
    overflow-y: auto;
    padding-right: 4px;
}

.catalog-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.catalog-item-text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.catalog-item strong {
    overflow-wrap: anywhere;
}

.catalog-item span {
    color: var(--muted);
    font-size: 13px;
}

button.catalog-add-button,
.button.catalog-add-button {
    min-height: 34px;
    padding: 6px 10px;
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

button.catalog-add-button:hover,
.button.catalog-add-button:hover {
    color: #ffffff;
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

button.catalog-add-button:focus-visible,
.button.catalog-add-button:focus-visible {
    color: #ffffff;
    outline: 3px solid var(--brand-blue-200);
    outline-offset: 2px;
}

.catalog-more-button {
    width: 100%;
    margin-top: 10px;
}

.catalog-more-button[hidden] {
    display: none;
}

.catalog-empty {
    margin: 8px 0;
}

.invoice-items-grid {
    display: grid;
    gap: 8px;
}

.invoice-items-header,
.invoice-item-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(72px, 0.3fr) minmax(82px, 0.35fr) minmax(108px, 0.45fr) 38px;
    gap: 8px;
    align-items: start;
}

.invoice-items-header {
    padding: 0 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.invoice-item-row {
    padding: 10px;
    background: #f9fbfa;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.invoice-item-row.is-deleted {
    display: none;
}

/* Фідбек: збільшення кількості наявної позиції при повторному «+ Додати» */
.invoice-item-row.row-bumped {
    animation: rowBump 0.45s ease;
}
@keyframes rowBump {
    0%   { background: #e6f0ff; border-color: var(--accent); }
    100% { background: #f9fbfa; border-color: var(--line); }
}

.invoice-item-row label {
    min-width: 0;
}

.item-row-nonfield {
    grid-column: 1 / -1;
    margin-top: 4px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
}

.invoice-item-row label span {
    display: none;
}

.invoice-item-row input {
    min-width: 0;
}

.hidden-form-fields {
    display: none;
}

.item-name-field {
    min-width: 0;
}

.item-row-errors {
    grid-column: 1 / -1;
}

.row-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--danger);
    background: #ffffff;
    border: 1px solid #e8c5c0;
    border-radius: 6px;
    font: inherit;
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.row-icon-button:hover {
    border-color: #d8978e;
}

.row-icon-button:disabled {
    color: #aeb8b4;
    background: #eef2f0;
    border-color: var(--line);
    cursor: not-allowed;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: stretch;
}
.detail-grid > .panel {
    align-content: flex-start;
    padding: 14px 16px;
}
.detail-grid > .panel h2 {
    margin-bottom: 2px;
}
.detail-grid .details {
    margin-top: 6px;
    gap: 6px 12px;
}
.detail-grid .detail-section-label {
    margin-top: 10px;
    margin-bottom: 6px;
}
.detail-grid .detail-section-label:first-of-type {
    margin-top: 2px;
}
.detail-grid .document-create-form {
    margin-top: 0;
}

.document-create-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    margin-top: 12px;
}

.created-documents-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.created-document-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    padding: 8px 10px;
    background: #f9fbfa;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.created-document-row span {
    font-weight: 750;
}

.compact-empty {
    margin: 12px 0 0;
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 14px;
    margin: 12px 0 0;
}

.details dt {
    color: var(--muted);
    font-weight: 700;
}

.details dd {
    margin: 0;
}

.empty,
.notes,
.helper-panel p {
    color: var(--muted);
}

/* Порожній стан переліку документів — центрований текст + заклик створити */
.docs-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    padding: 32px 16px;
}
.docs-empty-state .empty {
    margin: 0;
}

.tpl-section {
    margin: 20px 0 4px;
}

.tpl-section h3 {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #aaa;
    margin: 0 0 8px;
}

.tpl-section-hint {
    font-size: 12px;
    color: #bbb;
    margin: -4px 0 8px;
}

.tpl-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 16px;
}

.tpl-fields code {
    font-family: var(--font-mono, monospace);
    font-size: 12px;
    background: #f0f2f5;
    color: #3a3ea0;
    padding: 2px 7px;
    border-radius: 5px;
    white-space: nowrap;
    align-self: center;
}

.tpl-fields .tpl-desc {
    font-size: 13px;
    color: var(--muted);
    align-self: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    margin-left: 6px;
    padding: 5px 16px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border: 1.5px solid transparent;
    border-radius: var(--radius-btn);
    font-size: 12px;
    font-weight: 800;
}

.muted-pill {
    color: var(--muted);
    background: #eef2f0;
}

.pill--set-default {
    background: transparent;
    border: 1.5px solid var(--accent-dark);
    color: var(--accent-dark);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

/* Колонка «Стандарт» — обидва стани однакової ширини, в один рядок */
.pill-std {
    width: 220px;
    max-width: 100%;
    margin-left: 0;
    white-space: nowrap;
}
.pill-std-form {
    display: block;
    width: 220px;
    max-width: 100%;
}
.pill-std-form .pill-std {
    width: 100%;
}

.pill--set-default:hover {
    background: var(--accent-soft);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.status-form {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 26px;
    padding: 3px 9px;
    white-space: nowrap;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-select {
    width: auto;
    min-height: 30px;
    padding: 4px 28px 4px 10px;
    border: 1px solid transparent;
    border-radius: var(--radius-btn);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.status-select:focus {
    border-color: var(--accent);
    outline: 3px solid var(--brand-blue-200);
    outline-offset: 1px;
}

.status-draft {
    color: #475467;
    background: #eef2f0;
}

.status-sent {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.status-in_review {
    color: #b54708;
    background: #fef5e7;
}

.status-paid {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.status-canceled {
    color: var(--danger);
    background: #fff0ed;
}

/* Статуси вхідних рахунків */
.status-pending {
    color: #475467;
    background: #eef2f0;
}
.status-rejected {
    color: var(--danger);
    background: #fff0ed;
}

/* Вхідний рахунок: вибір статусу отримувачем */
.inbox-status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.inbox-status-btn {
    cursor: pointer;
    border: 1.5px solid transparent;
    font-weight: 600;
}
.inbox-status-btn.is-active {
    border-color: currentColor;
    box-shadow: 0 0 0 1px currentColor inset;
}

/* Реквізити для оплати з копіюванням */
.pay-reqs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.pay-req-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
}
.pay-req-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pay-req-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.pay-req-value {
    font-size: 14px;
    color: var(--ink);
    word-break: break-all;
}
.pay-req-copy {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 13px;
}
.pay-req-copy.is-copied {
    color: var(--color-success);
    border-color: var(--color-success);
}

/* Квитанція оплати (у вхідному) */
.receipt-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--color-success-bg, #e9fbf1);
}
.receipt-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
}

/* Статус у отримувачів (на сторінці рахунку відправника) */
.delivery-statuses {
    margin-top: 16px;
}
.delivery-status-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
}
.delivery-status-row:last-child {
    border-bottom: 0;
}
.delivery-recipient {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--ink);
    word-break: break-all;
}
.delivery-receipt-link {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* Коментар відхилення */
.reject-comment {
    margin-top: 10px;
    padding: 8px 12px;
    border: 1px solid #f3c6c6;
    border-radius: 8px;
    background: #fdf6f6;
}
.reject-comment-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #b42318;
    margin-bottom: 2px;
}
.reject-comment p {
    margin: 0;
    font-size: 14px;
    color: var(--ink);
    white-space: pre-wrap;
}
.reject-detail {
    font-size: 13px;
}
.reject-detail summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--danger);
    white-space: nowrap;
    list-style: none;
}
.reject-detail summary::-webkit-details-marker {
    display: none;
}
.reject-detail-body {
    flex-basis: 100%;
    margin-top: 6px;
    padding: 8px 12px;
    border: 1px solid #f3c6c6;
    border-radius: 8px;
    background: #fdf6f6;
    font-size: 14px;
    color: var(--ink);
    white-space: pre-wrap;
}

.status-submit {
    min-height: 30px;
    padding: 4px 8px;
    font-size: 12px;
}

.status-settings-dialog {
    width: min(660px, calc(100% - 28px));
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.status-settings-dialog::backdrop {
    background: rgba(20, 30, 90, 0.30);
}

.status-settings-form {
    display: grid;
    gap: 12px;
}

.status-settings-form .panel-title {
    margin-bottom: 0;
}

.status-settings-grid {
    display: grid;
    grid-template-columns: 110px 96px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
}

.status-grid-head {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    align-self: end;
    padding-bottom: 2px;
}

/* Великий чекбокс «стандартний» — на всю клітинку, як інпут емоджі */
.status-default-choice {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-btn);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}
.status-default-choice input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}
.status-check {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid #c7d0e8;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.status-default-choice:hover { border-color: var(--accent); }
.status-default-choice:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.status-default-choice:has(input:checked) .status-check {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.status-default-choice:has(input:focus-visible) {
    outline: 3px solid var(--brand-blue-200);
    outline-offset: 2px;
}

code {
    padding: 2px 5px;
    background: #eef2f0;
    border-radius: 5px;
}

@media (max-width: 560px) {
    .status-settings-grid {
        grid-template-columns: 48px 58px minmax(0, 1fr);
        gap: 8px;
    }

    .status-grid-head { display: none; }

    .quick-counterparty-grid {
        grid-template-columns: 1fr;
    }

    .party-label-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

}

@media (max-width: 860px) {
    .navbar {
        grid-template-columns: 1fr auto;
        height: auto;
        padding: 10px 16px;
        flex-wrap: wrap;
        position: sticky; /* залишаємо sticky — меню дропдаун виходить через fixed */
        overflow: visible;
    }

    .nav-center {
        display: none;
        position: fixed;
        top: var(--navbar-h, 52px);
        left: 0;
        right: 0;
        flex-direction: column;
        background: #fff;
        border-bottom: 0.5px solid #e8e8e8;
        padding: 8px 12px 12px;
        gap: 2px;
        z-index: 100;
    }

    .nav-center.is-open {
        display: flex;
    }

    .nav-link {
        width: 100%;
        padding: 10px 12px;
    }

    .nav-settings-wrap {
        width: 100%;
    }
    .nav-settings-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 10px 12px;
    }
    .nav-settings-menu {
        position: static;
        display: block;
        box-shadow: none;
        border: none;
        padding: 0 0 4px 14px;
        min-width: 0;
    }

    .nav-burger {
        display: inline-flex;
    }

    .nav-logo-img {
        height: 42px;
    }

    .nav-create-menu {
        right: -56px;
        min-width: min(290px, calc(100vw - 24px));
    }

    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .section-header,
    .items-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .button {
        flex: 1 1 150px;
    }

    /* Detail-page action rows: take full width so labelled buttons wrap
       cleanly in pairs instead of stretching or breaking onto two text lines */
    .section-header .actions {
        width: 100%;
    }

    .section-header .actions .button:not(.icon-only) {
        white-space: nowrap;
    }

    .form-grid,
    .document-create-form {
        grid-template-columns: 1fr;
    }

    .footer-inner {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .about-hero h1 {
        font-size: 34px;
    }

    .document-create-form .button {
        width: 100%;
    }

    .created-document-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .invoice-items-header {
        display: none;
    }

    .invoice-item-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
    }

    .invoice-item-row label span {
        display: block;
    }

    .item-name-field {
        grid-column: 1 / -1;
    }

    .row-remove-button {
        grid-column: 3;
        grid-row: 2;
    }
}

@media (max-width: 520px) {
    .invoice-item-row {
        grid-template-columns: minmax(0, 1fr) 38px;
    }

    .item-name-field,
    .invoice-item-row label:nth-of-type(2),
    .invoice-item-row label:nth-of-type(3),
    .invoice-item-row label:nth-of-type(4) {
        grid-column: 1 / -1;
    }

    .row-remove-button {
        grid-column: 2;
        grid-row: 1;
        align-self: end;
    }
}

/* ─── Flatpickr date picker theme ──────────────────────────── */
.flatpickr-calendar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-sans);
    font-size: 14px;
    width: 320px;
    padding: 0 0 10px;
}

.flatpickr-calendar.arrowTop::before {
    border-bottom-color: var(--line);
}

.flatpickr-calendar.arrowTop::after {
    border-bottom-color: var(--accent);
}

/* Header bar — single flex row: ‹ [month ▾] ‹ year › › */
.flatpickr-months {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--accent);
    border-radius: var(--radius) var(--radius) 0 0;
    height: 52px;
    padding: 0 8px;
    gap: 6px;
}

/* override flatpickr's absolute-positioned month nav arrows */
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    width: 34px;
    height: 34px;
    padding: 0;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85) !important;
    fill: rgba(255, 255, 255, 0.85) !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff !important;
    fill: #ffffff !important;
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: #ffffff;
}

.flatpickr-month {
    flex: 1 1 auto;
    background: transparent;
    color: #ffffff;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flatpickr-current-month {
    position: static;
    left: auto;
    right: auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    height: 52px;
    padding: 0;
    transform: none;
}

/* hide native year spinner — replaced by .fp-year-ctrl injected via JS */
.flatpickr-current-month input.cur-year,
.flatpickr-current-month .numInputWrapper {
    display: none !important;
}

/* Custom year control: ‹ 2026 › */
.fp-year-ctrl {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 2px 3px;
    flex: 0 0 auto;
}

.fp-yr-arrow {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    width: 22px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.fp-yr-arrow:hover {
    background: rgba(255, 255, 255, 0.25);
}

.fp-year-num {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    min-width: 40px;
    text-align: center;
    line-height: 1;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    appearance: none;
    -webkit-appearance: none;
    color: #ffffff !important;
    font-weight: 700;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.15) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 6px center !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    height: 30px;
    line-height: 30px;
    text-align: left;
    padding: 0 24px 0 10px;
    flex: 0 0 auto;
}

.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month {
    color: var(--ink);
    background: #ffffff;
}

.flatpickr-weekdays {
    background: var(--accent-soft);
    border-bottom: 1px solid #dae0ff;
    padding: 4px 8px 2px;
}

span.flatpickr-weekday {
    background: transparent;
    color: var(--accent-dark);
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.flatpickr-days {
    border-left: none;
    border-right: none;
    width: 100%;
}

.dayContainer {
    padding: 8px 10px 4px;
    width: 100%;
    min-width: 100%;
    max-width: 100%;
}

.flatpickr-day {
    color: var(--ink);
    border-radius: var(--radius-btn);
    border: 1px solid transparent;
    max-width: 40px;
    height: 38px;
    line-height: 38px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.1s, color 0.1s;
}

.flatpickr-day:hover {
    background: var(--accent-soft);
    border-color: var(--accent-soft);
    color: var(--accent-dark);
}

.flatpickr-day.today {
    border-color: var(--accent);
    color: var(--accent-dark);
    font-weight: 800;
}

.flatpickr-day.today:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
    font-weight: 800;
}

.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: #c8d0cd;
    cursor: not-allowed;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #bbc4c0;
}

/* Responsive — keep calendar inside the viewport on phones/tablets */
@media (max-width: 420px) {
    .flatpickr-calendar {
        width: calc(100vw - 24px) !important;
        max-width: 320px;
    }
    .flatpickr-day {
        height: 36px;
        line-height: 36px;
    }
    .flatpickr-months .flatpickr-prev-month,
    .flatpickr-months .flatpickr-next-month {
        width: 30px;
        height: 30px;
    }
    .flatpickr-current-month .flatpickr-monthDropdown-months {
        font-size: 14px;
        padding: 0 22px 0 8px;
    }
    .fp-year-num {
        font-size: 14px;
        min-width: 36px;
    }
}
/* ──────────────────────────────────────────────────────────── */

/* ─── Import Modal ─────────────────────────────────────────── */
.im-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 24, 40, 0.32);
    padding: 16px;
}

.im-modal {
    width: min(760px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: 0 24px 60px rgba(16, 24, 40, 0.22);
    overflow: hidden;
}

.im-step {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

.im-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.im-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
}

.im-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}

.im-close:hover {
    background: var(--bg);
    color: var(--ink);
}

.im-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px;
    padding: 36px 24px;
    color: var(--muted);
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    cursor: default;
}

.im-dropzone-active,
.im-dropzone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.im-dropzone-text {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.5;
}

.im-dropzone-hint {
    color: var(--muted);
    font-size: 13px;
}

.im-file-btn {
    cursor: pointer;
}

.im-error {
    margin: 0 20px 12px;
    padding: 10px 14px;
    color: var(--danger);
    background: #fff0ed;
    border: 1px solid #ffc9c0;
    border-radius: var(--radius-btn);
    font-size: 14px;
}

.im-warning {
    margin: 12px 20px 0;
    padding: 10px 14px;
    color: #7a4f00;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--radius-btn);
    font-size: 14px;
}

.im-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    color: var(--muted);
    font-size: 14px;
}

.im-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: im-spin 0.7s linear infinite;
}

@keyframes im-spin {
    to { transform: rotate(360deg); }
}

.im-mapping-wrap {
    overflow-x: auto;
    padding: 14px 20px 0;
    flex: 0 0 auto;
}

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

.im-mapping-table th {
    padding: 6px 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

.im-mapping-table td {
    padding: 6px 10px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
}

.im-col-name {
    font-weight: 600;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.im-select {
    width: auto;
    min-width: 180px;
    min-height: 34px;
    padding: 5px 32px 5px 10px;
    font-size: 14px;
    color: var(--ink);
    background: #ffffff;
    border: 1px solid #cfd8d4;
    border-radius: var(--radius-btn);
    font: inherit;
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2366706c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

.im-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.im-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.im-badge-ok {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.im-badge-no {
    color: #7a4f00;
    background: #fff8e1;
}

.im-preview-label {
    padding: 12px 20px 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: 0 0 auto;
}

.im-preview-wrap {
    overflow: auto;
    padding: 0 20px 4px;
    flex: 1 1 auto;
    min-height: 80px;
}

.im-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.im-preview-table th {
    padding: 6px 10px;
    text-align: left;
    background: var(--accent-soft);
    border: 1px solid #dae0ff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.im-preview-table td {
    padding: 5px 10px;
    border: 1px solid var(--line);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.im-col-skip {
    color: var(--muted);
    opacity: 0.5;
}

.im-preview-table small.im-col-orig {
    display: block;
    font-weight: 400;
    color: var(--muted);
    opacity: 0.8;
}

.im-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    flex: 0 0 auto;
}

.im-footer-center {
    justify-content: center;
}

.im-result {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 36px 24px;
}

.im-result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--color-success-bg);
    border-radius: 50%;
    color: var(--color-success);
    font-size: 28px;
    font-weight: 800;
}

.im-result-stats {
    margin: 0;
    display: grid;
    gap: 8px;
}

.im-result-stats > div {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.im-result-stats dt {
    color: var(--muted);
    font-size: 14px;
}

.im-result-stats dd {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--ink);
}

/* ─── Dashboard Hero ─────────────────────────────────────────── */
.db-hero {
    text-align: center;
    padding: 6px 0 28px;
}


.db-hero-title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ink);
}

.db-hero-sub {
    margin: 0 0 28px;
    font-size: 14px;
    color: #888;
}

/* Hero actions — two buttons in a row */
.db-actions {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

/* Blue split button */
.db-split-wrap {
    position: relative;
    display: inline-flex;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(67, 71, 181, 0.18);
    overflow: visible;
}

/* ─── Easter egg: рука-привіт за кнопкою ─── */
.wave-hand {
    position: absolute;
    left: 0;
    top: 50%;
    font-size: 44px;
    line-height: 1;
    z-index: 0;
    transform: translate(50%, -50%) rotate(0deg);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    user-select: none;
}
.db-split-wrap .db-split-main,
.db-split-wrap .db-split-arrow {
    position: relative;
    z-index: 1;
}
@keyframes handAppear {
    0%   { transform: translate(50%, -50%) rotate(0deg);    opacity: 0; }  /* за кнопкою */
    14%  { transform: translate(-72%, -50%) rotate(8deg);   opacity: 1; }  /* виповзла зліва */
    28%  { transform: translate(-72%, -50%) rotate(-22deg); opacity: 1; }  /* мах */
    44%  { transform: translate(-72%, -50%) rotate(14deg);  opacity: 1; }
    60%  { transform: translate(-72%, -50%) rotate(-14deg); opacity: 1; }
    76%  { transform: translate(-72%, -50%) rotate(8deg);   opacity: 1; }
    88%  { transform: translate(-72%, -50%) rotate(0deg);   opacity: 1; }
    100% { transform: translate(50%, -50%) rotate(0deg);    opacity: 0; }  /* сховалась назад */
}
@keyframes buttonVibrate {
    0%,100% { transform: translateX(0); }
    15%  { transform: translateX(-3px); }
    30%  { transform: translateX(3px); }
    45%  { transform: translateX(-2px); }
    60%  { transform: translateX(2px); }
    75%  { transform: translateX(-1px); }
}
.wave-hand.animating {
    animation: handAppear 1.6s ease-in-out forwards;
}
.db-split-main.vibrating {
    animation: buttonVibrate 0.4s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
    .wave-hand.animating,
    .db-split-main.vibrating {
        animation: none;
    }
}

.db-split-main {
    display: inline-flex;
    align-items: center;
    padding: 14px 22px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px 0 0 12px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition-fast);
}

.db-split-main:hover {
    background: var(--accent-dark);
    color: #fff;
    text-decoration: none;
}

.db-split-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.db-split-arrow:hover {
    background: var(--accent-dark);
}

.db-split-arrow svg {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.db-split-arrow.open svg {
    transform: rotate(180deg);
}

/* White dual button */
.btn-dual {
    position: relative;
    display: inline-flex;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.btn-dual-main {
    display: inline-flex;
    align-items: center;
    padding: 14px 22px;
    background: #fff;
    color: var(--accent);
    font-size: 15px;
    font-weight: 700;
    border: 1.5px solid #d0d2f5;
    border-right: 1px solid #d0d2f5;
    border-radius: 12px 0 0 12px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition-fast);
}

.btn-dual-main:hover {
    background: #f3f3ff;
    color: var(--accent-dark);
    text-decoration: none;
}

.btn-dual-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    background: #fff;
    color: var(--accent);
    border: 1.5px solid #d0d2f5;
    border-left: none;
    border-radius: 0 12px 12px 0;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-dual-arrow:hover {
    background: #f3f3ff;
}

.btn-dual-arrow svg {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-dual-arrow.open svg {
    transform: rotate(180deg);
}

/* Shared dropdown */
.db-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 290px;
    background: #fff;
    border: 0.5px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    z-index: 200;
}

.db-dropdown.visible {
    display: block;
}

.header-actions .doc-create-split .db-dropdown {
    left: auto;
    right: 0;
    transform: none;
}

.header-actions .doc-create-split .db-split-main {
    min-height: 38px;
    padding: 8px 13px;
    font-size: inherit;
    font-weight: 750;
    border-radius: var(--radius-btn) 0 0 var(--radius-btn);
}

.header-actions .doc-create-split .db-split-arrow {
    min-height: 38px;
    width: 38px;
    border-radius: 0 var(--radius-btn) var(--radius-btn) 0;
}

/* Shared dropdown items */
.drop-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--ink);
    text-decoration: none;
    text-align: left;
    border-bottom: 0.5px solid #f3f3f3;
    transition: background var(--transition-fast);
}

.drop-item:first-child { border-radius: 12px 12px 0 0; }
.drop-item:last-child  { border-bottom: none; border-radius: 0 0 12px 12px; }

.drop-item:hover {
    background: #f7f7ff;
    color: var(--accent);
    text-decoration: none;
}

.drop-icon {
    font-size: 20px;
    width: 28px;
    flex-shrink: 0;
    text-align: center;
}

.drop-label {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
}

.drop-sub {
    font-size: 12px;
    color: #aaa;
    margin-top: 1px;
    white-space: nowrap;
}

/* ─── Dashboard stat + action cards ─────────────────────────── */
.stat-action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    border: 0.5px solid #e8e8e8;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 110px;
}

.stat-top {
    margin-bottom: 16px;
}

.stat-num {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1;
}

.stat-num--word {
    font-size: 22px;
    padding-top: 4px;
}

.stat-label {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}

.stat-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    color: #4347b5;
    background: #f3f3ff;
    border: 0.5px solid #d0d2f5;
    border-radius: 7px;
    padding: 6px 11px;
    white-space: nowrap;
    text-decoration: none;
    transition: background var(--transition-fast);
}

.stat-btn:hover {
    background: #ededff;
    text-decoration: none;
    color: #4347b5;
}

.stat-btn-secondary {
    color: #666;
    background: #f5f5f5;
    border-color: #e0e0e0;
}

.stat-btn-secondary:hover {
    background: #ebebeb;
    color: #666;
}

/* ─── Dashboard invoices table ───────────────────────────────── */
.db-invoices-panel {
    margin-bottom: 16px;
}

.db-table th {
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #fafafa;
}

.db-td-date {
    color: #aaa;
}

.db-td-total {
    font-weight: 600;
}

.db-load-more-wrap {
    padding: 16px 0 4px;
    text-align: center;
}

.db-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 22px;
    font-size: 13px;
    font-weight: 750;
    color: #ffffff;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.db-load-more-btn:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.db-load-more-btn:disabled {
    opacity: 0.65;
    cursor: default;
    box-shadow: none;
}

/* Convert dropdown in invoice table */
.db-td-actions {
    white-space: nowrap;
}

.db-td-actions-inner {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* ── Таблиця «Останні рахунки»: щільніша розкладка ── */
.db-table {
    min-width: 0;            /* прибираємо глобальний min-width: 720px */
}
.db-table th,
.db-table td {
    padding: 12px 12px;
}
/* Платник забирає вільний простір — інші колонки сидять компактно */
.db-table td:nth-child(3),
.db-table th:nth-child(3) {
    width: 100%;
}
.db-table td:nth-child(1),
.db-table td:nth-child(2),
.db-table td:nth-child(4),
.db-table td:nth-child(5),
.db-table th:nth-child(4) {
    white-space: nowrap;    /* статус та інші колонки не стискаються */
}
.db-table .db-td-actions {
    text-align: right;
}
.db-table .db-td-actions-inner {
    justify-content: flex-end;
}
.db-table .status-select {
    width: auto;
    min-width: 140px;       /* статус повністю видно (текст + емодзі + стрілка) */
}

.inv-convert-wrap {
    display: inline-block;
}

/* ── Мобільний/планшетний вигляд: картки замість таблиці (без скролу) ── */
@media (max-width: 720px) {
    .db-invoices-panel .table-wrap { overflow-x: visible; }
    .db-table thead { display: none; }
    .db-table,
    .db-table tbody,
    .db-table tr,
    .db-table td {
        display: block;
        width: 100%;
    }
    .db-table tr {
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 10px 14px;
        margin-bottom: 12px;
        transition: background 0.12s;
    }
    .db-table tr:last-child { margin-bottom: 0; }
    /* Підсвітка — на всю картку, а не на окремі комірки (інакше лишаються поля по контуру) */
    .db-table tbody tr:hover,
    .db-table tbody tr:active {
        background: #f6f8ff;
    }
    .db-table tbody tr:hover td {
        background: transparent;
    }
    .db-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        padding: 7px 0;
        border: none;
        border-bottom: 1px solid #f1f1f4;
        white-space: normal;
    }
    .db-table td:last-child { border-bottom: none; }
    .db-table td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 11px;
        font-weight: 700;
        color: #aaa;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    /* колонки на всю ширину */
    .db-table td:nth-child(3),
    .db-table td:nth-child(3) { width: 100%; }
    .db-table .status-form,
    .db-table .status-select { width: auto; min-width: 0; }
    .db-table .db-td-actions-inner {
        justify-content: flex-end;
        gap: 18px;
    }
}

/* Кнопка конвертації — стиль і hover-підказка 1 в 1 як іконка @ в меню */
.inv-convert-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f3f3ff;
    border: 1px solid #d0d2f5;
    border-radius: var(--radius-btn);
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.inv-convert-btn::after {
    content: "Конвертувати документ";
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    display: none;
    padding: 7px 10px;
    color: #ffffff;
    background: #1e1e2e;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    z-index: 300;
}
.inv-convert-btn:hover::after {
    display: block;
}

.inv-convert-btn:hover { background: #f0f0ff; }

.inv-convert-dropdown {
    display: none;
    position: fixed;
    min-width: 260px;
    background: #fff;
    border: 0.5px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 1000;
}

.inv-convert-dropdown.visible { display: block; }

.drop-form { margin: 0; }

.drop-item-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

/* ─── Dashboard mobile ───────────────────────────────────────── */
@media (max-width: 768px) {
    .db-hero {
        padding: 16px 0 24px;
    }

    .db-hero-title { font-size: 22px; }

    .db-actions { flex-direction: column; align-items: center; }

    .db-split-wrap,
    .btn-dual { flex-direction: row !important; }

    .stat-action-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .db-hero {
        padding: 12px 0 20px;
    }

    .db-hero-sub {
        margin-bottom: 22px;
    }

    .db-dropdown {
        left: 0;
        transform: none;
        right: 0;
        min-width: unset;
        width: calc(100vw - 40px);
        margin: 0 auto;
    }

    .stat-action-grid { grid-template-columns: 1fr; }
}

/* ─── Split button ───────────────────────────────────────────── */
.split-btn {
    position: relative;
    display: inline-flex;
}

.split-btn-main {
    border-radius: var(--radius-btn) 0 0 var(--radius-btn) !important;
}

.split-btn-toggle {
    border-radius: 0 var(--radius-btn) var(--radius-btn) 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.3) !important;
    padding: 0 10px;
    min-width: 36px;
    font-size: 12px;
}

.split-btn-menu {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    min-width: 220px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
}

.split-btn-menu a {
    display: block;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    transition: background var(--transition-fast);
}

.split-btn-menu a:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════
   Invoice Form Redesign — ifc-* components
   ═══════════════════════════════════════════════════════════════ */

/* ─── Card ─────────────────────────────────────────────────── */
.ifc-card {
    background: #ffffff;
    border-radius: 12px;
    border: 0.5px solid #e0e0e0;
    padding: 20px;
    margin-bottom: 12px;
}

/* ─── Section label ─────────────────────────────────────────── */
.ifc-label {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ─── Document details row (4 fields in one line) ───────────── */
.ifc-doc-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1.4fr;
    gap: 12px;
    align-items: start;
}

/* ─── Act/waybill specific card (number, date, doc notes) ───── */
.ifc-act-hint {
    margin: -4px 0 12px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.5;
}
.ifc-card:has(.ifc-act-hint) .ifc-doc-row {
    grid-template-columns: 1fr 1fr;
}
.ifc-act-notes {
    display: block;
    margin-top: 12px;
}
.ifc-act-notes > span {
    display: block;
    margin-bottom: 4px;
}

/* ─── Parties (my company + counterparty) ───────────────────── */
.parties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

.party-label {
    font-size: 11px;
    font-weight: 600;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.party-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.party-add-thin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 3px 9px;
    color: var(--accent);
    background: transparent;
    border: 1px solid #d0d2f5;
    border-radius: 999px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.party-add-thin-btn:hover {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

.party-field {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

/* Company select */
.party-select {
    flex: 1;
    height: 40px;
    padding: 0 32px 0 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 7L11 1' stroke='%23aaa' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    min-width: 0;
}
.party-select:focus { outline: none; border-color: var(--accent); }

/* Counterparty field wrap */
.party-select-wrap {
    flex: 1;
    height: 40px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 12px;
    overflow: visible;
    position: relative;
    min-width: 0;
}
.party-select-wrap:focus-within { border-color: var(--accent); }

/* Badge shown when counterparty is selected (JS toggles display: flex / none) */
.party-selected-badge {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 6px;
    overflow: hidden;
}

.party-on-payer-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.payer-clear {
    background: none;
    border: none;
    color: #bbb;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.payer-clear:hover { color: #666; }

/* Search input inside wrap */
.party-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 14px;
    color: var(--text);
    background: transparent;
}

.party-placeholder {
    font-size: 14px;
    color: #bbb;
    cursor: pointer;
    user-select: none;
}

/* Action icon button */
.party-action-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    text-decoration: none;
}
.party-action-btn:hover { background: var(--accent-dark); }
.party-action-btn.is-disabled { background: #c5c7e8; pointer-events: none; }

.quick-counterparty-dialog {
    width: min(620px, calc(100% - 28px));
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.quick-counterparty-dialog::backdrop {
    background: rgba(20, 30, 90, 0.30);
}

.quick-counterparty-form {
    display: grid;
    gap: 12px;
}

.quick-counterparty-form .panel-title {
    margin-bottom: 0;
}

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

.quick-counterparty-wide {
    grid-column: 1 / -1;
}

/* Hint under counterparty */
.party-hint {
    font-size: 12px;
    color: #aaa;
    margin-top: -2px;
}

/* ─── Note row ──────────────────────────────────────────────── */
/* ─── Note card ──────────────────────────────────────────────── */
.ifc-note-card { display: flex; flex-direction: column; gap: 12px; }

.ifc-note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

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

.ifc-note-tpl-pick-btn {
    font-size: 12px;
    padding: 4px 10px;
}

.ifc-note-body textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
}

/* Toggle switch for "Вивести примітку в рахунок" */
.ifc-note-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    align-self: flex-start;
}

.ifc-note-toggle-track {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex: 0 0 auto;
}

.ifc-note-toggle-track input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.ifc-note-toggle-slider {
    position: absolute;
    inset: 0;
    background: #d0d0d8;
    border-radius: 20px;
    transition: background 0.2s;
}

.ifc-note-toggle-slider::before {
    content: "";
    position: absolute;
    left: 3px;
    top: 3px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.ifc-note-toggle-track input:checked ~ .ifc-note-toggle-slider { background: var(--accent); }
.ifc-note-toggle-track input:checked ~ .ifc-note-toggle-slider::before { transform: translateX(16px); }

.ifc-note-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

/* Template picker dropdown */
.note-tpl-pick-wrap { position: relative; display: inline-block; }

.note-tpl-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: #fff;
    border: 0.5px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.10);
    z-index: 200;
    padding: 4px 0;
}

.note-tpl-dropdown.visible { display: block; }

.note-tpl-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text);
    transition: background 0.12s;
}
.note-tpl-item:hover { background: var(--accent-soft); color: var(--accent-dark); }

/* Template dialog list */
.note-tpl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 0.5px solid var(--line);
}
.note-tpl-row:last-child { border-bottom: none; }

.note-tpl-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.note-tpl-row-info strong { font-size: 13px; }
.note-tpl-row-info span { font-size: 12px; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.note-tpl-dialog { min-width: 420px; max-width: 560px; }
.note-tpl-add-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: #555; }

/* ─── Products card (catalog + invoice lines) ───────────────── */
.ifc-products-card {
    padding: 0;
    overflow: hidden;
}

.ifc-products-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.ifc-products-left {
    padding: 20px;
    border-right: 0.5px solid #ebebeb;
    overflow: hidden;
}

.ifc-products-right {
    padding: 20px;
    overflow: hidden;
}

.ifc-products-hint {
    margin: -4px 0 12px;
    font-size: 12px;
    color: #aaa;
    font-weight: 400;
}

/* ─── Catalog search ────────────────────────────────────────── */
.ifc-catalog-search-wrap {
    margin-bottom: 8px;
}

.ifc-catalog-search-input {
    width: 100%;
}

.ifc-catalog-meta {
    margin-bottom: 8px;
    font-size: 11px;
    color: #bbb;
}

/* ─── Catalog items (compact cards) ────────────────────────── */
.ifc-catalog-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: #fafafa;
    border: 0.5px solid #ebebeb;
    border-radius: 8px;
}

.ifc-catalog-item-text {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.ifc-catalog-item-text strong {
    font-size: 13px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.ifc-catalog-item-text span {
    font-size: 11px;
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ifc-catalog-add-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 36px;
    padding: 8px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 5px rgba(67, 71, 181, 0.28);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.ifc-catalog-add-btn:hover {
    background: var(--accent-dark);
    box-shadow: 0 2px 8px rgba(67, 71, 181, 0.35);
}

.ifc-catalog-add-btn:hover {
    background: var(--accent-dark);
}

/* ─── Items head (section label + add button) ───────────────── */
.ifc-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.ifc-add-row-btn {
    flex: 0 0 auto;
    padding: 5px 12px;
    font-size: 12px;
    min-height: 28px;
}

/* ─── Total row ──────────────────────────────────────────────── */
.ifc-total-row {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 0.5px solid #ebebeb;
}

.ifc-total-label {
    font-size: 13px;
    color: #888;
}

.ifc-total-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
}

/* ─── Override row grid for ifc layout ──────────────────────── */
.ifc-products-right .invoice-items-header,
.ifc-products-right .invoice-item-row {
    grid-template-columns: 1fr 54px 52px 110px 36px;
}

.ifc-products-right .invoice-items-header {
    font-size: 11px;
    color: #aaa;
    letter-spacing: 0.04em;
}

.ifc-products-right .invoice-item-row {
    padding: 8px 6px;
    background: #fafafa;
}

.ifc-products-right .row-icon-button {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-color: #f0c0c0;
}

/* ─── Responsive: < 768px ────────────────────────────────────── */
@media (max-width: 768px) {
    .ifc-doc-row {
        grid-template-columns: 1fr 1fr;
    }

    .ifc-doc-row label:last-child {
        grid-column: 1 / -1;
    }

    .parties-grid {
        grid-template-columns: 1fr;
    }

    .ifc-products-grid {
        grid-template-columns: 1fr;
    }

    .ifc-products-left {
        border-right: none;
        border-bottom: 0.5px solid #ebebeb;
        padding-bottom: 16px;
    }

    /* ifc-products-right: 4-колонка (Назва на рядку 1, решта + × на рядку 2) */
    .ifc-products-right .invoice-items-header {
        display: none;
    }
    .ifc-products-right .invoice-item-row {
        grid-template-columns: 68px 52px 1fr 36px;
    }
    .ifc-products-right .item-name-field {
        grid-column: 1 / -1;
        grid-row: 1;
    }
    .ifc-products-right .invoice-item-row label:not(.item-name-field) span {
        display: none;
    }
    .ifc-products-right .row-remove-button {
        grid-column: 4;
        grid-row: 2;
        align-self: end;
    }
}

@media (max-width: 520px) {
    .ifc-doc-row {
        grid-template-columns: 1fr;
    }

    /* Нейтралізуємо глобальне стекування для ifc-products-right */
    .ifc-products-right .invoice-item-row label:not(.item-name-field) {
        grid-column: auto;
        grid-row: 2;
    }
    .ifc-products-right .row-remove-button {
        grid-column: 4;
        grid-row: 2;
        align-self: end;
    }
}
/* ──────────────────────────────────────────────────────────── */

/* ─── Auth pages ─────────────────────────────────────────────── */
.auth-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
}

.auth-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px 60px;
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-bottom: 28px;
}

.auth-logo:hover { text-decoration: none; }

.auth-logo-img {
    height: 59px;
    width: auto;
    display: block;
}

.auth-card {
    width: 100%;
    max-width: 580px;
    background: #fff;
    border: 0.5px solid #e8e8e8;
    border-radius: 18px;
    padding: 52px 48px;
    box-shadow: 0 4px 28px rgba(0,0,0,0.08);
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px;
    text-align: center;
    color: #1a1a1a;
}

.auth-hint {
    font-size: 16px;
    color: #aaa;
    text-align: center;
    margin: 0 0 30px;
}

.auth-field {
    margin-bottom: 20px;
}

.auth-field label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #555;
    margin-bottom: 7px;
}

.auth-field .input {
    width: 100%;
    font-size: 16px;
    padding: 11px 15px;
}

.auth-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
}

.auth-field-row label {
    margin-bottom: 0;
}

.auth-forgot {
    font-size: 15px;
    color: var(--accent);
    text-decoration: none;
}

.auth-forgot:hover {
    text-decoration: underline;
}

.auth-field-error {
    margin-top: 6px;
    font-size: 15px;
    color: var(--danger);
}

.auth-errors {
    background: #fff3f3;
    border: 0.5px solid #f5c6cb;
    color: var(--danger);
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 16px;
    margin-bottom: 22px;
}

.auth-errors ul {
    margin: 0;
    padding: 0 0 0 16px;
}

.auth-errors li {
    margin: 2px 0;
}

.auth-submit {
    width: 100%;
    margin-top: 12px;
    font-size: 16px;
    padding: 13px 16px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 26px 0;
    color: #aaa;
    font-size: 15px;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e8e8e8;
}

.auth-google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 16px;
    border: 0.5px solid #e8e8e8;
    border-radius: 10px;
    background: #fff;
    color: #aaa;
    font-size: 16px;
    font-weight: 500;
    cursor: not-allowed;
    opacity: 0.6;
}

.auth-footer-links {
    margin-top: 28px;
    text-align: center;
    font-size: 16px;
    color: #aaa;
}

.auth-footer-links a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer-links a:hover {
    text-decoration: underline;
}

.otp-input {
    font-size: 28px;
    letter-spacing: 8px;
    text-align: center;
    font-weight: 700;
}

/* ─── Auth Split Layout (login page) ─────────────────────────── */

.auth-split-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: #fff;
    overflow: hidden;
}

.auth-split-layout {
    display: grid;
    grid-template-columns: 5fr 6fr;
    min-height: 100vh;
}

/* ── Left panel ── */
.auth-split-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: #fff;
    z-index: 1;
}

.auth-split-logo { margin-bottom: 32px; }

/* ── Right panel ── */
.auth-split-right {
    position: relative;
    background: linear-gradient(150deg, #252260 0%, #3e3ba8 55%, #5e58cc 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 40px;
    overflow: hidden;
}

.asr-circle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    background: rgba(255,255,255,0.08);
}
.asr-circle-1 { width: 520px; height: 520px; top: -200px; right: -140px; }
.asr-circle-2 { width: 320px; height: 320px; bottom: -130px; left: -90px; }
.asr-circle-3 { width: 140px; height: 140px; top: 42%; left: 18%; background: rgba(255,255,255,0.04); }

/* ── Demo content ── */
.auth-demo {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 460px;
}

.auth-demo-headline {
    color: rgba(255,255,255,0.96);
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    line-height: 1.4;
    margin: 0;
    letter-spacing: -0.2px;
}

.demo-scene { width: 100%; }

/* Float wrapper — bobs after card is fully built */
@keyframes demo-float {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-9px); }
}
.demo-scene-inner {
    animation: demo-float 4s ease-in-out 0s infinite;
}

/* ── Invoice card ── */
.demo-inv {
    background: #fff;
    border-radius: 18px;
    padding: 18px 18px 16px;
    box-shadow: 0 28px 72px rgba(0,0,0,0.42), 0 4px 16px rgba(0,0,0,0.18);
    position: relative;
    opacity: 0;
    animation: demo-enter 0.85s cubic-bezier(0.2,0,0,1) 0.1s both;
}
@keyframes demo-enter {
    from { opacity: 0; transform: translateY(22px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── One-shot element animations ── */

/* Topbar: delay 0.7s */
.demo-inv-topbar {
    opacity: 0;
    animation: demo-fadein-down 0.45s ease 0.7s both;
}

/* Parties: delay 1.25s */
.demo-inv-parties {
    opacity: 0;
    animation: demo-fadein-down 0.45s ease 1.25s both;
}

/* Section label: delay 1.9s */
.demo-inv-sec-lbl {
    opacity: 0;
    animation: demo-fadein-down 0.35s ease 1.9s both;
}

/* Table header: delay 2.2s */
.demo-inv-thead {
    opacity: 0;
    animation: demo-fadein-slide 0.35s ease 2.2s both;
}

/* Items — slide in one by one */
.demo-inv-row-1 {
    opacity: 0;
    animation: demo-fadein-slide 0.4s ease 2.6s both;
}
.demo-inv-row-2 {
    opacity: 0;
    animation: demo-fadein-slide 0.4s ease 3.3s both;
}
.demo-inv-row-3 {
    opacity: 0;
    animation: demo-fadein-slide 0.4s ease 4.0s both;
}

/* Total: delay 4.9s, scale effect */
.demo-inv-total {
    opacity: 0;
    animation: demo-total-pop 0.5s cubic-bezier(0.2,0,0,1.4) 4.9s both;
}

/* Actions: delay 5.8s */
.demo-inv-actions {
    opacity: 0;
    animation: demo-fadein-down 0.4s ease 5.8s both;
}

/* Badge: delay 6.8s, bounce */
.demo-inv-badge {
    opacity: 0;
    animation: demo-badge-pop 0.55s cubic-bezier(0.2,0,0,1.5) 6.8s both;
}

/* ── Keyframe definitions ── */
@keyframes demo-fadein-down {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes demo-fadein-slide {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes demo-total-pop {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes demo-badge-pop {
    from { opacity: 0; transform: scale(0.4) translateY(-6px); }
    80%  { transform: scale(1.1) translateY(0); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Invoice card inner styles ── */

/* Top bar — тип документа + номер + дата */
.demo-inv-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 11px;
    border-bottom: 1.5px solid #f0f0f0;
    margin-bottom: 11px;
}
.demo-inv-topbar-left {
    display: flex;
    align-items: center;
    gap: 7px;
}
.demo-inv-type {
    font-size: 12.5px;
    font-weight: 600;
    color: #888;
}
.demo-inv-num-badge {
    font-size: 12.5px;
    font-weight: 700;
    color: #4f39f6;
    background: #eeeeff;
    padding: 2px 8px;
    border-radius: 999px;
}
.demo-inv-topbar-date {
    font-size: 11.5px;
    color: #bbb;
}

/* Parties — two columns like parties-grid */
.demo-inv-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.demo-inv-party {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 7px 9px;
}
.demo-inv-party-lbl {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #bbb;
    margin-bottom: 4px;
}
.demo-inv-party-name {
    font-size: 12.5px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.3;
}
.demo-inv-party-sub {
    font-size: 10.5px;
    color: #bbb;
    margin-top: 2px;
}

/* Section label */
.demo-inv-sec-lbl {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #bbb;
    margin-bottom: 7px;
}

/* Items table — 4 cols like the actual app */
.demo-inv-thead {
    display: grid;
    grid-template-columns: 1fr 32px 32px 68px;
    gap: 5px;
    padding: 0 0 6px;
    font-size: 9px;
    font-weight: 700;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 3px;
}
.demo-inv-row {
    display: grid;
    grid-template-columns: 1fr 32px 32px 68px;
    gap: 5px;
    padding: 6px 0;
    font-size: 12px;
    color: #444;
    border-bottom: 1px solid #f5f5f5;
}
.demo-inv-row span:nth-child(2),
.demo-inv-row span:nth-child(3) { text-align: center; color: #999; font-size: 11.5px; }
.demo-inv-row span:last-child    { text-align: right; font-weight: 600; color: #1a1a1a; }

/* Total row — right-aligned like the real app */
.demo-inv-total {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 9px 0 11px;
    border-top: 1.5px solid #f0f0f0;
    margin-top: 2px;
    font-size: 12.5px;
    font-weight: 600;
    color: #888;
}
.demo-inv-total-amt {
    font-size: 16px;
    font-weight: 800;
    color: #4f39f6;
}

/* Action buttons */
.demo-inv-actions {
    display: flex;
    gap: 6px;
    border-top: 1.5px solid #f0f0f0;
    padding-top: 11px;
}
.demo-inv-btn-pdf,
.demo-inv-btn-docx,
.demo-inv-btn-act {
    flex: 1;
    text-align: center;
    padding: 7px 4px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
}
.demo-inv-btn-pdf  { background: #4f39f6; color: #fff; }
.demo-inv-btn-docx { background: #f0f0f0; color: #555; }
.demo-inv-btn-act  { background: #f0f0f0; color: #555; }

/* Success badge */
.demo-inv-badge {
    position: absolute;
    top: -12px;
    right: 18px;
    background: #22c55e;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    padding: 5px 15px;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(34,197,94,0.5);
    white-space: nowrap;
}

/* ── Card nudge (click on demo → shake + red border) ── */
@keyframes card-shake {
    0%, 100% { transform: translateX(0); }
    15%       { transform: translateX(-7px) rotate(-0.4deg); }
    30%       { transform: translateX(7px)  rotate(0.4deg); }
    45%       { transform: translateX(-5px); }
    60%       { transform: translateX(5px); }
    75%       { transform: translateX(-3px); }
    88%       { transform: translateX(2px); }
}
@keyframes card-flash-border {
    0%   { box-shadow: 0 4px 28px rgba(0,0,0,0.08); border-color: #e8e8e8; }
    18%  { box-shadow: 0 0 0 3px rgba(239,68,68,0.28), 0 4px 28px rgba(0,0,0,0.08); border-color: #f87171; }
    55%  { box-shadow: 0 0 0 2px rgba(239,68,68,0.12), 0 4px 28px rgba(0,0,0,0.08); border-color: rgba(239,68,68,0.35); }
    100% { box-shadow: 0 4px 28px rgba(0,0,0,0.08); border-color: #e8e8e8; }
}
.auth-card.is-nudged {
    animation: card-shake 0.52s ease-out, card-flash-border 0.9s ease-out;
}

/* ── Features strip ── */
.auth-demo-features {
    display: flex;
    gap: 14px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    margin: 0;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Mobile preview block (hidden on desktop) ── */
.mobile-preview { display: none; }

/* ── Responsive ── */
@media (max-width: 1060px) {
    .auth-split-left { padding: 48px 36px; }
    .auth-demo-headline { font-size: 19px; }
}

@media (max-width: 820px) {
    .auth-split-layout { grid-template-columns: 1fr; }
    .auth-split-right  { display: none; }
    .auth-split-left   {
        min-height: 100vh;
        padding: 40px 20px 0;
        justify-content: flex-start;
    }

    /* ── Mobile preview ── */
    .mobile-preview {
        display: block;
        background: linear-gradient(160deg, #252260 0%, #4845b8 55%, #5e58cc 100%);
        padding: 24px 20px 32px;
        position: relative;
        overflow: hidden;
        align-self: stretch;
        border-radius: 28px;
        margin: 20px -4px 32px;
        box-shadow:
            0 -6px 20px rgba(37, 34, 96, 0.12),
            0 16px 48px rgba(37, 34, 96, 0.38);
    }
    .mobile-preview::before {
        content: '';
        position: absolute;
        width: 200px; height: 200px;
        border-radius: 50%;
        background: rgba(255,255,255,0.07);
        top: -70px; right: -60px;
    }
    .mobile-preview::after {
        content: '';
        position: absolute;
        width: 120px; height: 120px;
        border-radius: 50%;
        background: rgba(255,255,255,0.04);
        bottom: -40px; left: -30px;
    }

    .mp-tagline {
        font-size: 13px;
        font-weight: 600;
        color: rgba(255,255,255,0.88);
        text-align: center;
        margin-bottom: 16px;
        position: relative;
        z-index: 1;
    }

    .mp-invoice {
        background: #fff;
        border-radius: 12px;
        padding: 14px 16px;
        box-shadow: 0 6px 24px rgba(0,0,0,0.2);
        position: relative;
        z-index: 1;
    }

    .mp-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding-bottom: 10px;
        border-bottom: 1px solid #f0f0f0;
        margin-bottom: 10px;
    }
    .mp-type {
        font-size: 9.5px;
        color: #aaa;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 600;
    }
    .mp-num  { font-size: 11.5px; font-weight: 700; color: #4f39f6; }
    .mp-date { font-size: 9px; color: #bbb; margin-top: 2px; }

    .mp-parties {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #f0f0f0;
    }
    .mp-party-label {
        font-size: 8px;
        color: #bbb;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 700;
        margin-bottom: 3px;
    }
    .mp-party-name { font-size: 10.5px; font-weight: 700; color: #1a1a1a; }

    .mp-items { margin-bottom: 8px; }
    .mp-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border-bottom: 1px solid #f8f8f8;
    }
    .mp-item:last-child { border: none; }
    .mp-item-name  { font-size: 10.5px; color: #444; }
    .mp-item-price { font-size: 10.5px; font-weight: 600; color: #1a1a1a; }

    .mp-total {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
        padding-top: 8px;
        border-top: 1px solid #e8e8e8;
    }
    .mp-total-label { font-size: 10.5px; color: #888; font-weight: 600; }
    .mp-total-sum   { font-size: 14px; font-weight: 800; color: #4f39f6; }

    .mp-actions {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 5px;
        margin-top: 11px;
    }
    .mp-btn {
        font-size: 10px;
        font-weight: 600;
        padding: 7px 0;
        border-radius: 7px;
        text-align: center;
    }
    .mp-btn-primary   { background: #4f39f6; color: #fff; }
    .mp-btn-secondary { background: #f4f4f4; color: #555; }

    .mp-features {
        display: flex;
        justify-content: space-around;
        margin-top: 16px;
        position: relative;
        z-index: 1;
    }
    .mp-feature {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
    }
    .mp-feature-icon  { font-size: 16px; }
    .mp-feature-label { font-size: 9.5px; color: rgba(255,255,255,0.65); }
}

@media (min-width: 821px) and (max-width: 1060px) {
    .auth-demo-features { font-size: 11px; gap: 10px; }
    .demo-inv-total-amt { font-size: 15px; }
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 0 8px;
}
.pagination-btn {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 16px;
    border-radius: var(--radius-btn);
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s;
}
.pagination-btn:hover { background: var(--accent-soft); text-decoration: none; }
.pagination-btn.disabled { color: var(--muted); pointer-events: none; }
.pagination-info { font-size: 13px; color: var(--muted); }

/* ── Onboarding banner ─────────────────────────────────────── */
.ob-banner {
    width: 100%;
    background: #3B40C4;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 48px;
    position: relative;
}
.ob-banner-cta {
    background: rgba(255,255,255,0.14);
    border: 1.5px solid rgba(255,255,255,0.45);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 22px;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 0.01em;
    transition: background 0.15s;
    animation: obBannerGlow 2.4s ease-in-out infinite;
}
.ob-banner-cta:hover {
    background: rgba(255,255,255,0.24);
    animation: none;
}
@keyframes obBannerGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
    50%       { box-shadow: 0 0 0 9px rgba(255,255,255,0); }
}
.ob-banner-close {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: color 0.12s;
}
.ob-banner-close:hover { color: #fff; }

/* ── Share link block ───────────────────────────────────────── */
@media (max-width: 767px) {
    .detail-grid { grid-template-columns: 1fr; }
}

/* ── Send-to-client row ── */
.detail-note {
    font-size: 13px;
    color: var(--muted);
    margin: 4px 0 8px;
    line-height: 1.5;
}

/* Легкий розділювач у блоці деталей */
.detail-divider {
    height: 0;
    border: 0;
    border-top: 1px solid var(--line);
    margin: 14px 0;
}

/* Таблиця позицій: ПК/планшет — звичайна, смартфон — картки */
@media (max-width: 640px) {
    .items-table thead {
        display: none;
    }
    .items-table,
    .items-table tbody,
    .items-table tr,
    .items-table td {
        display: block;
        width: 100%;
        min-width: 0;          /* скидаємо базове table{min-width:720px} */
        white-space: normal;
    }
    .items-table tr {
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 6px 12px;
        margin-bottom: 10px;
    }
    .items-table td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 14px;
        padding: 5px 0;
        border: 0;
        text-align: right;
    }
    .items-table td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: 12px;
        font-weight: 600;
        color: var(--muted);
        text-align: left;
    }
    /* «Назва» — на всю ширину зверху картки, виділена */
    .items-table td[data-label="Назва"] {
        font-weight: 700;
        border-bottom: 1px solid var(--line);
        margin-bottom: 4px;
        padding-bottom: 7px;
        text-align: left;
    }
    .items-table td[data-label="Назва"]::before {
        display: none;
    }
    /* Порядковий номер у картці зайвий */
    .items-table td[data-label="#"] {
        display: none;
    }
}

/* ── Синхронізація (Вчасно) ── */
.sync-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
.sync-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.sync-logo { display: flex; align-items: center; gap: 12px; }
.sync-logo-badge {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-btn);
    background: #ffe14d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1a1a2e;
    font-size: 21px;
    font-weight: 800;
}
.sync-logo-badge--dubidoc { background: #8B3FAD; color: #fff; }

.eyebrow-link { color: inherit; text-decoration: none; }
.eyebrow-link:hover { color: var(--accent); text-decoration: underline; }

/* ── Хаб синхронізацій ── */
.sync-hub-intro {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 14px;
}
.sync-hub-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 720px;
}
.sync-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
a.sync-tile:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(45, 45, 142, 0.08);
    text-decoration: none;
    color: inherit;
}
.sync-tile--soon {
    opacity: 0.7;
    cursor: not-allowed;
    background: #fafafd;
}
.sync-tile-body { flex: 1; min-width: 0; }
.sync-tile-name { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.sync-tile-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* Плитка-побажання */
.sync-tile--suggest {
    align-items: flex-start;
    border-style: dashed;
}
.sync-logo-badge--suggest {
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 24px;
    font-weight: 800;
}
.suggest-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    max-width: 460px;
}
.suggest-form[hidden] { display: none; }
.suggest-input { flex: 1; min-width: 0; }
.suggest-btn { flex-shrink: 0; white-space: nowrap; }
.suggest-error {
    margin-top: 8px;
    font-size: 13px;
    color: var(--danger);
}
.suggest-error[hidden] { display: none; }
.suggest-done {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding: 12px 14px;
    background: #e9fbf1;
    border: 1px solid #b6efce;
    border-radius: 10px;
    font-size: 13.5px;
    color: #166534;
    line-height: 1.5;
    max-width: 540px;
}
.suggest-done[hidden] { display: none; }
.suggest-done-check { flex-shrink: 0; }
.sync-tile-arrow { flex-shrink: 0; color: #bbb; }
a.sync-tile:hover .sync-tile-arrow { color: var(--accent); }
.sync-logo h2 { margin: 0; }
.sync-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.sync-status {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 14px;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.sync-status--on { background: #e6faf0; color: #16a34a; }
.sync-status--off { background: #f1f1f5; color: #888; }
.sync-form { display: flex; flex-direction: column; gap: 14px; }
.sync-field { display: flex; flex-direction: column; gap: 6px; }
.sync-field > span { font-size: 13px; font-weight: 600; color: #333; }
.sync-field small { color: var(--muted); font-weight: 400; }
.sync-details { margin: 4px 0 18px; }
.sync-token-tail { font-weight: 700; color: var(--text); }
.sync-help h2 { margin: 0 0 16px; }
.sync-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.sync-steps li { display: flex; gap: 12px; align-items: flex-start; }
.sync-step-num {
    flex-shrink: 0;
    width: 26px; height: 26px;
    border-radius: var(--radius-btn);
    background: var(--accent, #2d2d8e);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sync-steps strong { display: block; font-size: 14px; margin-bottom: 2px; }
.sync-steps p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.sync-token-link { font-size: 12px; color: var(--muted); text-decoration: underline; }
.sync-token-link:hover { color: var(--accent, #2d2d8e); }
@media (max-width: 767px) {
    .sync-grid { grid-template-columns: 1fr; }
}

/* ── Історія змін ── */
.edit-history {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.edit-history .detail-section-label {
    margin-top: 0;
}
.edit-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.edit-history-list li {
    font-size: 12.5px;
    color: var(--muted);
    padding-left: 14px;
    position: relative;
}
.edit-history-list li::before {
    content: "•";
    position: absolute;
    left: 2px;
    color: var(--accent, #2d2d8e);
}

.send-client-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}
.btn-send-action {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 6px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    cursor: default;
    opacity: 0.75;
    text-align: center;
    line-height: 1.2;
}
.btn-send-action img {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: block;
}
.btn-send-action svg {
    width: 14px;
    height: 14px;
}
/* Кнопка «Надіслати у Янків.Док» (внутрішній обмін) */
.btn-send-yankiv {
    cursor: pointer;
    opacity: 1;
    color: var(--text);
}
.btn-send-yankiv:hover {
    background: var(--accent-soft);
    text-decoration: none;
    color: var(--text);
}
.btn-send-yankiv.is-sent {
    border-color: #22c55e;
    background: #e9fbf1;
    color: #16a34a;
    cursor: pointer;
}
.btn-send-yankiv.is-sent:hover { background: #d8f7e6; color: #16a34a; }
.yankiv-sent-check {
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    color: #16a34a;
}
.yankiv-send-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: #2d2d8e;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}
.yankiv-send-badge--lg {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 16px;
}
.btn-send-link {
    cursor: pointer;
    opacity: 1;
    color: var(--text);
}
.btn-send-link:hover {
    background: #f0f2ff;
}
/* ── Кнопка Вчасно (стани) ── */
.btn-send-vchasno {
    cursor: pointer;
    opacity: 1;
    color: var(--text);
    text-decoration: none;
}
.btn-send-vchasno:hover { background: #f0f2ff; text-decoration: none; color: var(--text); }
.btn-send-vchasno.is-disabled {
    cursor: default;
    opacity: 0.6;
}
.btn-send-vchasno.is-disabled:hover { background: var(--bg); }
.btn-send-vchasno.is-sent {
    border-color: #22c55e;
    background: #e9fbf1;
    color: #16a34a;
    cursor: pointer;
}
.btn-send-vchasno.is-sent:hover { background: #d8f7e6; color: #16a34a; }
.vchasno-sent-check {
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    color: #16a34a;
}

/* ── Кнопка Dubidoc (стани, дзеркало Вчасно) ── */
.btn-send-dubidoc {
    cursor: pointer;
    opacity: 1;
    color: var(--text);
    text-decoration: none;
}
.btn-send-dubidoc:hover { background: #f7f0fb; text-decoration: none; color: var(--text); }
.btn-send-dubidoc.is-disabled { cursor: default; opacity: 0.6; }
.btn-send-dubidoc.is-disabled:hover { background: var(--bg); }
.btn-send-dubidoc.is-sent {
    border-color: #22c55e;
    background: #e9fbf1;
    color: #16a34a;
    cursor: pointer;
}
.btn-send-dubidoc.is-sent:hover { background: #d8f7e6; color: #16a34a; }
.dubidoc-sent-check {
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    color: #16a34a;
}

/* Режим надсилання у модалці Dubidoc */
.dubidoc-mode-row { display: flex; gap: 8px; }
.dubidoc-mode {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 6px 10px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.dubidoc-mode input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dubidoc-mode:hover { border-color: #c7a8e0; }
.dubidoc-mode:has(input:checked) {
    border-color: #8B3FAD;
    background: #f5edfb;
    color: #6b2d8a;
}

/* ── Попап-довідка Dubidoc (де взяти ключ) ── */
.vchasno-modal.dubidoc-help-card {
    max-width: min(50vw, 860px);
    text-align: left;
}
@media (max-width: 900px) {
    .vchasno-modal.dubidoc-help-card {
        max-width: 94vw;
    }
}
.dubidoc-help-img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 4px 0 18px;
}
.dubidoc-help-cta {
    display: flex;
    width: fit-content;
    margin: 6px auto 0;
    justify-content: center;
    text-decoration: none;
}

/* ── Модалка Вчасно ── */
.vchasno-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 40, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    animation: vchasno-fade 0.15s ease;
}
.vchasno-modal-overlay[hidden] { display: none; }
@keyframes vchasno-fade { from { opacity: 0; } to { opacity: 1; } }
.vchasno-modal {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    padding: 26px 26px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: vchasno-pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes vchasno-pop {
    from { transform: scale(0.94) translateY(8px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}
.vchasno-modal-close {
    position: absolute;
    top: 12px; right: 14px;
    border: none; background: none;
    font-size: 26px; line-height: 1;
    color: #aaa; cursor: pointer;
    padding: 2px 6px;
}
.vchasno-modal-close:hover { color: #333; }
.vchasno-modal-head {
    display: flex; align-items: center; gap: 11px;
    margin-bottom: 12px;
}
.vchasno-modal-head h3 { margin: 0; font-size: 19px; }
.vchasno-modal-sub {
    margin: 0 0 18px;
    font-size: 13.5px;
    color: var(--muted);
    line-height: 1.55;
}
.vchasno-modal .sync-field { margin-bottom: 14px; }
.vchasno-modal-error {
    background: #fff0f0;
    border: 1px solid #f5c2c2;
    color: #c0392b;
    font-size: 13px;
    padding: 9px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.vchasno-modal-error[hidden] { display: none; }
.vchasno-send-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.vchasno-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: vchasno-spin 0.6s linear infinite;
}
@keyframes vchasno-spin { to { transform: rotate(360deg); } }

/* ── Успіх: анімований чекмарк ── */
#vchasno-success-state,
#dubidoc-success-state,
#yankiv-success-state { text-align: center; padding: 8px 0 4px; }
#vchasno-success-state[hidden],
#dubidoc-success-state[hidden],
#yankiv-success-state[hidden] { display: none; }
#vchasno-form-state[hidden],
#dubidoc-form-state[hidden] { display: none; }
.vchasno-anim { display: flex; justify-content: center; margin-bottom: 16px; }
.vchasno-anim-svg { width: 84px; height: 84px; }
.vchasno-anim-circle {
    stroke: #22c55e;
    stroke-width: 2.5;
    stroke-dasharray: 151;
    stroke-dashoffset: 151;
    animation: vchasno-circle 0.5s ease forwards;
}
.vchasno-anim-check {
    stroke: #22c55e;
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: vchasno-check 0.35s 0.45s ease forwards;
}
@keyframes vchasno-circle { to { stroke-dashoffset: 0; } }
@keyframes vchasno-check { to { stroke-dashoffset: 0; } }
.vchasno-success-title { margin: 4px 0 6px; font-size: 19px; color: #16a34a; }
.vchasno-success-sub { margin: 0 0 20px; font-size: 13.5px; color: var(--muted); line-height: 1.55; }

.detail-section-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
    margin-bottom: 8px;
    margin-top: 20px;
}
.share-link-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.share-link-input {
    flex: 1;
    font-size: 13px;
    color: var(--muted);
    background: var(--bg);
    cursor: text;
    min-width: 0;
}

/* ── Invoice Preview ────────────────────────────────────────── */
.inv-preview-panel { margin-top: 24px; }
.inv-preview-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.inv-preview-panel-title h2 { margin: 0; }

.inv-preview-wrap {
    background: #e8e8e8;
    border-radius: 6px;
    padding: 32px;
    overflow-x: auto;
}

.inv-preview {
    background: #fff;
    width: 100%;
    max-width: 794px;      /* A4 @ 96dpi на десктопі, гнучко на менших екранах */
    min-height: 600px;
    margin: 0 auto;
    padding: 40px 48px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    color: #111;
    box-shadow: 0 2px 16px rgba(0,0,0,0.13);
    border-radius: 2px;
}

/* Шапка */
.inv-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 24px;
}
.inv-preview-seller { flex: 1; }
.inv-preview-seller-name {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 3px;
}
.inv-preview-seller-sub {
    font-size: 11.5px;
    color: #555;
    line-height: 1.5;
}
.inv-preview-title-block {
    text-align: right;
    flex-shrink: 0;
}
.inv-preview-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #1a1a9e;
}
.inv-preview-number {
    font-size: 13px;
    color: #444;
    margin-top: 3px;
}
.inv-preview-due {
    font-size: 12px;
    color: #b54708;
    font-weight: 600;
    margin-top: 2px;
}

/* Постачальник / Покупець */
.inv-preview-parties {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border: 1px solid #c8c8c8;
}
.inv-preview-parties td {
    padding: 7px 10px;
    border: 1px solid #c8c8c8;
    font-size: 12.5px;
    vertical-align: top;
}
.inv-party-label {
    font-weight: 700;
    white-space: nowrap;
    width: 120px;
    background: #f5f5f5;
}
.inv-party-value { color: #222; }

/* Таблиця позицій */
.inv-preview-items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 12.5px;
}
.inv-preview-items th {
    background: #1a1a9e;
    color: #fff;
    padding: 7px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    border: 1px solid #1a1a9e;
}
.inv-preview-items td {
    padding: 6px 8px;
    border: 1px solid #d4d4d4;
    vertical-align: middle;
}
.inv-preview-items tbody tr:nth-child(even) td { background: #f8f8ff; }

/* Колонки */
.inv-col-num   { width: 36px;  text-align: center; }
.inv-col-name  { min-width: 200px; }
.inv-col-unit  { width: 56px;  text-align: center; }
.inv-col-qty   { width: 64px;  text-align: right; }
.inv-col-price { width: 90px;  text-align: right; }
.inv-col-sum   { width: 100px; text-align: right; font-weight: 600; }

/* Рядок "Разом" */
.inv-total-row td { border-top: 2px solid #1a1a9e; }
.inv-total-label {
    text-align: right;
    font-weight: 700;
    padding-right: 12px;
    font-size: 13px;
}
.inv-total-value {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a9e;
    text-align: right;
    white-space: nowrap;
}

/* Примітка */
.inv-preview-notes {
    font-size: 12px;
    color: #555;
    margin-bottom: 24px;
    padding: 8px 12px;
    background: #fffbe6;
    border-left: 3px solid #f0c040;
    border-radius: 2px;
}

/* Підписи */
.inv-preview-sign {
    display: flex;
    gap: 60px;
    margin-top: 36px;
    padding-top: 12px;
}
.inv-sign-block { flex: 1; }
.inv-sign-line {
    height: 1px;
    background: #bbb;
    margin-bottom: 6px;
}
.inv-sign-label {
    font-size: 11px;
    color: #888;
}

@media (max-width: 860px) {
    .inv-preview-wrap { padding: 12px; }
    .inv-preview { padding: 26px 22px; font-size: 12.5px; }
    .inv-preview-header { gap: 14px; }
}

@media (max-width: 520px) {
    .inv-preview-wrap { padding: 8px; border-radius: 8px; }
    .inv-preview { padding: 18px 14px; font-size: 11.5px; min-height: 0; }
    /* Шапка: постачальник і блок назви — у стовпчик */
    .inv-preview-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 14px;
    }
    .inv-preview-title-block { text-align: left; }
    .inv-preview-title { font-size: 16px; }
    /* Таблиця позицій у прев'ю: компактніше, назва переноситься */
    .inv-preview-items { font-size: 10.5px; }
    .inv-preview-items th,
    .inv-preview-items td { padding: 4px 4px; }
    .inv-preview-items .inv-col-name { word-break: break-word; }
    .inv-preview-parties { font-size: 11px; }
    /* Підписи — у стовпчик */
    .inv-preview-sign { flex-direction: column; gap: 18px; }
}
