/**
 * Tasteology Papers — dashboard UI (iOS glass)
 */

:root {
    --ink: #0b1220;
    --forest: #0a84ff;
    --forest-2: #0071e3;
    --gold: #0a84ff;
    --gold-d: #0071e3;
    --paper: rgba(255, 255, 255, 0.22);
    --cream: rgba(255, 255, 255, 0.58);
    --muted: #5c6573;
    --line: rgba(255, 255, 255, 0.42);
    --locked: rgba(246, 248, 251, 0.55);
    --locked-ink: #7a3b3b;
    --ok: #30d158;
    --warn: #ff9f0a;
    --err: #ff453a;
    --glass: rgba(255, 255, 255, 0.55);
    --glass-strong: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.62);
    --shadow: 0 10px 40px rgba(13, 27, 42, 0.16);
    --blur: saturate(1.85) blur(22px);
    --radius: 22px;
    --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html {
    background: #122033;
}

body {
    font-family: var(--sans);
    color: var(--ink);
    background:
        radial-gradient(920px 520px at 8% -12%, rgba(10, 132, 255, 0.42), transparent 58%),
        radial-gradient(680px 420px at 108% 0%, rgba(94, 92, 230, 0.32), transparent 52%),
        linear-gradient(180deg, #15263a 0%, #1b334c 168px, #d7e2ef 168px, #eef3f8 100%);
}

img {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font-family: inherit;
    touch-action: manipulation;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 16px 28px 14px;
    color: #f7f8fa;
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(15, 28, 44, 0.52);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-mark {
    width: 48px;
    height: 48px;
    border: 0;
    display: grid;
    place-items: center;
    color: #fff;
    overflow: hidden;
    padding: 0;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.logo-mark img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.brand-lockup h1 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 0.34em;
    font-weight: 650;
}

.brand-lockup p {
    margin: 4px 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.62);
    letter-spacing: 0.02em;
}

.status-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chip {
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.12);
    color: #f2f6fb;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 7px 12px;
    border-radius: 999px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.chip.ok {
    border-color: rgba(120, 170, 140, 0.55);
    color: #b7d7c4;
}

.account-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.account-nav a.chip {
    text-decoration: none;
    color: #f2f6fb;
}

.account-layout {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 32px 48px;
    display: grid;
    gap: 16px;
}

.users-list {
    display: grid;
    gap: 8px;
}

.user-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 10px 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    border-radius: 16px;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.user-row .chip {
    color: var(--forest);
    border-color: var(--line);
    margin-left: auto;
}

#client_id[readonly],
#timeline_total[readonly] {
    background: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
    font-weight: 600;
}

.auth-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(900px 420px at 50% -10%, rgba(10, 132, 255, 0.42), transparent 55%),
        radial-gradient(640px 380px at 90% 110%, rgba(94, 92, 230, 0.28), transparent 50%),
        #0d1b2a;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    padding: 36px 32px 28px;
    border-radius: 28px;
    backdrop-filter: saturate(1.8) blur(28px);
    -webkit-backdrop-filter: saturate(1.8) blur(28px);
    color: #f4f7fb;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #f4f7fb;
}

.auth-brand .logo-mark,
.auth-brand .logo-mark img {
    width: 64px;
    height: 64px;
}

.auth-brand .logo-mark {
    border-radius: 16px;
    box-shadow: 0 0 0 1px var(--line);
}

.auth-brand h1 {
    margin: 4px 0 0;
    font-size: 13px;
    letter-spacing: 0.22em;
    font-weight: 700;
}

.auth-brand p {
    margin: 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.62);
    letter-spacing: 0.02em;
}

.auth-card h2 {
    margin: 22px 0 6px;
    font-size: 24px;
    text-align: center;
    font-weight: 700;
    color: #fff;
}

.auth-lead {
    margin: 0 0 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    line-height: 1.45;
}

.auth-card .flash {
    margin-bottom: 16px;
    border-radius: 10px;
}

.auth-card .field {
    margin-bottom: 14px;
}

.auth-card input[type="text"],
.auth-card input[type="password"] {
    min-height: 46px;
    font-size: 16px;
    border-radius: 14px;
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.auth-card label {
    color: rgba(255, 255, 255, 0.62);
}

.auth-card .btn {
    width: 100%;
    margin-top: 8px;
    min-height: 48px;
    border-radius: 12px;
}

.auth-foot {
    margin: 22px 0 0;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 920px);
    justify-content: center;
    gap: 24px;
    padding: 0 32px 48px;
    align-items: start;
}

.panel {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
}

.panel-form {
    padding: 22px 24px 28px;
    overflow: visible;
}

.flash {
    background: rgba(255, 69, 58, 0.12);
    color: #9b1c1c;
    border: 1px solid rgba(255, 69, 58, 0.22);
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 14px;
    border-radius: 16px;
}

.save-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--glass-border);
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 13px;
    border-radius: 16px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.save-banner span {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.save-banner-time {
    font-size: 12px;
}

.flash ul {
    margin: 8px 0 0 18px;
    padding: 0;
}

.section {
    margin-bottom: 22px;
    overflow: visible;
}

.section h2 {
    margin: 0 0 12px;
    font-size: 12px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--forest);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.section-head h2 {
    margin: 0;
}

.ios-lock {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    position: relative;
    z-index: 3;
    cursor: pointer;
    pointer-events: auto;
}

.ios-lock-text {
    font-size: 12px;
    font-weight: 650;
    color: var(--muted);
    letter-spacing: 0.04em;
    pointer-events: none;
}

.ios-switch {
    width: 51px;
    height: 31px;
    border: 0;
    border-radius: 16px;
    background: #e9e9eb;
    position: relative;
    z-index: 4;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    pointer-events: auto;
    transition: background 0.2s ease;
}

.ios-switch.is-on {
    background: #34c759;
}

.ios-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease;
}

.ios-switch.is-on .ios-switch-knob {
    transform: translateX(20px);
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.type-card {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.42);
    padding: 14px 12px;
    text-align: left;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    display: block;
    border-radius: 16px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.save-banner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.type-card small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.02em;
}

.type-card.active {
    border-color: rgba(10, 132, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
    background: rgba(10, 132, 255, 0.12);
}

.pay-pick {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.pay-card {
    display: block;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.42);
    padding: 12px;
    border-radius: 16px;
    cursor: pointer;
}

.pay-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.pay-card strong,
.pay-card small {
    display: block;
}

.pay-card small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}

.pay-card.is-on {
    border-color: rgba(10, 132, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
    background: rgba(10, 132, 255, 0.12);
}

.pay-preview {
    margin-top: 10px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(13, 27, 42, 0.04);
    font-size: 13px;
    line-height: 1.55;
    white-space: normal;
}

.pay-preview + .pay-preview {
    border-top: 1px solid rgba(18, 32, 51, 0.22);
    border-radius: 0 0 12px 12px;
}

.pay-preview .pay-lines {
    width: 100%;
    border-collapse: collapse;
}

.pay-preview .pay-lines th,
.pay-preview .pay-lines td {
    padding: 5px 0;
    vertical-align: top;
    text-align: left;
    font-size: 13px;
    line-height: 1.5;
    border-bottom: 1px solid rgba(18, 32, 51, 0.12);
}

.pay-preview .pay-lines tr:last-child th,
.pay-preview .pay-lines tr:last-child td {
    border-bottom: 0;
}

.pay-preview .pay-lines th {
    width: 46%;
    padding-right: 12px;
    font-weight: 700;
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 12px;
    overflow: visible;
}

.phase-picks {
    display: grid;
    gap: 8px;
    margin: 0 0 16px;
}

.phase-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.42);
    border-radius: 14px;
    font-size: 14px;
}

.phase-pick input {
    width: 18px;
    height: 18px;
}

.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.full {
    grid-column: 1 / -1;
}

.suggest-field {
    position: relative;
    z-index: 80;
    overflow: visible;
}

.suggest-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 400;
    display: none;
    flex-direction: column;
    gap: 4px;
    max-height: 280px;
    overflow: auto;
    padding: 8px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(10, 132, 255, 0.28);
    box-shadow: 0 16px 40px rgba(13, 27, 42, 0.22);
}

.suggest-list.is-open {
    display: flex;
}

.suggest-item {
    text-align: left;
    border: 0;
    background: #f4f8fc;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    color: #0b1220;
    cursor: pointer;
}

.suggest-item strong {
    display: block;
    font-weight: 650;
}

.suggest-item small {
    display: block;
    margin-top: 2px;
    color: #5c6573;
    font-size: 12px;
}

.suggest-item:hover,
.suggest-item:focus,
.suggest-item.is-active {
    background: rgba(10, 132, 255, 0.16);
}

.suggest-empty {
    padding: 10px 12px;
    color: #5c6573;
    font-size: 13px;
}

.duration-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr minmax(108px, 0.9fr);
    gap: 8px;
    align-items: center;
}

.duration-till {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: var(--glass-strong);
    color: var(--ink);
    padding: 11px 12px;
    font-size: 14px;
    border-radius: 12px;
}

textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: rgba(10, 132, 255, 0.7);
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.18);
}

.hint {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 10px;
}

.live-date {
    margin: 0 0 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--locked);
    font-size: 14px;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.items-table th {
    text-align: left;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 6px 8px;
}

.items-table td {
    padding: 4px;
    vertical-align: middle;
}

.items-table input {
    padding: 8px;
}

.phase-ms-block {
    margin-top: 22px;
}

.phase-ms-table td {
    vertical-align: top;
}

.phase-ms-table textarea {
    min-height: 118px;
    padding: 8px;
    font-size: 13px;
}

.phase-ms-total {
    margin-top: 10px;
}

.share-box {
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.4);
}

.share-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.share-row input {
    flex: 1 1 220px;
}

.share-row .btn {
    white-space: nowrap;
}

.amount-step {
    display: flex;
    align-items: center;
    gap: 6px;
}

.amount-step .js-amount {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.amount-step .btn.secondary {
    width: auto;
    min-width: 58px;
    padding: 8px 6px;
    font-size: 11px;
    letter-spacing: 0;
}

.col-qty,
.col-price,
.col-line {
    width: 108px;
}

.col-price {
    width: 230px;
}

.col-line {
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding-right: 8px !important;
    color: var(--forest);
}

.col-remove {
    width: 40px;
}

.bill-add-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 12px 0 4px;
}

.bill-add-row .hint {
    margin: 0;
}

.team-pick-name {
    display: block;
    font-weight: 600;
}

.team-pick-role {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

#team-block #scientist-select {
    max-width: 100%;
}

.btn {
    appearance: none;
    border: 0;
    background: #0a84ff;
    color: #fff;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
    text-transform: none;
    cursor: pointer;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(10, 132, 255, 0.28);
}

.btn:hover {
    background: #0071e3;
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.5);
    color: var(--ink);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.btn.ghost {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--err);
    padding: 6px 8px;
    letter-spacing: 0;
    text-transform: none;
}

.totals-box {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: rgba(255, 255, 255, 0.38);
    border: 1px solid var(--glass-border);
    padding: 14px;
    border-radius: 16px;
}

.total-readout {
    text-align: right;
    font-size: 14px;
    line-height: 1.7;
}

.total-readout strong {
    display: block;
    font-size: 22px;
    letter-spacing: 0.02em;
    color: var(--forest);
}

.terms-box {
    background: rgba(255, 255, 255, 0.38);
    border: 1px solid var(--glass-border);
    padding: 14px 16px;
    border-radius: 16px;
}

.terms-box.is-fixed {
    background: rgba(246, 248, 251, 0.45);
}

.clause-card {
    border-top: 0;
    padding: 0 0 12px;
}

.clause-card label {
    display: block;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 6px;
}

.clause-card input,
.clause-card textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.5;
    background: var(--glass-strong);
    resize: vertical;
}

.clause-card textarea {
    margin-top: 8px;
}

.terms-box.is-fixed .clause-card input,
.terms-box.is-fixed .clause-card textarea {
    background: rgba(238, 242, 246, 0.72);
    color: #333;
    cursor: default;
}

.clause-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.clause-card-head label {
    margin: 0;
}

.clause-card-head .js-clause-remove {
    font-size: 18px;
    line-height: 1;
    padding: 0 6px;
    margin-left: auto;
}

.terms-box.is-fixed .js-clause-remove {
    display: none;
}

.spacer-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 32px;
    margin: 2px 0 10px;
    padding: 0 12px;
    border: 1.5px dashed rgba(10, 132, 255, 0.35);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.35);
    color: #5a7388;
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
    transition: height 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.spacer-bar:hover {
    background: #e7f0f7;
    border-color: #2f5d7c;
    color: #2f5d7c;
}

.spacer-bar.is-on {
    align-items: flex-start;
    padding-top: 8px;
    background: repeating-linear-gradient(
        -45deg,
        #eef5fa,
        #eef5fa 8px,
        #e4eef6 8px,
        #e4eef6 16px
    );
}

.spacer-bar-label {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    pointer-events: none;
}

.terms-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.file-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.signer-pick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.signer-card {
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.45);
    padding: 14px 12px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    width: 100%;
    border-radius: 16px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.signer-card.active {
    border-color: rgba(10, 132, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.16);
    background: rgba(10, 132, 255, 0.12);
}

.signer-card-head strong {
    display: block;
    font-size: 14px;
}

.signer-card-head small {
    display: block;
    margin: 4px 0 8px;
    color: var(--muted);
    font-size: 12px;
}

.signer-using {
    display: none;
    margin: 0 0 10px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--forest);
    font-weight: 650;
}

.signer-card.active .signer-using {
    display: block;
}

.signer-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
}

.signer-preview-sig {
    max-height: 48px;
    max-width: 140px;
    display: block;
    background: #fff;
}

.signer-preview-stamp {
    max-height: 52px;
    max-width: 52px;
    display: block;
    background: #fff;
}

.upload-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.upload-trigger {
    width: 100%;
    min-height: 48px;
}

.upload-thumb {
    max-height: 36px;
    max-width: 72px;
    display: block;
    background: #fff;
    border: 1px solid var(--line);
}

.sig-status,
.stamp-preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.stamp-preview-row {
    margin: 0 0 12px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(238, 243, 248, 0), rgba(238, 243, 248, 0.88) 40%);
    padding-top: 16px;
}

.terms-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}


.preview-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 200;
    display: flex;
    flex-direction: column;
    background: #2b2b2b;
}

.preview-modal[hidden] {
    display: none !important;
}

.preview-modal-bar {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    min-height: 56px;
    padding: 10px 16px;
    color: #f7f8fa;
    background: rgba(16, 16, 18, 0.62);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.preview-modal-bar span {
    flex: 1;
    font-size: 12px;
    color: #c9d4e0;
}

.preview-modal-bar .btn,
.preview-modal-bar .btn.secondary {
    position: relative;
    z-index: 31;
    width: auto;
    min-width: 96px;
    min-height: 40px;
    cursor: pointer;
}

.preview-modal-stage {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    background: #525659;
}

.preview-modal-stage iframe,
.preview-modal-stage embed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: #525659;
}

.preview-pdf-pages {
    position: absolute;
    inset: 0;
    overflow: auto;
    padding: 18px 16px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    box-sizing: border-box;
}

.preview-pdf-pages[hidden] {
    display: none !important;
}

.preview-pdf-pages canvas {
    display: block;
    max-width: min(920px, 100%);
    height: auto;
    background: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.preview-modal-stage iframe[hidden],
.preview-modal-stage embed[hidden] {
    display: none !important;
}

.preview-modal-status {
    position: absolute;
    left: 0;
    right: 0;
    top: 28px;
    z-index: 2;
    margin: 0;
    text-align: center;
    color: #fff;
    pointer-events: none;
}

.preview-modal-status:empty {
    display: none;
}

body.preview-open {
    overflow: hidden;
}

.preview-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #4a433a;
}

.preview-frame-wrap {
    flex: 1;
    min-height: 640px;
    overflow: hidden;
    background: #525659;
}

#pdf-preview {
    display: block;
    width: 100%;
    height: calc(100vh - 120px);
    min-height: 640px;
    border: 0;
    background: #525659;
}

#client_address {
    min-height: 72px;
}

.app-dock {
    display: none;
}

.archive-layout {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 32px 48px;
    display: grid;
    gap: 16px;
}

.archive-toolbar {
    display: grid;
    grid-template-columns: 1fr 200px auto;
    gap: 12px;
    align-items: end;
}

.archive-toolbar .btn {
    min-height: 42px;
}

.archive-list {
    display: grid;
    gap: 10px;
}

.archive-card {
    display: flex;
    align-items: stretch;
    gap: 12px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    border-radius: 18px;
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    overflow: hidden;
}

.archive-card-main {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
}

.archive-card-main:hover {
    background: #f7fafd;
}

.archive-card-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.archive-card-top strong {
    font-size: 16px;
}

.archive-card-top .chip {
    color: var(--forest);
    border-color: var(--line);
    margin-left: auto;
}

.archive-card-top .chip-status {
    margin-left: 0;
}

.chip-status.is-sent {
    color: #0f6b3a;
    background: rgba(52, 199, 89, 0.16);
    border-color: rgba(52, 199, 89, 0.35);
}

.chip-status.is-downloaded {
    color: #0b4f9c;
    background: rgba(10, 132, 255, 0.12);
    border-color: rgba(10, 132, 255, 0.32);
}

.chip-status.is-downloaded_not_sent,
.chip-status.is-not-sent,
.chip-status.is-not_sent {
    color: #8a5a12;
    background: rgba(255, 196, 74, 0.22);
    border-color: rgba(214, 158, 46, 0.4);
}

.chip-status.is-not_downloaded {
    color: #5c6773;
    background: rgba(92, 103, 115, 0.12);
    border-color: rgba(92, 103, 115, 0.28);
}

.archive-card-main span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.archive-card-meta {
    font-size: 12px !important;
}

.archive-card-actions {
    display: flex;
    align-items: center;
    padding: 0 10px 0 0;
}

.archive-empty {
    padding: 28px 8px 8px;
    color: var(--muted);
    font-size: 14px;
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
        padding: 0 16px 32px;
    }

    .save-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .preview-wrap {
        position: relative;
        top: 0;
        max-height: none;
    }

    .type-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .pay-pick {
        grid-template-columns: 1fr;
    }

    .grid-3,
    .upload-pair {
        grid-template-columns: 1fr;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 18px 16px;
    }
}

@media (max-width: 820px) {
    body {
        background: #0d1b2a;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    body.auth-body {
        padding: 28px 16px calc(28px + env(safe-area-inset-bottom, 0px));
        background:
            radial-gradient(900px 420px at 50% -10%, rgba(4, 95, 193, 0.35), transparent 55%),
            #0d1b2a;
    }

    body.auth-body .auth-brand p {
        display: block;
    }

    .auth-card {
        padding: 28px 20px 24px;
    }

    .app-header {
        padding: 12px 16px calc(14px + env(safe-area-inset-top, 0px));
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        gap: 10px;
    }

    .logo-mark,
    .logo-mark img {
        width: 40px;
        height: 40px;
    }

    body.auth-body .auth-brand .logo-mark,
    body.auth-body .auth-brand .logo-mark img {
        width: 64px;
        height: 64px;
    }

    .brand-lockup h1 {
        font-size: 13px;
        letter-spacing: 0.2em;
    }

    .brand-lockup p {
        display: none;
    }

    .account-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .layout {
        padding: 0 12px 16px;
        gap: 12px;
    }

    .panel {
        border: 1px solid var(--glass-border);
        box-shadow: var(--shadow);
        border-radius: 18px;
        overflow: hidden;
        background: var(--glass);
    }

    .panel-form {
        padding: 16px 14px 20px;
    }

    .section {
        margin-bottom: 18px;
    }

    .type-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .type-card {
        min-height: 52px;
        padding: 10px 6px;
        font-size: 12px;
        font-weight: 650;
        border-radius: 12px;
        text-align: center;
    }

    .type-card small {
        display: none;
    }

    .signer-pick {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .signer-card {
        min-height: 88px;
        border-radius: 14px;
        padding: 12px 10px;
    }

    .grid-2,
    .totals-box {
        grid-template-columns: 1fr;
    }

    .duration-row {
        grid-template-columns: 1fr auto 1fr;
    }

    .duration-row select {
        grid-column: 1 / -1;
    }

    label {
        font-size: 11px;
    }

    input[type="text"],
    input[type="email"],
    input[type="date"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px;
        min-height: 44px;
        padding: 12px 12px;
        border-radius: 12px;
        border-color: var(--line);
    }

    textarea {
        min-height: 120px;
    }

    .clause-card input,
    .clause-card textarea {
        font-size: 16px;
        min-height: 44px;
        border-radius: 12px;
    }

    .clause-card textarea {
        min-height: 140px;
    }

    .btn,
    .btn.secondary {
        min-height: 44px;
        border-radius: 12px;
        width: 100%;
    }

    .btn.ghost {
        width: auto;
        min-height: 40px;
        min-width: 40px;
        font-size: 22px;
    }

    .save-banner {
        border-radius: 14px;
        width: 100%;
    }

    .save-banner .btn.ghost {
        font-size: 13px;
        width: 100%;
        text-transform: none;
        letter-spacing: 0;
        color: var(--forest);
        border: 1px solid var(--line);
    }

    .save-banner-actions {
        width: 100%;
    }

    .save-banner-actions .btn {
        width: 100%;
    }

    .account-layout,
    .archive-layout {
        padding: 0 12px 24px;
    }

    .archive-toolbar {
        grid-template-columns: 1fr;
    }

    .archive-card {
        flex-direction: column;
        border-radius: 14px;
    }

    .archive-card-actions {
        padding: 0 12px 12px;
    }

    .archive-card-actions .btn.ghost {
        width: 100%;
        font-size: 13px;
        text-transform: none;
        letter-spacing: 0;
        color: var(--err);
        border: 1px solid var(--line);
    }

    .items-table thead {
        display: none;
    }

    .items-table,
    .items-table tbody,
    .items-table tr,
    .items-table td {
        display: block;
        width: 100%;
    }

    .items-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 10px 10px 6px;
        margin-bottom: 10px;
        position: relative;
    }

    .items-table td {
        padding: 6px 0 8px;
        width: 100%;
    }

    .items-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 10px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--muted);
        margin-bottom: 4px;
    }

    .items-table td.col-remove {
        position: absolute;
        top: 4px;
        right: 4px;
        width: auto;
        padding: 0;
    }

    .col-price,
    .col-qty,
    .col-line {
        width: 100%;
    }

    .spacer-bar {
        min-height: 40px;
    }

    .preview-wrap {
        display: none;
        min-height: calc(100vh - 160px);
        max-height: none;
        border-radius: 18px;
        padding: 12px;
    }

    body.is-preview-tab .panel-form {
        display: none;
    }

    body.is-preview-tab .preview-wrap {
        display: flex;
    }

    .preview-frame-wrap,
    #pdf-preview {
        min-height: calc(100vh - 180px);
        height: calc(100vh - 180px);
        border-radius: 12px;
    }

    .app-dock {
        display: grid;
        grid-template-columns: 1fr 1.4fr;
        gap: 8px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        background: rgba(15, 28, 44, 0.55);
        backdrop-filter: saturate(1.8) blur(22px);
        -webkit-backdrop-filter: saturate(1.8) blur(22px);
        border-top: 1px solid rgba(255, 255, 255, 0.16);
    }

    .app-dock-preview,
    .app-dock-download {
        width: 100%;
        min-height: 46px;
        border-radius: 12px;
        letter-spacing: 0.04em;
        font-size: 12px;
    }

    .preview-modal-bar .btn,
    .preview-modal-bar .btn.secondary {
        width: auto;
        min-height: 40px;
    }
}

@media (max-width: 720px) {
    .grid-2,
    .totals-box {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .app-header,
    .panel,
    .auth-card,
    .chip,
    .type-card,
    .signer-card,
    .archive-card,
    .btn.secondary,
    .save-banner,
    .app-dock,
    .preview-modal-bar {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
