
:root {
    --blue-950: #061a4b;
    --blue-900: #08266d;
    --blue-800: #0b3ea8;
    --blue-700: #1455c8;
    --blue-600: #2563eb;
    --blue-100: #dbeafe;
    --blue-50: #eff6ff;
    --ink: #10213d;
    --muted: #64748b;
    --line: #dbe4f0;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --success: #0f9f6e;
    --warning: #d97706;
    --danger: #c92a2a;
    --shadow: 0 18px 45px rgba(10, 49, 118, .12);
    --radius: 18px;
    --radius-sm: 11px;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: #f2f6fb;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 80;
    min-height: 74px;
    padding: 9px clamp(18px, 4vw, 54px);
    display: flex;
    align-items: center;
    gap: 28px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid rgba(219,228,240,.9);
    backdrop-filter: blur(14px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 245px;
}
.brand-logo-wrap,
.editor-logo-wrap {
    width: 46px;
    height: 46px;
    border-radius: 0;
    overflow: visible;
    background: transparent;
    display: grid;
    place-items: center;
    box-shadow: none;
}
.brand-logo {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}
.brand strong { display: block; font-size: 1rem; }
.brand small { display: block; color: var(--muted); font-size: .75rem; }
.topnav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
}
.topnav a {
    white-space: nowrap;
    color: #42526c;
    font-weight: 700;
    font-size: .88rem;
    padding: 10px 12px;
    border-radius: 9px;
}
.topnav a:hover { color: var(--blue-800); background: var(--blue-50); }
.user-menu { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--line);
}
.user-name { font-weight: 700; font-size: .86rem; max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
    font-size: .9rem;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
    color: white;
    background: linear-gradient(135deg, var(--blue-800), var(--blue-600));
    box-shadow: 0 10px 24px rgba(37,99,235,.22);
}
.btn-primary:hover { box-shadow: 0 13px 30px rgba(37,99,235,.3); }
.btn-outline { color: var(--blue-800); background: white; border-color: #b7c8e6; }
.btn-outline:hover { background: var(--blue-50); }
.btn-ghost { color: #334155; background: #f6f8fb; border-color: #e6ebf2; }
.btn-danger { color: #a61e1e; background: #fff5f5; border-color: #ffc9c9; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: .8rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 13px 20px; font-size: .98rem; }

.page-shell {
    width: min(1480px, calc(100% - 36px));
    margin: 0 auto;
    padding: 38px 0 64px;
}
.narrow-shell { width: min(900px, calc(100% - 36px)); }
.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}
.page-heading h1 { margin: 5px 0 6px; font-size: clamp(1.7rem, 3vw, 2.45rem); letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--muted); max-width: 730px; }
.eyebrow {
    display: inline-block;
    color: var(--blue-700);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .12em;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    min-height: 142px;
    padding: 22px;
    border: 1px solid rgba(188,205,230,.75);
    border-radius: var(--radius);
    background:
        radial-gradient(circle at 100% 0, rgba(37,99,235,.13), transparent 42%),
        white;
    box-shadow: 0 8px 30px rgba(23,64,126,.06);
}
.stat-card span { color: var(--muted); font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong { display: block; margin: 8px 0 2px; color: var(--blue-900); font-size: 2rem; line-height: 1.1; }
.stat-card small { color: var(--muted); }
.stat-card .stat-date { font-size: 1.45rem; }

.panel {
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-header {
    min-height: 92px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: 1.15rem; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: .87rem; }
.search-form { display: flex; gap: 8px; }
.search-form input,
.field input,
.field select,
.field textarea,
.filter-bar input,
.filter-bar select {
    min-height: 43px;
    width: 100%;
    padding: 9px 12px;
    color: var(--ink);
    background: white;
    border: 1px solid #c9d5e5;
    border-radius: 9px;
    outline: none;
}
.search-form input { width: min(280px, 50vw); }
.search-form input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
.data-table th,
.data-table td {
    padding: 15px 18px;
    text-align: left;
    border-bottom: 1px solid #edf1f6;
    vertical-align: middle;
}
.data-table th {
    color: #53647c;
    background: #f8fafc;
    font-size: .73rem;
    text-transform: uppercase;
    letter-spacing: .065em;
    white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdff; }
.text-right { text-align: right !important; }
.doc-cell { display: flex; align-items: center; gap: 11px; min-width: 250px; }
.doc-cell strong { display: block; max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-cell small { display: block; color: var(--muted); max-width: 330px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-badge {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, #e03131, #b52020);
    font-size: .72rem;
    font-weight: 900;
    box-shadow: 0 7px 15px rgba(176,32,32,.18);
}
.action-row { display: flex; flex-wrap: wrap; gap: 6px; }
.action-row-right { justify-content: flex-end; }
.action-row form { display: inline-flex; }
.muted-block { display: block; color: var(--muted); }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #edf2ff;
    color: #364fc7;
    font-weight: 800;
    font-size: .72rem;
}
.badge-success { color: #087f5b; background: #e6fcf5; }
.badge-warning { color: #a55c00; background: #fff4e6; }
.badge-danger { color: #b02525; background: #fff0f0; }

.pagination {
    padding: 18px 22px;
    display: flex;
    justify-content: center;
    gap: 7px;
    border-top: 1px solid var(--line);
}
.pagination a {
    min-width: 36px;
    height: 36px;
    padding: 0 9px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    font-weight: 800;
    color: #4b5f7d;
}
.pagination a.active { color: white; background: var(--blue-800); border-color: var(--blue-800); }

.empty-state {
    min-height: 390px;
    padding: 70px 24px;
    text-align: center;
}
.empty-icon {
    width: 78px;
    height: 78px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    color: white;
    background: linear-gradient(145deg, var(--blue-800), #5985e8);
    border-radius: 24px;
    font-weight: 900;
    box-shadow: 0 14px 32px rgba(37,99,235,.23);
}
.empty-state h3 { margin: 0 0 5px; }
.empty-state p { color: var(--muted); margin: 0 0 22px; }

.field { display: grid; gap: 7px; margin-bottom: 18px; }
.field > span { font-weight: 800; font-size: .85rem; color: #394b66; }
.upload-panel { padding: 28px; }
.dropzone {
    position: relative;
    min-height: 320px;
    padding: 38px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    border: 2px dashed #97b3df;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(239,246,255,.7), rgba(255,255,255,.9));
    transition: .2s ease;
}
.dropzone.dragover { border-color: var(--blue-600); background: #eaf3ff; transform: scale(1.005); }
.dropzone input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone-icon {
    width: 78px;
    height: 78px;
    margin-bottom: 18px;
    display: grid;
    place-items: center;
    border-radius: 23px;
    color: white;
    background: linear-gradient(145deg, #e03131, #a91818);
    font-size: 1.1rem;
    font-weight: 900;
    box-shadow: 0 15px 35px rgba(175,24,24,.2);
}
.dropzone strong { font-size: 1.15rem; }
.dropzone small { color: var(--muted); margin-top: 5px; }
.selected-file {
    margin-top: 16px;
    max-width: 100%;
    padding: 7px 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--blue-800);
    background: var(--blue-50);
    border-radius: 999px;
    font-weight: 800;
    font-size: .82rem;
}
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.upload-progress { margin-top: 18px; }
.progress-track { height: 10px; overflow: hidden; background: #e8eef7; border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blue-800), #4f8cff); transition: width .2s ease; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: .78rem; }

.flash-stack {
    position: fixed;
    right: 20px;
    top: 90px;
    z-index: 200;
    width: min(420px, calc(100vw - 40px));
    display: grid;
    gap: 9px;
}
.alert {
    padding: 13px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid;
    border-radius: 11px;
    background: white;
    box-shadow: 0 15px 35px rgba(15,23,42,.12);
    font-weight: 700;
    font-size: .88rem;
}
.alert-success { color: #087f5b; border-color: #96f2d7; background: #edfff9; }
.alert-danger { color: #a61e1e; border-color: #ffc9c9; background: #fff5f5; }
.alert-warning { color: #9a5b00; border-color: #ffd8a8; background: #fff9db; }
.alert-close { padding: 0; border: 0; background: transparent; color: inherit; font-size: 1.3rem; line-height: 1; }

.modal,
.signature-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: grid;
    place-items: center;
    padding: 20px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(5,18,48,.68); backdrop-filter: blur(5px); }
.modal-card {
    position: relative;
    width: min(520px, 100%);
    padding: 28px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 30px 80px rgba(0,0,0,.28);
}
.modal-card h2 { margin: 0 0 20px; }
.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    background: #f1f5f9;
    font-size: 1.35rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

.footer {
    min-height: 75px;
    padding: 18px clamp(20px,4vw,55px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    color: #6d7e96;
    font-size: .8rem;
}

/* Landing */
.landing-page {
    background:
        radial-gradient(circle at 85% 10%, rgba(91,132,255,.35), transparent 27%),
        radial-gradient(circle at 8% 88%, rgba(49,101,232,.22), transparent 28%),
        linear-gradient(135deg, #031337, #0a317d 58%, #0b3ea8);
}
.landing-page .footer { color: rgba(255,255,255,.68); }
.landing-shell {
    min-height: calc(100vh - 75px);
    padding: clamp(22px, 5vw, 70px);
    display: grid;
    place-items: center;
}
.landing-card {
    width: min(1040px, 100%);
    padding: clamp(26px, 5vw, 56px);
    border: 1px solid rgba(255,255,255,.42);
    border-radius: 28px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 35px 100px rgba(0,0,0,.32);
}
.landing-brand {
    display: grid;
    grid-template-columns: 190px 1fr;
    align-items: center;
    gap: clamp(24px, 5vw, 56px);
}
.landing-logo-wrap {
    width: 190px;
    height: 190px;
    border-radius: 30px;
    overflow: hidden;
    background: #050505;
    display: grid;
    place-items: center;
    box-shadow: 0 20px 45px rgba(8,38,109,.22);
}
.landing-logo { width: 100%; height: 100%; object-fit: contain; }
.landing-brand h1 { margin: 6px 0 7px; font-size: clamp(2.25rem, 6vw, 4.3rem); line-height: 1; letter-spacing: -.06em; color: var(--blue-950); }
.landing-brand p { margin: 0; color: var(--muted); font-size: 1.05rem; max-width: 620px; }
.feature-grid {
    margin: 42px 0 28px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}
.feature-grid article {
    padding: 20px;
    border: 1px solid #d8e3f2;
    border-radius: 15px;
    background: #f9fbfe;
}
.feature-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: var(--blue-100);
    color: var(--blue-800);
    font-size: 1.25rem;
    font-weight: 900;
}
.feature-grid h2 { margin: 13px 0 4px; font-size: 1rem; }
.feature-grid p { margin: 0; color: var(--muted); font-size: .84rem; }
.login-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.google-mark {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    color: #4285f4;
    background: white;
    border-radius: 50%;
    font-family: Arial, sans-serif;
    font-weight: 900;
}
.privacy-note { margin: 18px 0 0; color: #7b8ba1; font-size: .76rem; text-align: center; }

/* Admin */
.filter-bar {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    background: #fbfcfe;
}
.analytics-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 18px;
    margin-top: 18px;
}
.chart-card {
    padding: 22px;
    background: white;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 9px 30px rgba(30,64,120,.07);
}
.chart-card h2 { margin: 0 0 4px; font-size: 1rem; }
.chart-card p { margin: 0 0 18px; color: var(--muted); font-size: .83rem; }
.chart-holder { position: relative; min-height: 310px; }
.detail-list { margin: 0; display: grid; gap: 0; }
.detail-list > div {
    padding: 12px 0;
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 15px;
    border-bottom: 1px solid #edf1f6;
}
.detail-list dt { color: var(--muted); font-size: .8rem; font-weight: 800; }
.detail-list dd { margin: 0; font-weight: 700; word-break: break-word; }
.online-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #12b886; box-shadow: 0 0 0 4px rgba(18,184,134,.13); }

/* Editor */
.editor-page { overflow: hidden; background: #dfe6f1; }
.editor-page .flash-stack { top: 75px; }
.editor-app {
    height: 100vh;
    display: grid;
    grid-template-columns: 78px 190px 1fr;
    grid-template-rows: 70px 1fr;
    overflow: hidden;
}
.editor-topbar {
    grid-column: 1 / -1;
    z-index: 30;
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: white;
    border-bottom: 1px solid #cfd9e6;
    box-shadow: 0 3px 15px rgba(15,23,42,.08);
}
.editor-brand,
.editor-top-actions { display: flex; align-items: center; gap: 9px; }
.editor-brand > div:last-child { min-width: 0; }
.editor-brand strong { display: block; max-width: min(42vw, 520px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor-brand small { display: block; color: #6b7d95; font-size: .72rem; }
.editor-logo-wrap { width: clamp(38px, 4vw, 52px); height: clamp(38px, 4vw, 52px); }
.editor-logo-wrap img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid #cbd7e6;
    border-radius: 9px;
    background: white;
    font-weight: 900;
}
.editor-toolbar {
    grid-column: 1;
    grid-row: 2;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    background: #0a245f;
    border-right: 1px solid #061a48;
}
.tool-btn {
    min-height: 59px;
    padding: 6px 3px;
    color: rgba(255,255,255,.78);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
}
.tool-btn span { display: block; font-size: 1.3rem; line-height: 1.2; font-weight: 800; }
.tool-btn small { display: block; margin-top: 4px; font-size: .62rem; }
.tool-btn:hover,
.tool-btn.active { color: white; background: rgba(255,255,255,.13); border-color: rgba(255,255,255,.18); }
.tool-btn.tool-danger { margin-top: auto; color: #ffc9c9; }
.page-sidebar {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    overflow: hidden;
    background: #f6f8fb;
    border-right: 1px solid #cbd7e5;
}
.page-sidebar-header {
    height: 47px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #3a4f6d;
    border-bottom: 1px solid #d6dfeb;
    font-size: .8rem;
}
.page-sidebar-header span {
    min-width: 26px;
    height: 24px;
    padding: 0 6px;
    display: grid;
    place-items: center;
    color: white;
    background: var(--blue-800);
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
}
.thumbnail-list { height: calc(100% - 47px); padding: 12px; overflow-y: auto; }
.thumbnail-item {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 2px solid transparent;
    border-radius: 10px;
    background: white;
    box-shadow: 0 4px 12px rgba(15,23,42,.08);
}
.thumbnail-item.active { border-color: var(--blue-600); background: var(--blue-50); }
.thumbnail-item canvas { width: 100%; height: auto; display: block; background: white; }
.thumbnail-item span { display: block; margin-top: 6px; color: #52657f; text-align: center; font-size: .69rem; font-weight: 800; }
.editor-workspace {
    grid-column: 3;
    grid-row: 2;
    min-width: 0;
    min-height: 0;
    display: grid;
    grid-template-rows: 51px 1fr;
}
.editor-options {
    z-index: 20;
    padding: 7px 14px;
    display: flex;
    align-items: center;
    gap: 18px;
    overflow-x: auto;
    background: #f9fbfd;
    border-bottom: 1px solid #cbd7e5;
}
.editor-options label { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: #4f6179; font-size: .72rem; font-weight: 800; }
.editor-options input[type="color"] { width: 35px; height: 31px; padding: 2px; border: 1px solid #bcc9db; border-radius: 7px; background: white; }
.editor-options input[type="range"] { width: 92px; }
.editor-options output { min-width: 34px; color: var(--blue-800); }
.editor-options select { min-height: 32px; border: 1px solid #bdcadd; border-radius: 7px; background: white; }
.workspace-scroll {
    position: relative;
    overflow: auto;
    background:
        linear-gradient(45deg, rgba(255,255,255,.23) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,.23) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,.23) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.23) 75%),
        #d9e0ea;
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.page-stage {
    min-width: max-content;
    min-height: 100%;
    padding: 35px 50px 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
}
.pdf-page-wrap {
    position: relative;
    flex: 0 0 auto;
    background: white;
    box-shadow: 0 10px 35px rgba(15,23,42,.28);
    transition: transform .2s ease;
    transform-origin: top center;
}
.pdf-page-wrap.current { box-shadow: 0 0 0 3px var(--blue-600), 0 13px 38px rgba(15,23,42,.3); }
.pdf-render-canvas { position: absolute; inset: 0; display: block; }
.annotation-canvas { position: absolute !important; inset: 0; }
.pdf-page-wrap > .canvas-container { position: absolute !important; inset: 0; }
.pdf-page-label {
    position: absolute;
    left: 50%;
    bottom: -25px;
    transform: translateX(-50%);
    padding: 3px 9px;
    color: #50627a;
    background: rgba(255,255,255,.88);
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
    box-shadow: 0 3px 10px rgba(15,23,42,.09);
}
.editor-loading {
    min-width: 300px;
    min-height: 250px;
    padding: 35px;
    display: grid;
    place-items: center;
    align-content: center;
    text-align: center;
    color: #3c506d;
    background: rgba(255,255,255,.9);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.editor-loading small { margin-top: 5px; color: var(--muted); }
.spinner {
    width: 48px;
    height: 48px;
    margin-bottom: 18px;
    border: 5px solid #dbe7f8;
    border-top-color: var(--blue-700);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.signature-card { width: min(720px, 100%); }
.signature-card p { color: var(--muted); }
#signatureCanvas {
    width: 100%;
    height: auto;
    touch-action: none;
    border: 1px dashed #9eb2d0;
    border-radius: 10px;
    background: white;
}
.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 800;
    max-width: min(420px, calc(100vw - 44px));
    padding: 13px 16px;
    color: white;
    background: #142a51;
    border-radius: 11px;
    box-shadow: 0 16px 40px rgba(0,0,0,.27);
    font-weight: 750;
    font-size: .86rem;
}
.toast.error { background: #a61e1e; }
.toast.success { background: #087f5b; }

@media (max-width: 1080px) {
    .topbar { gap: 15px; }
    .topnav { order: 3; width: 100%; flex-basis: 100%; }
    .topbar { flex-wrap: wrap; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .editor-app { grid-template-columns: 68px 150px 1fr; }
    .editor-top-actions .btn-outline:nth-child(-n+2) { display: none; }
    .analytics-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .topbar { padding: 9px 14px; }
    .brand { min-width: 0; flex: 1; }
    .brand small, .user-name { display: none; }
    .user-menu { margin-left: auto; }
    .page-shell, .narrow-shell { width: min(100% - 22px, 1480px); padding-top: 24px; }
    .page-heading { flex-direction: column; }
    .page-heading .btn { width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { min-height: 122px; padding: 16px; }
    .stat-card strong { font-size: 1.55rem; }
    .panel-header { align-items: stretch; flex-direction: column; }
    .search-form input { width: 100%; }
    .feature-grid { grid-template-columns: 1fr; }
    .landing-brand { grid-template-columns: 1fr; text-align: center; }
    .landing-logo-wrap { width: 150px; height: 150px; margin: auto; }
    .login-actions { grid-template-columns: 1fr; }
    .footer { flex-direction: column; justify-content: center; text-align: center; }
    .filter-bar { grid-template-columns: 1fr; }
    .editor-app {
        grid-template-columns: 59px 1fr;
        grid-template-rows: 62px 1fr;
    }
    .editor-toolbar { grid-column: 1; }
    .page-sidebar { display: none; }
    .editor-workspace { grid-column: 2; }
    .editor-topbar { padding: 7px 10px; }
    .editor-logo-wrap { display: none; }
    .editor-brand strong { max-width: 34vw; font-size: .78rem; }
    .editor-top-actions .btn-outline { display: none; }
    .editor-top-actions .btn-primary { min-height: 38px; padding: 7px 11px; font-size: .78rem; }
    .editor-options { gap: 10px; padding-left: 9px; }
    .editor-options label span { display: none; }
    .page-stage { padding: 24px 16px 80px; }
}
@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .upload-panel { padding: 16px; }
    .dropzone { min-height: 260px; }
}


.pdf-text-edit-layer {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}
.pdf-text-edit-layer.active { pointer-events: auto; }
.pdf-editable-text {
    position: absolute;
    display: block;
    padding: 0;
    margin: 0;
    border: 1px solid transparent;
    background: transparent;
    color: transparent;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    cursor: text;
    opacity: 0;
}
.pdf-text-edit-layer.active .pdf-editable-text {
    opacity: 1;
    border-color: rgba(37, 99, 235, .25);
    background: rgba(59, 130, 246, .08);
}
.pdf-text-edit-layer.active .pdf-editable-text:hover,
.pdf-editable-text:focus-visible {
    border-color: #2563eb;
    background: rgba(59, 130, 246, .20);
    outline: 2px solid rgba(37, 99, 235, .20);
}
.pdf-editable-text.is-edited { display: none; }
.text-edit-hint {
    flex: 1 1 100%;
    padding: 7px 10px;
    border: 1px solid #93c5fd;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: .78rem;
    font-weight: 700;
}
