:root {
    --bg: #F0F4F3;
    --card: #FFFFFF;
    --ink: #142A30;
    --mut: #6A7F84;
    --line: #E0E8E7;
    --pri: #1B6E8A;
    --pri-d: #13566C;
    --pri-l: #E2F0F5;
    --acc: #F2A93B;
    --ok: #2B9367;
    --ok-l: #DDF3E8;
    --warn: #A86A08;
    --warn-l: #FFF1D6;
    --bad: #CF4A32;
    --bad-l: #FCE4DE;
    --info: #1B6E8A;
    --info-l: #E2F0F5;
    --mute-l: #EBEFEF;
    --radius: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

.mt-10 {
    margin-top: 10px;
}

.mt-12 {
    margin-top: 12px;
}

small {
    display: block;
    color: var(--mut);
    font-size: 12.5px;
}

:focus-visible {
    outline: 3px solid rgba(27, 110, 138, 0.35);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

::-webkit-scrollbar-track:vertical {
    background: linear-gradient(90deg, transparent 7px, var(--line) 7px 9px, transparent 9px);
}

::-webkit-scrollbar-track:horizontal {
    background: linear-gradient(180deg, transparent 7px, var(--line) 7px 9px, transparent 9px);
}

::-webkit-scrollbar-thumb {
    border: 4px solid transparent;
    border-radius: 12px;
    background-color: var(--pri);
    background-clip: padding-box;
    background-position: center;
    background-repeat: no-repeat;
}

::-webkit-scrollbar-thumb:vertical {
    background-size: 8px 20px;
    background-image:
        radial-gradient(circle at 50% 4px, var(--acc) 1.6px, transparent 2.2px),
        radial-gradient(circle at 50% 10px, var(--acc) 1.6px, transparent 2.2px),
        radial-gradient(circle at 50% 16px, var(--acc) 1.6px, transparent 2.2px);
}

::-webkit-scrollbar-thumb:horizontal {
    background-size: 20px 8px;
    background-image:
        radial-gradient(circle at 4px 50%, var(--acc) 1.6px, transparent 2.2px),
        radial-gradient(circle at 10px 50%, var(--acc) 1.6px, transparent 2.2px),
        radial-gradient(circle at 16px 50%, var(--acc) 1.6px, transparent 2.2px);
}

::-webkit-scrollbar-thumb:hover {
    border-width: 3px;
    background-color: var(--pri-d);
}

@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--pri) var(--line);
    }
}

.ic {
    width: 20px;
    height: 20px;
    flex: none;
}

.app {
    display: grid;
    grid-template-columns: 252px 1fr;
    min-height: 100vh;
}

.side {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 24px 16px;
    background: var(--card);
    border-inline-end: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 28px;
}

.logo {
    width: 42px;
    height: 42px;
}

.brand b {
    display: block;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: 0.2px;
}

.nav {
    display: grid;
    gap: 4px;
}

.nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    color: var(--mut);
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.nav a:hover {
    background: var(--bg);
    color: var(--ink);
}

.nav a.on {
    background: var(--pri-l);
    color: var(--pri-d);
    font-weight: 600;
}

.nav a.on::after {
    content: '';
    position: absolute;
    inset-inline-end: -16px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 4px 0 0 4px;
    background: var(--acc);
}

.socials {
    display: flex;
    align-items: center;
    gap: 8px;
}

.socials-side {
    justify-content: center;
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.social {
    position: relative;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--mut);
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.social:hover {
    border-color: var(--pri);
    background: var(--pri-l);
    color: var(--pri);
    transform: translateY(-2px);
}

.tooltip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 90;
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-size: 12.5px;
    direction: ltr;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.tooltip.show {
    opacity: 1;
}

.main {
    min-width: 0;
    padding: 28px 36px 60px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.top h1 {
    font-size: 26px;
}

.tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--mut);
}

.search {
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search:focus-within {
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgba(27, 110, 138, 0.15);
}

.search input {
    min-width: 190px;
}

.search input,
.search input:focus {
    width: auto;
    padding: 10px 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    box-shadow: none;
    background: none;
    color: var(--ink);
    -webkit-appearance: none;
    appearance: none;
}

.search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.filter,
label select,
label input,
label textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter {
    width: auto;
}

label input:focus,
label select:focus,
label textarea:focus {
    outline: 0;
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgba(27, 110, 138, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s, border-color 0.2s, color 0.2s;
}

.btn .ic {
    width: 18px;
    height: 18px;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.6;
    pointer-events: none;
}

.btn.primary {
    background: var(--pri);
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(27, 110, 138, 0.7);
}

.btn.primary:hover {
    background: var(--pri-d);
}

.btn.ghost {
    background: var(--card);
    border-color: var(--line);
}

.btn.ghost:hover {
    border-color: var(--pri);
    color: var(--pri);
}

.btn.danger {
    background: var(--bad);
    color: #fff;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--mut);
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background: var(--pri-l);
    color: var(--pri);
}

.icon-btn[data-act$=del]:hover {
    background: var(--bad-l);
    color: var(--bad);
}

.card {
    padding: 20px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.card h3 {
    margin-bottom: 14px;
    font-size: 16px;
}

.grid2 {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 18px;
    margin-top: 18px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-top: 18px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat b {
    display: block;
    font-size: 21px;
    line-height: 1.3;
}

.bubble {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--pri-l);
    color: var(--pri);
}

.bubble.w {
    background: var(--warn-l);
    color: var(--warn);
}

.bubble.b {
    background: var(--bad-l);
    color: var(--bad);
}

.bubble.o {
    background: var(--ok-l);
    color: var(--ok);
}

.flow {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    align-items: center;
    gap: 18px;
    background: linear-gradient(120deg, #fff 55%, var(--pri-l));
}

.stage span {
    color: var(--mut);
    font-weight: 500;
}

.stage b {
    display: block;
    margin: 2px 0 10px;
    font-size: 28px;
}

.flow .arrow {
    color: var(--acc);
}

.flow .arrow .ic {
    width: 30px;
    height: 30px;
}

.prog {
    min-width: 70px;
    height: 8px;
    border-radius: 8px;
    background: var(--mute-l);
    overflow: hidden;
}

.prog i {
    display: block;
    height: 100%;
    border-radius: 8px;
    background: var(--pri);
    transform-origin: right;
    animation: fill 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.prog.ok i {
    background: var(--ok);
}

@keyframes fill {
    from {
        transform: scaleX(0);
    }
}

.chart {
    display: flex;
    align-items: stretch;
    gap: 12px;
    height: 190px;
}

.bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--mut);
}

.bar em {
    font-style: normal;
}

.bar i {
    width: 100%;
    max-width: 46px;
    min-height: 5px;
    border-radius: 10px 10px 4px 4px;
    background: var(--pri);
    transform-origin: bottom;
    animation: grow 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.bar:last-child i {
    background: var(--acc);
}

@keyframes grow {
    from {
        transform: scaleY(0);
    }
}

.method {
    display: grid;
    gap: 4px;
    margin-bottom: 14px;
}

.method div {
    display: flex;
    justify-content: space-between;
    font-weight: 500;
}

.list {
    display: grid;
    gap: 2px;
}

.mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.mini:hover {
    background: var(--bg);
}

.mini b {
    display: block;
}

.mini .end {
    text-align: end;
}

.tbl {
    overflow-x: auto;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th {
    padding: 14px 16px;
    background: #F8FAFA;
    border-bottom: 1px solid var(--line);
    color: var(--mut);
    font-size: 13px;
    font-weight: 500;
    text-align: start;
    white-space: nowrap;
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

td b {
    display: block;
}

tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

tbody tr:hover {
    background: #F6FAFA;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.acts {
    text-align: end;
    white-space: nowrap;
}

.who {
    display: flex;
    align-items: center;
    gap: 12px;
}

.av {
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--acc);
    color: #3D2A05;
    font-weight: 700;
}

.badge,
.chip {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.badge.ok {
    background: var(--ok-l);
    color: var(--ok);
}

.badge.warn {
    background: var(--warn-l);
    color: var(--warn);
}

.badge.bad {
    background: var(--bad-l);
    color: var(--bad);
}

.badge.info {
    background: var(--info-l);
    color: var(--info);
}

.badge.mute {
    background: var(--mute-l);
    color: var(--mut);
}

.chip {
    background: var(--mute-l);
}

.chip.m-cash {
    background: #E6F4EA;
    color: #247A4F;
}

.chip.m-bank {
    background: var(--info-l);
    color: var(--info);
}

.chip.m-wallet {
    background: #FDEBD3;
    color: #9A5B07;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 20px;
    background: var(--card);
    border: 2px dashed var(--line);
    border-radius: var(--radius);
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin-bottom: 16px;
    border-radius: 24px;
    background: var(--pri-l);
    color: var(--pri);
}

.empty-icon .ic {
    width: 34px;
    height: 34px;
}

.empty h3 {
    margin-bottom: 4px;
    font-size: 18px;
}

.empty p {
    max-width: 340px;
    margin-bottom: 20px;
    color: var(--mut);
}

.empty h3:last-child,
.empty p:last-child {
    margin-bottom: 0;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(20, 42, 48, 0.45);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.2s;
}

.overlay.show {
    opacity: 1;
}

.modal {
    width: min(640px, 100%);
    max-height: 92vh;
    padding: 24px;
    overflow-y: auto;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 30px 70px -20px rgba(20, 42, 48, 0.5);
    transform: translateY(18px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.overlay.show .modal {
    transform: none;
}

.modal:focus {
    outline: none;
}

.modal > header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
}

.head-buttons {
    display: flex;
    flex: none;
    align-items: center;
    gap: 2px;
}

.modal h3 {
    font-size: 20px;
}

.modal h4 {
    margin: 20px 0 8px;
    font-size: 15px;
}

.modal footer {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form label {
    display: grid;
    gap: 4px;
    font-size: 14px;
    font-weight: 500;
}

.form label.full {
    grid-column: 1 / -1;
}

.form .form-section {
    grid-column: 1 / -1;
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--mut);
    font-size: 13.5px;
    font-weight: 600;
}

.form textarea {
    resize: vertical;
}

.preview {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--pri-l);
    color: var(--pri-d);
}

.quick {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 18px;
}

.quick .btn {
    justify-content: center;
    padding-inline: 10px;
    white-space: nowrap;
}

.trio {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.trio div {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg);
}

.trio b {
    display: block;
    font-size: 17px;
}

.trio .hl {
    background: var(--warn-l);
}

.meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    margin-bottom: 16px;
}

.note {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg);
    color: var(--mut);
}

.confirm {
    text-align: center;
}

.confirm .ic {
    width: 46px;
    height: 46px;
    color: var(--bad);
}

.confirm p {
    margin: 6px 0;
    color: var(--mut);
}

.confirm footer {
    justify-content: center;
}

#toasts {
    position: fixed;
    bottom: 24px;
    left: 50%;
    z-index: 80;
    display: grid;
    gap: 8px;
    transform: translateX(-50%);
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: 14px;
    background: var(--ink);
    color: #fff;
    box-shadow: 0 14px 30px -10px rgba(0, 0, 0, 0.4);
    animation: toast 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.toast.bad {
    background: var(--bad);
}

.toast .ic {
    color: #7BE0B0;
}

.toast.bad .ic {
    color: #fff;
}

@keyframes toast {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
}

.tax-controls {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 0;
}

.tax-alerts {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.tax-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--warn-l);
    color: var(--warn);
    font-weight: 500;
}

.tax-alert.bad {
    background: var(--bad-l);
    color: var(--bad);
}

.tax-alert .ic {
    flex: none;
}

.tax-section {
    margin-top: 18px;
}

.tax-scroll {
    overflow-x: auto;
}

.tax-table {
    min-width: 0;
}

.tax-table th,
.tax-table td {
    padding: 10px 12px;
    white-space: nowrap;
}

.tax-table tbody tr {
    cursor: default;
}

.tax-table tbody tr:hover {
    background: none;
}

.tax-table tbody tr:last-child td {
    border-bottom: 1px solid var(--line);
}

.tax-table tr.is-empty td {
    color: var(--mut);
}

.tax-table tfoot td {
    background: var(--pri-l);
    color: var(--pri-d);
    font-weight: 700;
}

.tax-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
}

.tax-line span {
    color: var(--mut);
}

.tax-line.total {
    margin-top: 6px;
    padding: 12px 14px;
    border: 0;
    border-radius: 12px;
    background: var(--warn-l);
}

.tax-line.total span,
.tax-line.total b {
    color: var(--warn);
    font-size: 16px;
}

.tax-details .tax-unit {
    display: block;
    margin-top: 12px;
}

.tax-details .tax-scroll {
    margin-top: 6px;
}

.tax-notes {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
    padding-inline-start: 20px;
}

.tax-notes li::marker {
    color: var(--acc);
}

@media (max-width: 760px) {
    .tax-controls {
        grid-template-columns: 1fr;
    }
}

.tax-controls .btn {
    align-self: end;
    justify-content: center;
}

.tax-table .tax-wrap {
    min-width: 160px;
    white-space: normal;
}

.tax-hint {
    margin-top: 12px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.card-head h3 {
    margin: 0;
}

.nav-more,
.more-menu {
    display: none;
}

.settings {
    display: grid;
    gap: 18px;
}

.settings-lead {
    margin-bottom: 14px;
    color: var(--mut);
}

.type-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    transition: background 0.15s;
}

.type-row:hover {
    background: var(--bg);
}

.type-row b {
    display: block;
}

.reassign-note {
    margin-bottom: 14px;
    color: var(--mut);
}

.reassign-note b {
    color: var(--ink);
}

.choices {
    display: grid;
    gap: 10px;
}

.choice {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    transition: border-color 0.2s, background 0.2s;
}

.choice.on {
    border-color: var(--pri);
    background: var(--pri-l);
}

.choice-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.choice-head input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--pri);
}

.choice-head label {
    flex: 1;
    cursor: pointer;
}

.choice-field {
    margin-top: 12px;
}

.choice-field label {
    display: grid;
    gap: 4px;
    font-size: 14px;
    font-weight: 500;
}

.help {
    display: grid;
    gap: 18px;
}

.help-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.help-section {
    scroll-margin-top: 16px;
}

.help-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.help-section h3 .ic {
    color: var(--pri);
}

.help-lead {
    margin-bottom: 14px;
    color: var(--mut);
}

.help-steps {
    display: grid;
    gap: 12px;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.help-steps li {
    position: relative;
    min-height: 30px;
    padding-inline-start: 44px;
    line-height: 30px;
    counter-increment: step;
}

.help-steps li::before {
    content: counter(step);
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: var(--pri-l);
    color: var(--pri-d);
    font-weight: 700;
    line-height: 1;
}

.help-item {
    border-top: 1px solid var(--line);
}

.help-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.help-item summary::-webkit-details-marker {
    display: none;
}

.help-item summary::after {
    content: '+';
    color: var(--pri);
    font-size: 22px;
    line-height: 1;
}

.help-item[open] summary::after {
    content: '−';
}

.help-body {
    display: grid;
    gap: 12px;
    padding-bottom: 16px;
}

.help-body ul {
    display: grid;
    gap: 6px;
    padding-inline-start: 20px;
}

.help-body li::marker {
    color: var(--acc);
}

.help-terms {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 8px 18px;
}

.help-terms dt {
    color: var(--pri-d);
    font-weight: 600;
}

.help-terms dd {
    margin: 0;
}

.help-callout {
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--pri-l);
    color: var(--pri-d);
}

.help-callout.warn {
    background: var(--warn-l);
    color: var(--warn);
}

.help-callout ul {
    margin-top: 8px;
}

@media (max-width: 760px) {
    .help-terms {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .help-terms dd {
        margin-bottom: 8px;
    }
}

.invoice-sheet {
    display: none;
}

@page {
    size: A4;
    margin: 0;
}

@page tax {
    size: A4;
    margin: 10mm 0 12mm;
}

@media print {
    body > *:not(.invoice-sheet) {
        display: none !important;
    }

    html,
    body {
        background: #fff;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .no-print {
        display: none !important;
    }

    .invoice-sheet {
        --sheet-pad: 14mm;
        display: flex;
        flex-direction: column;
        width: 210mm;
        min-height: 296mm;
        background: #fff;
        color: var(--ink);
        font-size: 10.5pt;
        line-height: 1.55;
    }

    .invoice-sheet small {
        display: block;
        color: var(--mut);
        font-size: 8.5pt;
        font-weight: 500;
    }

    .sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12mm var(--sheet-pad) 10mm;
        background: linear-gradient(135deg, var(--pri-d), var(--pri));
        border-bottom: 1.6mm solid var(--acc);
        color: #fff;
    }

    .sheet-brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .sheet-brand b {
        display: block;
        font-size: 15pt;
        line-height: 1.2;
    }

    .sheet-brand small {
        color: rgba(255, 255, 255, 0.75);
    }

    .sheet-logo {
        width: 13mm;
        height: 13mm;
    }

    .sheet-title {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
        text-align: left;
    }

    .sheet-title h1 {
        font-size: 26pt;
        font-weight: 700;
        line-height: 1;
        letter-spacing: 0.5px;
    }

    .sheet-number {
        font-size: 12pt;
        font-weight: 600;
        direction: ltr;
        color: var(--acc);
    }

    .sheet-body {
        display: flex;
        flex-direction: column;
        gap: 8mm;
        padding: 10mm var(--sheet-pad) 0;
    }

    .sheet-info {
        display: grid;
        grid-template-columns: 1fr 1fr 0.9fr;
        gap: 6mm;
    }

    .sheet-party {
        display: flex;
        flex-direction: column;
        gap: 1px;
        padding-inline-start: 4mm;
        border-inline-start: 1mm solid var(--acc);
    }

    .sheet-party b {
        font-size: 12pt;
    }

    .sheet-party span {
        color: var(--mut);
        font-size: 9.5pt;
        overflow-wrap: anywhere;
    }

    .sheet-dates {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 3mm;
        padding: 4mm;
        background: var(--pri-l);
        border-radius: 3mm;
    }

    .sheet-dates b {
        color: var(--pri-d);
        font-size: 10.5pt;
    }

    .sheet-table {
        width: 100%;
        min-width: 0;
        border-collapse: collapse;
        table-layout: fixed;
    }

    .sheet-table th {
        padding: 3mm 4mm;
        background: var(--pri-l);
        color: var(--pri-d);
        font-size: 9.5pt;
        font-weight: 600;
        text-align: right;
        white-space: normal;
        border-bottom: 0;
    }

    .sheet-table th:first-child {
        border-radius: 0 2.5mm 2.5mm 0;
    }

    .sheet-table th:last-child {
        border-radius: 2.5mm 0 0 2.5mm;
    }

    .sheet-table td {
        padding: 4mm;
        border-bottom: 1px solid var(--line);
        vertical-align: top;
    }

    .sheet-table tr {
        break-inside: avoid;
        cursor: auto;
    }

    .sheet-table tbody tr:last-child td {
        border-bottom: 1px solid var(--line);
    }

    .sheet-table .col-money {
        width: 40mm;
        font-weight: 700;
        text-align: left;
        white-space: nowrap;
    }

    .sheet-summary {
        display: grid;
        grid-template-columns: 1fr 88mm;
        gap: 8mm;
        break-inside: avoid;
    }

    .sheet-project {
        display: flex;
        flex-direction: column;
        gap: 2.5mm;
        padding: 5mm;
        border: 1px solid var(--line);
        border-top: 1.2mm solid var(--pri);
        border-radius: 3mm;
    }

    .sheet-project h2 {
        font-size: 14pt;
        font-weight: 700;
        line-height: 1.4;
    }

    .sheet-project-row {
        display: flex;
        justify-content: space-between;
        padding-bottom: 2mm;
        border-bottom: 1px dashed var(--line);
    }

    .sheet-project-row span {
        color: var(--mut);
    }

    .sheet-project-notes {
        color: var(--mut);
        font-size: 9.5pt;
        white-space: pre-wrap;
    }

    .sheet-progress {
        display: flex;
        flex-direction: column;
        gap: 1.5mm;
        margin-top: auto;
    }

    .sheet-progress-label {
        display: flex;
        justify-content: space-between;
        font-size: 9.5pt;
    }

    .sheet-progress-label span {
        color: var(--mut);
    }

    .sheet-progress-label b {
        color: var(--ok);
    }

    .sheet-progress .prog i {
        animation: none;
    }

    .sheet-totals {
        display: flex;
        flex-direction: column;
        padding: 5mm;
        border: 1px solid var(--line);
        border-top: 1.2mm solid var(--pri);
        border-radius: 3mm;
        break-inside: avoid;
    }

    .sheet-totals small {
        margin-bottom: 1.5mm;
    }

    .sheet-total-row {
        display: flex;
        justify-content: space-between;
        padding: 2.2mm 0;
        border-bottom: 1px solid var(--line);
    }

    .sheet-total-row span {
        color: var(--mut);
    }

    .sheet-total-row.is-discount b {
        color: var(--bad);
    }

    .sheet-total-row.is-total {
        margin-top: 2mm;
        padding: 3.2mm 4mm;
        background: var(--pri);
        border-radius: 2.5mm;
        border-bottom: 0;
        color: #fff;
        font-size: 12.5pt;
    }

    .sheet-total-row.is-total span {
        color: rgba(255, 255, 255, 0.85);
    }

    .sheet-total-row.is-paid b {
        color: var(--ok);
    }

    .sheet-total-row.is-due {
        margin-top: 2mm;
        padding: 3mm 4mm;
        background: var(--warn-l);
        border-radius: 2.5mm;
        border-bottom: 0;
        font-size: 11.5pt;
    }

    .sheet-total-row.is-due span,
    .sheet-total-row.is-due b {
        color: var(--warn);
    }

    .sheet-block {
        break-inside: avoid;
    }

    .sheet-block h2 {
        margin-bottom: 3mm;
        font-size: 11pt;
        font-weight: 700;
    }

    .sheet-notes {
        padding: 4mm;
        background: #FBF7EE;
        border-inline-start: 1mm solid var(--acc);
        border-radius: 2.5mm;
        color: var(--ink);
        white-space: pre-wrap;
    }

    .sheet-foot {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6mm;
        margin-top: auto;
        padding: 6mm var(--sheet-pad);
        background: var(--bg);
        border-top: 1px solid var(--line);
    }

    .sheet-foot p {
        font-weight: 600;
        color: var(--pri-d);
    }

    .sheet-links {
        display: flex;
        gap: 5mm;
        color: var(--mut);
        font-size: 8.5pt;
        direction: ltr;
    }
}

@media print {
    .invoice-sheet.tax-sheet {
        --tax-gap: 6mm;
        display: block;
        min-height: 0;
        page: tax;
    }

    .tax-sheet .sheet-head {
        margin: 0 var(--sheet-pad);
        padding: 8mm 10mm 7mm;
        border-radius: 3mm;
    }

    .tax-sheet .sheet-title {
        flex-direction: row;
        align-items: center;
        gap: 5mm;
    }

    .tax-sheet .sheet-title h1 {
        font-size: 24pt;
        line-height: 1.5;
    }

    .tax-sheet .sheet-number {
        padding: 0.5mm 5mm;
        background: rgba(255, 255, 255, 0.14);
        border: 0.5mm solid var(--acc);
        border-radius: 3mm;
        color: #fff;
        font-size: 20pt;
        font-weight: 700;
        line-height: 1.5;
    }

    .tax-sheet .sheet-body {
        display: block;
        padding-top: var(--tax-gap);
    }

    .tax-sheet .sheet-body > * + * {
        margin-top: var(--tax-gap);
    }

    .tax-sheet .sheet-info {
        grid-template-columns: repeat(3, 1fr);
        gap: 4mm;
    }

    .tax-sheet .sheet-party,
    .tax-sheet .sheet-dates {
        padding: 4mm 5mm;
        border-radius: 3mm;
    }

    .tax-sheet .sheet-party {
        border: 1px solid var(--line);
        border-inline-start: 1mm solid var(--acc);
    }

    .tax-sheet .sheet-summary {
        grid-template-columns: 1fr 1fr;
        gap: 4mm;
    }

    .tax-sheet .sheet-total-row b,
    .tax-sheet .sheet-project-row b {
        white-space: nowrap;
    }

    .tax-sheet .sheet-total-row.is-total {
        font-size: 11.5pt;
    }

    .tax-sheet .sheet-block {
        break-inside: auto;
    }

    .tax-sheet .sheet-block h2 {
        break-after: avoid;
    }

    .tax-sheet .sheet-table th,
    .tax-sheet .sheet-table td,
    .tax-sheet .sheet-table .col-money {
        width: auto;
        text-align: center;
    }

    .tax-sheet .sheet-table th:first-child,
    .tax-sheet .sheet-table td:first-child {
        text-align: start;
    }

    .tax-sheet .sheet-table th {
        padding: 2.5mm 4mm;
    }

    .tax-sheet .sheet-table td {
        padding: 2.2mm 4mm;
    }

    .tax-sheet .sheet-table thead,
    .tax-sheet .sheet-table tfoot {
        display: table-row-group;
    }

    .tax-sheet .sheet-table tfoot td {
        background: var(--pri-l);
        border-bottom: 0;
        color: var(--pri-d);
        font-weight: 700;
    }

    .tax-sheet .sheet-table tr.is-empty td {
        color: var(--mut);
    }

    .tax-sheet .sheet-notes + .sheet-notes,
    .tax-sheet .sheet-table + .sheet-notes {
        margin-top: 3mm;
    }

    .tax-sheet .sheet-foot {
        flex-direction: column;
        gap: 2mm;
        margin: var(--tax-gap) var(--sheet-pad) 0;
        padding: 4mm 5mm;
        border: 1px solid var(--line);
        border-radius: 3mm;
        text-align: center;
        break-inside: avoid;
    }

    .tax-sheet .sheet-links {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

.top-logo,
.search-toggle,
.chips,
.mcards,
.socials-foot {
    display: none;
}

.chip-btn {
    flex: none;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    color: var(--mut);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.chip-btn.on {
    border-color: var(--pri);
    background: var(--pri);
    color: #fff;
}

.account-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
}

.account-btn:hover {
    border-color: var(--pri);
}

.account-info {
    display: grid;
    gap: 10px;
}

.account-info div {
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg);
}

.account-info b {
    display: block;
    font-size: 17px;
}

.modal .account-footer {
    justify-content: center;
}

.notice {
    text-align: center;
}

.notice-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 20px;
    background: var(--warn-l);
    color: var(--warn);
}

.notice-icon.bad {
    background: var(--bad-l);
    color: var(--bad);
}

.notice-icon .ic {
    width: 30px;
    height: 30px;
}

.notice h3 {
    margin-bottom: 6px;
}

.notice > p {
    color: var(--mut);
}

.notice footer {
    justify-content: center;
}

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px 16px;
    background:
        radial-gradient(circle at 12% 8%, var(--pri-l), transparent 45%),
        radial-gradient(circle at 92% 92%, #FDEBD3, transparent 40%),
        var(--bg);
}

.auth-card {
    width: min(440px, 100%);
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--card);
    box-shadow: 0 30px 70px -30px rgba(20, 42, 48, 0.35);
    animation: auth-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

@keyframes auth-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 26px;
}

.auth-brand b {
    display: block;
    font-size: 20px;
    line-height: 1.2;
}

.auth-card h1 {
    margin-bottom: 4px;
    font-size: 24px;
    text-align: center;
}

.auth-lead {
    margin-bottom: 22px;
    text-align: center;
    color: var(--mut);
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-field {
    display: grid;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
}

.input-wrap {
    position: relative;
}

.input-wrap > .ic {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    color: var(--mut);
    pointer-events: none;
    transform: translateY(-50%);
}

.auth-field input {
    width: 100%;
    padding: 12px 14px;
    padding-inline-start: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-field input.has-reveal {
    padding-inline-end: 48px;
}

.auth-field input:focus {
    outline: 0;
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgba(27, 110, 138, 0.15);
}

.reveal {
    position: absolute;
    inset-inline-end: 6px;
    top: 50%;
    transform: translateY(-50%);
}

.auth-submit {
    justify-content: center;
    width: 100%;
    margin-top: 4px;
    padding: 13px 18px;
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bad-l);
    color: var(--bad);
    font-weight: 500;
}

.auth-alert.warn {
    background: var(--warn-l);
    color: var(--warn);
}

@media (max-width: 480px) {
    .auth {
        align-items: start;
        padding-top: calc(32px + env(safe-area-inset-top, 0px));
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .auth-card h1 {
        font-size: 22px;
    }
}

@media (pointer: coarse) {
    .icon-btn {
        width: 40px;
        height: 40px;
    }
}

@media (min-width: 761px) and (max-width: 1100px) {
    .app {
        grid-template-columns: 88px 1fr;
    }

    .side {
        align-items: center;
        padding: 20px 10px;
    }

    .brand {
        padding: 0 0 22px;
    }

    .brand div {
        display: none;
    }

    .nav {
        width: 100%;
        gap: 6px;
    }

    .nav a {
        justify-content: center;
        height: 50px;
        padding: 0;
        font-size: 0;
    }

    .nav a.on::after {
        inset-inline-end: -10px;
    }

    .socials-side {
        flex-direction: column;
        width: 100%;
    }

    .main {
        padding: 22px 24px 48px;
    }

    .top {
        gap: 12px;
        margin-bottom: 20px;
    }

    .top h1 {
        font-size: 23px;
    }

    .tools {
        flex: 1;
        justify-content: flex-end;
    }

    .socials-top {
        display: none;
    }

    .search {
        flex: 1;
        max-width: 280px;
    }

    .search input {
        flex: 1;
        min-width: 120px;
    }

    .card {
        padding: 18px;
    }

    .flow {
        gap: 12px;
        padding: 18px;
    }

    .stage b {
        font-size: 21px;
    }

    .flow .arrow .ic {
        width: 22px;
        height: 22px;
    }

    .stats {
        gap: 14px;
    }

    .stat {
        gap: 12px;
    }

    .stat b {
        font-size: 18px;
    }

    .bubble {
        width: 42px;
        height: 42px;
    }

    .grid2 {
        gap: 14px;
    }

    table {
        min-width: 660px;
    }

    td:not(:first-child),
    td:not(:first-child) b {
        white-space: nowrap;
    }

    td:first-child {
        min-width: 190px;
    }

    th,
    td {
        padding: 12px 12px;
    }

    .modal {
        width: min(680px, 100%);
        padding: 26px;
    }

    .tax-controls {
        grid-template-columns: 1fr 1fr auto;
    }

    .help {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }

    .help-nav,
    .help-section:first-of-type {
        grid-column: 1 / -1;
    }
}

@media (min-width: 761px) and (max-width: 900px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid2 {
        grid-template-columns: 1fr 1fr;
    }

    .help {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    :root {
        --bar-h: 64px;
        --safe-b: env(safe-area-inset-bottom, 0px);
        --radius: 16px;
    }

    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        font-size: 15px;
        -webkit-tap-highlight-color: transparent;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .tooltip {
        display: none;
    }

    .app {
        display: block;
    }

    .side {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 40;
        display: block;
        height: auto;
        padding: 0 0 var(--safe-b);
        padding-inline: max(4px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
        border: 0;
        border-top: 1px solid var(--line);
        background: rgba(255, 255, 255, 0.94);
        backdrop-filter: blur(14px);
    }

    .brand,
    .socials-side {
        display: none;
    }

    .nav {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 0;
        height: var(--bar-h);
    }

    .nav a,
    .nav-more {
        position: relative;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 0;
        border-radius: 14px;
        color: var(--mut);
        font-size: 10.5px;
        font-weight: 500;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
    }

    .nav .ic {
        width: 22px;
        height: 22px;
    }

    .nav .lbl {
        display: block;
        max-width: 100%;
        font-size: 0;
        text-align: center;
    }

    .nav .lbl::after {
        content: attr(data-short);
        display: block;
        font-size: 10px;
        line-height: 1.6;
        letter-spacing: 0;
        white-space: nowrap;
    }

    .socials-foot {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin-top: 28px;
    }

    .socials-foot .social {
        width: 44px;
        height: 44px;
    }

    .nav a.on,
    .nav-more.on {
        background: none;
        color: var(--pri);
        font-weight: 700;
    }

    .nav a.on::after {
        display: none;
    }

    .nav a.on::before,
    .nav-more.on::before {
        content: '';
        position: absolute;
        top: 0;
        left: 28%;
        right: 28%;
        height: 3px;
        border-radius: 0 0 4px 4px;
        background: var(--acc);
    }

    .nav a[data-tab="settings"],
    .nav a[data-tab="help"] {
        display: none;
    }

    .nav-more {
        border: 0;
        background: none;
    }

    .more-menu:not([hidden]) {
        position: fixed;
        inset-inline-end: 10px;
        bottom: calc(var(--bar-h) + var(--safe-b) + 10px);
        z-index: 45;
        display: grid;
        gap: 2px;
        min-width: 190px;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: var(--card);
        box-shadow: 0 18px 40px -14px rgba(20, 42, 48, 0.45);
        animation: toast 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
    }

    .more-menu a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 12px;
        font-weight: 500;
    }

    .more-menu a.on {
        background: var(--pri-l);
        color: var(--pri-d);
        font-weight: 600;
    }

    .main {
        padding: 0 14px calc(var(--bar-h) + var(--safe-b) + 100px);
    }

    .top {
        position: sticky;
        top: 0;
        z-index: 30;
        flex-wrap: wrap;
        gap: 10px;
        margin: 0 -14px 12px;
        padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
        background: var(--bg);
    }

    .top-logo {
        display: block;
        flex: none;
        width: 34px;
        height: 34px;
    }

    .top h1 {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        font-size: 19px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .search-toggle,
    .account-btn {
        display: inline-grid;
        width: 40px;
        height: 40px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--card);
    }

    body.search-open .search-toggle {
        border-color: var(--pri);
        background: var(--pri-l);
        color: var(--pri);
    }

    .tools {
        display: contents;
    }

    .socials-top,
    .filter {
        display: none;
    }

    .search {
        display: none;
    }

    body.search-open .search {
        display: flex;
        flex-basis: 100%;
        order: 9;
        padding: 0 14px;
    }

    .search input {
        flex: 1;
        min-width: 0;
        padding: 12px 0;
    }

    #add {
        position: fixed;
        inset-inline-end: 16px;
        bottom: calc(var(--bar-h) + var(--safe-b) + 16px);
        z-index: 35;
        justify-content: center;
        width: 58px;
        height: 58px;
        padding: 0;
        border-radius: 20px;
        box-shadow: 0 14px 28px -8px rgba(27, 110, 138, 0.75);
    }

    #add .ic {
        width: 26px;
        height: 26px;
    }

    .add-label {
        display: none;
    }

    .chips:not([hidden]) {
        display: flex;
        gap: 8px;
        margin: 0 -14px 14px;
        padding: 2px 14px 4px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .chips::-webkit-scrollbar {
        display: none;
    }

    .card {
        padding: 16px;
    }

    .card h3 {
        margin-bottom: 12px;
        font-size: 15px;
    }

    .btn {
        padding: 12px 18px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
    }

    .flow {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 6px 16px;
    }

    .flow .arrow {
        display: none;
    }

    .stage {
        padding: 14px 0;
    }

    .stage + .arrow + .stage {
        border-top: 1px dashed var(--line);
    }

    .stage b {
        margin-bottom: 8px;
        font-size: 24px;
    }

    .stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-top: 14px;
    }

    .stat {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px;
    }

    .bubble {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .stat b {
        font-size: 17px;
    }

    .grid2 {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-top: 14px;
    }

    .chart {
        gap: 6px;
        height: 160px;
    }

    .bar {
        font-size: 11px;
    }

    .bar span {
        font-size: 9.5px;
        direction: ltr;
    }

    .tbl {
        display: none;
    }

    .mcards {
        display: grid;
        gap: 12px;
    }

    .mcard {
        display: grid;
        gap: 12px;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--card);
        cursor: pointer;
        transition: transform 0.15s, border-color 0.2s;
    }

    .mcard:active {
        transform: scale(0.985);
        border-color: var(--pri);
    }

    .mcard-top {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .mcard-main {
        flex: 1;
        min-width: 0;
    }

    .mcard-main b,
    .mcard-main small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mcard-main b {
        display: block;
        font-size: 16px;
    }

    .mcard-side {
        flex: none;
        text-align: end;
    }

    .mcard-side b {
        display: block;
    }

    .mcard-prog {
        display: grid;
        gap: 4px;
    }

    .mcard-meta {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
        gap: 8px;
        padding: 10px 12px;
        border-radius: 12px;
        background: var(--bg);
    }

    .mcard-meta > div {
        min-width: 0;
    }

    .mcard-meta b {
        overflow: hidden;
        font-size: 13.5px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mcard-acts {
            display: grid;
            grid-auto-flow: column;
            grid-auto-columns: 1fr;
            gap: 8px;
            margin-top: -2px;
            padding-top: 10px;
            border-top: 1px solid var(--line);
        }

        .mcard-acts .icon-btn {
            width: 100%;
            height: 42px;
            background: var(--bg);
        }

    .empty {
        padding: 40px 18px;
    }

    .overlay {
        place-items: end stretch;
        padding: 0;
    }

    .modal {
        position: relative;
        width: 100%;
        max-height: 92dvh;
        padding: 22px 16px calc(18px + var(--safe-b));
        border-radius: 24px 24px 0 0;
        transform: translateY(100%);
        transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
        overscroll-behavior: contain;
    }

    .modal::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        border-radius: 4px;
        background: var(--line);
        transform: translateX(-50%);
    }

    .overlay.show .modal {
        transform: none;
    }

    .modal > header {
        margin-bottom: 14px;
    }

    .modal h3 {
        font-size: 18px;
    }

    .form {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .modal:has(> form) {
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
        overflow: hidden;
    }

    .modal:has(> form) > header {
        flex: none;
    }

    .modal > form {
        display: flex;
        flex: 1;
        flex-direction: column;
        min-height: 0;
    }

    .modal > form > .form {
        flex: 1;
        min-height: 0;
        padding-bottom: 6px;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .modal > form > .preview {
        flex: none;
    }

    .modal > form > .choices {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .modal form footer {
        flex: none;
        margin: 12px -16px 0;
        padding: 12px 16px calc(14px + var(--safe-b));
        border-top: 1px solid var(--line);
        background: var(--card);
    }

    .modal footer .btn {
        flex: 1;
        justify-content: center;
    }

    .confirm footer {
        flex-wrap: nowrap;
    }

    .quick {
        grid-template-columns: 1fr 1fr;
    }

    .quick .btn.primary {
        grid-column: 1 / -1;
        order: -1;
    }

    .quick .btn.ghost:nth-last-child(2):nth-child(odd) {
        grid-column: 1 / -1;
    }

    .meta {
        grid-template-columns: 1fr 1fr;
        gap: 12px 16px;
        overflow-wrap: anywhere;
    }

    .trio {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .trio div {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px;
    }

    .trio small {
        font-size: 13.5px;
    }

    .trio b {
        font-size: 16px;
    }

    .preview {
        flex-direction: column;
        gap: 2px;
    }

    #toasts {
        bottom: calc(var(--bar-h) + var(--safe-b) + 90px);
        width: calc(100% - 28px);
    }

    .toast {
        padding: 12px 16px;
    }

    .tax-controls {
        gap: 12px;
    }

    .tax-controls .btn {
        padding-block: 13px;
    }

    .tax-table th,
    .tax-table td {
        padding: 9px 10px;
        font-size: 13px;
    }

    .tax-line {
        font-size: 14px;
    }

    .card-head {
        flex-wrap: wrap;
    }

    .help {
        gap: 14px;
    }

    .help-nav {
        flex-wrap: nowrap;
        margin: 0 -14px;
        padding: 2px 14px 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .help-nav::-webkit-scrollbar {
        display: none;
    }

    .help-nav .btn {
        flex: none;
        padding: 9px 14px;
        font-size: 13.5px;
    }

    .help-steps li {
        min-height: 30px;
        padding-top: 3px;
        line-height: 1.7;
    }

    .help-item summary {
        padding: 16px 0;
    }
}

@media (max-width: 760px) and (max-height: 520px) {
    .modal {
        max-height: 100dvh;
    }

    #add {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 380px) {
    .nav .lbl::after {
        font-size: 9px;
    }

    .mcard-meta {
        grid-auto-flow: row;
        grid-template-columns: 1fr 1fr;
    }

    .stat b {
        font-size: 15.5px;
    }
}

.setup-page {
    display: grid;
    place-items: start center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 32px 16px 56px;
    background:
        radial-gradient(circle at 12% 8%, var(--pri-l), transparent 45%),
        radial-gradient(circle at 92% 92%, #FDEBD3, transparent 40%),
        var(--bg);
}

.setup-card {
    width: min(680px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--card);
    box-shadow: 0 30px 70px -30px rgba(20, 42, 48, 0.35);
    animation: auth-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

.setup-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.setup-head .auth-brand {
    justify-content: flex-start;
    margin: 0;
}

.setup-tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.setup-tools .btn {
    padding: 8px 14px;
    font-size: 14px;
}

.setup-steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0 0 24px;
    padding: 0;
    list-style: none;
}

.setup-steps li {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    color: var(--mut);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.setup-steps li:last-child {
    flex: none;
}

.setup-steps li:not(:last-child)::after {
    content: '';
    flex: 1;
    min-width: 16px;
    height: 2px;
    margin-inline: 8px;
    border-radius: 2px;
    background: var(--line);
    transition: background 0.3s;
}

.setup-steps li.done:not(:last-child)::after {
    background: var(--ok);
}

.setup-steps .dot {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--mute-l);
    font-size: 14px;
    transition: background 0.3s, color 0.3s;
}

.setup-steps .dot .ic {
    width: 16px;
    height: 16px;
    stroke-width: 2.8;
}

.setup-steps li.on {
    color: var(--ink);
}

.setup-steps li.on .dot {
    background: var(--pri);
    color: #fff;
}

.setup-steps li.done .dot {
    background: var(--ok);
    color: #fff;
}

.setup-intro {
    margin-bottom: 20px;
    color: var(--mut);
}

.setup-banner {
    margin-bottom: 18px;
}

.setup-body h2 {
    margin-bottom: 4px;
    font-size: 22px;
}

.setup-lead {
    margin-bottom: 18px;
    color: var(--mut);
}

.setup-body code,
.setup-banner code {
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(20, 42, 48, 0.08);
    direction: ltr;
    unicode-bidi: isolate;
    font-size: 0.92em;
}

.setup-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}

.setup-nav-end {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.setup-add {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.setup-add input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.setup-add input:focus {
    outline: 0;
    border-color: var(--pri);
    box-shadow: 0 0 0 3px rgba(27, 110, 138, 0.15);
}

.type-suggestions,
.type-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.type-suggestions {
    margin-bottom: 18px;
}

.type-chips {
    min-height: 44px;
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: 14px;
    background: var(--bg);
}

.type-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--pri-l);
    color: var(--pri-d);
    font-weight: 600;
    animation: auth-in 0.25s both;
}

.type-chip .icon-btn {
    width: 24px;
    height: 24px;
    margin-inline-end: -8px;
    border-radius: 50%;
}

.type-chip .icon-btn .ic {
    width: 14px;
    height: 14px;
}

.type-chip.locked {
    background: var(--mute-l);
    color: var(--mut);
}

.type-chip.locked .ic {
    width: 14px;
    height: 14px;
}

.setup-info {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.setup-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg);
}

.setup-info-row span {
    color: var(--mut);
}

.mono {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    unicode-bidi: isolate;
}

.setup-danger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--bad-l);
    border-radius: 14px;
    background: #FFF8F6;
}

.setup-danger b {
    display: block;
    color: var(--bad);
}

.setup-danger > div {
    flex: 1;
    min-width: 220px;
}

.setup-warn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bad-l);
    color: var(--bad);
    font-weight: 500;
}

.setup-warn p {
    margin: 0;
}

.setup-tasks {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.setup-task {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    transition: background 0.3s, border-color 0.3s;
}

.setup-task b {
    display: block;
}

.setup-task[data-state="done"] {
    border-color: var(--ok-l);
    background: #F6FBF8;
}

.setup-task[data-state="error"] {
    border-color: var(--bad-l);
    background: #FFF8F6;
}

.setup-task[data-state="idle"] {
    opacity: 0.55;
}

.task-status {
    display: grid;
    place-items: center;
    flex: none;
    width: 28px;
    height: 28px;
}

.task-status .ic {
    width: 24px;
    height: 24px;
    stroke-width: 2.6;
    color: var(--ok);
    animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

.setup-task[data-state="error"] .task-status .ic {
    color: var(--bad);
}

.spin {
    width: 22px;
    height: 22px;
    border: 3px solid var(--pri-l);
    border-top-color: var(--pri);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.idle {
    width: 16px;
    height: 16px;
    border: 2px dashed var(--line);
    border-radius: 50%;
}

#setupRunError {
    margin-top: 18px;
}

#setupRunError .auth-alert {
    margin-bottom: 0;
}

.setup-done {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 4px;
    text-align: center;
}

.setup-done h2 {
    font-size: 26px;
}

.setup-done .setup-lead {
    max-width: 420px;
}

.done-badge {
    position: relative;
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    margin-bottom: 18px;
    border-radius: 50%;
    background: var(--ok);
    color: #fff;
    animation: pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

.done-badge::after {
    content: '';
    position: absolute;
    inset: -10px;
    border: 3px solid var(--ok);
    border-radius: 50%;
    opacity: 0;
    animation: ring 1.6s 0.3s ease-out 2;
}

.done-badge .ic {
    width: 46px;
    height: 46px;
    stroke-width: 2.6;
}

.done-badge .ic path {
    stroke-dasharray: 24;
    stroke-dashoffset: 24;
    animation: draw 0.5s 0.35s ease forwards;
}

.setup-note {
    margin-top: 18px;
    color: var(--mut);
    font-size: 13.5px;
}

.confetti-layer {
    position: fixed;
    inset: 0;
    z-index: 70;
    overflow: hidden;
    pointer-events: none;
}

.confetti-layer i {
    position: absolute;
    top: 0;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    opacity: 0;
    animation: confetti-fall linear both;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pop {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
}

@keyframes draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes ring {
    from {
        opacity: 0.6;
        transform: scale(0.85);
    }

    to {
        opacity: 0;
        transform: scale(1.4);
    }
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translate3d(0, -10vh, 0) rotate(0);
    }

    100% {
        opacity: 0.9;
        transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin));
    }
}

@media (max-width: 520px) {
    .setup-page {
        padding: 12px 10px 24px;
        padding: calc(12px + env(safe-area-inset-top)) 10px calc(24px + env(safe-area-inset-bottom));
    }

    .setup-card {
        min-width: 0;
        padding: 20px 16px;
        border-radius: 18px;
    }

    .setup-head {
        align-items: stretch;
        gap: 16px;
        margin-bottom: 22px;
    }

    .setup-head .auth-brand {
        margin: 0;
    }

    .setup-tools {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .setup-tools .badge {
        grid-column: 1 / -1;
        justify-self: start;
        max-width: 100%;
        white-space: normal;
    }

    .setup-tools .btn {
        min-width: 0;
        padding: 10px 8px;
        justify-content: center;
        text-align: center;
        font-size: 13px;
    }

    .setup-steps {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 22px;
    }

    .setup-steps li,
    .setup-steps li:last-child {
        flex-direction: column;
        min-width: 0;
        gap: 6px;
        font-size: 12px;
        text-align: center;
        white-space: normal;
    }

    .setup-steps li:not(:last-child)::after {
        display: none;
    }

    .setup-steps li b {
        display: block;
        font-size: 11px;
        line-height: 1.35;
    }

    .setup-nav {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .setup-nav-end {
        flex-direction: column-reverse;
    }

    .setup-nav .btn {
        justify-content: center;
        width: 100%;
        min-height: 44px;
    }

    .setup-body h2 {
        font-size: 20px;
    }

    .setup-info-row {
        align-items: flex-start;
    }

    .setup-info-row b {
        min-width: 0;
        max-width: 65%;
        overflow-wrap: anywhere;
        text-align: end;
    }

    .setup-danger {
        flex-direction: column;
        align-items: stretch;
    }

    .setup-danger > div {
        min-width: 0;
    }

    .setup-danger .btn,
    .setup-done > .btn {
        justify-content: center;
        width: 100%;
    }

    .setup-task {
        align-items: flex-start;
        gap: 10px;
        padding: 10px 12px;
    }

    .setup-task > div {
        min-width: 0;
    }

    .setup-task small {
        display: block;
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {
    .confetti-layer {
        display: none;
    }

    .done-badge .ic path {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
    }

    .spin {
        border-top-color: var(--pri);
        border-color: var(--pri);
    }
}