/* LoveDPGE — institutional, modern, professional theme. */
:root {
    --lp-primary: #1f4e8c;
    --lp-primary-dark: #163a68;
    --lp-accent: #2f9e8f;
    --lp-bg: #f4f6fa;
    --lp-surface: #ffffff;
    --lp-border: #e2e8f0;
    --lp-text: #1f2937;
    --lp-muted: #6b7280;
    --lp-success: #1f9d55;
    --lp-danger: #d64545;
    --lp-warning: #c9820b;
    --lp-radius: 14px;
    --lp-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: var(--lp-bg);
    color: var(--lp-text);
}

/* ---------- App shell / top bar ---------- */
:root {
    --lp-green: #1f5c3d;
    --lp-green-dark: #123a26;
}

.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.app-topbar {
    /* Green gradient bar, matching the welcome screen. */
    background: linear-gradient(90deg, #005e3c 0%, #013622 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 49, 29, .25);
    position: sticky;
    top: 0;
    z-index: 30;
}
.app-topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 28px;
    height: 66px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}
.topbar-logo {
    height: 65px;
    width: auto;
    object-fit: contain;
    /* the "I love" logo has dark strokes; keep it crisp on the green bar */
}

.topbar-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar-item {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: rgba(255, 255, 255, .88);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.topbar-item:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.topbar-item.active { background: rgba(255, 255, 255, .22); color: #fff; }

.app-main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 34px 40px;
}

@media (max-width: 640px) {
    .app-topbar-inner { padding: 0 16px; gap: 12px; height: 56px; }
    .topbar-logo { height: 40px; }
    .topbar-item span { display: none; }
    .topbar-item { padding: 10px 12px; }
    .app-main { padding: 16px 14px; }
}

/* ---------- Headings ---------- */
.page-title { font-size: 1.8rem; font-weight: 700; margin: 0 0 4px; }
.page-subtitle { color: var(--lp-muted); margin: 0 0 24px; }
.section-title { font-size: 1.1rem; font-weight: 600; margin: 28px 0 14px; }

/* ---------- Search ---------- */
.hub-search {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    padding: 14px 18px;
    box-shadow: var(--lp-shadow);
    margin-bottom: 8px;
}
.hub-search i { color: var(--lp-muted); }
.hub-search input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 1rem;
    background: transparent;
}

/* ---------- Tool cards ---------- */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}
.tool-card {
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    padding: 18px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--lp-shadow);
    transition: transform .12s, box-shadow .12s;
    position: relative;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.12); }
.tool-card.disabled { opacity: .6; pointer-events: none; }
.tool-card .icon {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: rgba(31, 78, 140, .1);
    color: var(--lp-primary);
    font-size: 1.1rem;
}
.tool-card .name { font-weight: 600; }
.tool-card .soon {
    position: absolute; top: 12px; right: 12px;
    font-size: .68rem; text-transform: uppercase;
    background: var(--lp-warning); color: #fff;
    padding: 2px 7px; border-radius: 20px;
}

.category-block { margin-bottom: 26px; }
.category-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.category-head i { color: var(--lp-accent); }
.category-head h3 { margin: 0; font-size: 1.05rem; }

/* ---------- Tables ---------- */
.data-card {
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    overflow: hidden;
    box-shadow: var(--lp-shadow);
}
table.lp-table { width: 100%; border-collapse: collapse; }
.lp-table th, .lp-table td {
    text-align: left; padding: 13px 16px;
    border-bottom: 1px solid var(--lp-border);
    font-size: .92rem;
}
.lp-table th { background: #f8fafc; color: var(--lp-muted); font-weight: 600; }
.lp-table tr:last-child td { border-bottom: none; }

/* ---------- Status pills ---------- */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px; border-radius: 20px;
    font-size: .78rem; font-weight: 600;
}
.pill.PENDING    { background: #eef2ff; color: #4356b3; }
.pill.PROCESSING { background: #fff4e0; color: var(--lp-warning); }
.pill.COMPLETED  { background: #e6f6ee; color: var(--lp-success); }
.pill.FAILED     { background: #fdecec; color: var(--lp-danger); }
.pill.CANCELLED  { background: #eceff3; color: var(--lp-muted); }

/* ---------- Upload dropzone ---------- */
.dropzone {
    border: 2px dashed var(--lp-primary);
    border-radius: var(--lp-radius);
    background: #fbfdff;
    padding: 44px 24px;
    text-align: center;
    color: var(--lp-primary);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.dropzone.dragover { background: rgba(31,78,140,.08); border-color: var(--lp-accent); }
.dropzone i { font-size: 2.2rem; margin-bottom: 10px; }
.dropzone .hint { color: var(--lp-muted); font-size: .9rem; margin-top: 6px; }

/* ---------- File list ---------- */
.file-list { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.file-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: 10px;
    padding: 12px 14px;
}
.file-item .grip { cursor: grab; color: var(--lp-muted); }
.file-item .meta { flex: 1; }
.file-item .meta .fname { font-weight: 600; }
.file-item .meta .fsub { font-size: .8rem; color: var(--lp-muted); }
.file-item .remove { background: none; border: none; color: var(--lp-danger); cursor: pointer; font-size: 1rem; }
.file-item.dragging { opacity: .5; }
.file-item .state-error { color: var(--lp-danger); font-size: .8rem; }

/* ---------- Buttons ---------- */
.btn-primary-lp {
    background: var(--lp-primary); color: #fff; border: none;
    padding: 12px 22px; border-radius: 10px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary-lp:hover:not(:disabled) { background: var(--lp-primary-dark); }
.btn-primary-lp:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Progress ---------- */
.progress-wrap { margin-top: 24px; }
.progress-bar-lp { height: 14px; background: var(--lp-border); border-radius: 20px; overflow: hidden; }
.progress-bar-lp > span { display: block; height: 100%; width: 0; background: var(--lp-accent); transition: width .4s; }
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; color: var(--lp-muted); font-size: .9rem; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--lp-muted); }
.empty-state i { font-size: 2.4rem; margin-bottom: 12px; color: var(--lp-border); }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 1080; }
.lp-toast {
    background: var(--lp-surface); border: 1px solid var(--lp-border);
    border-left: 4px solid var(--lp-primary);
    border-radius: 10px; padding: 12px 16px; box-shadow: 0 6px 18px rgba(16,24,40,.14);
    min-width: 260px;
}
.lp-toast.error { border-left-color: var(--lp-danger); }
.lp-toast.success { border-left-color: var(--lp-success); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--lp-primary), var(--lp-primary-dark)); padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand-lg { text-align: center; font-size: 1.8rem; font-weight: 700; color: var(--lp-primary); margin-bottom: 4px; }
.login-card .brand-lg i { color: var(--lp-accent); }
.login-card .subtitle { text-align: center; color: var(--lp-muted); margin-bottom: 26px; }
.login-card .form-control { margin-bottom: 14px; }

/* ---------- Responsive ---------- */
/* ---------- Single-tool options ---------- */
.tool-options {
    margin-top: 18px;
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    padding: 18px 20px;
    box-shadow: var(--lp-shadow);
}
.tool-options label { display: block; font-weight: 600; margin-bottom: 6px; }
.tool-options .help { color: var(--lp-muted); font-size: .85rem; margin-top: 6px; }
.tool-options input[type="text"],
.tool-options input[type="number"],
.tool-options select {
    width: 100%;
    max-width: 360px;
    padding: 10px 12px;
    border: 1px solid var(--lp-border);
    border-radius: 8px;
    font-size: .95rem;
}
.rotate-choices { display: flex; gap: 10px; flex-wrap: wrap; }
.rotate-choices label {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--lp-border); border-radius: 8px;
    padding: 10px 14px; cursor: pointer; font-weight: 500; margin: 0;
}
.rotate-choices input { margin: 0; }

/* ==========================================================================
   Hub landing page (institutional entry screen)
   ========================================================================== */
.hub-page { background: var(--lp-bg); }

/* Topbar */
.hub-topbar {
    background: var(--lp-primary);
    color: #fff;
    box-shadow: var(--lp-shadow);
    position: sticky;
    top: 0;
    z-index: 20;
}
.hub-topbar-inner {
    max-width: 1160px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.hub-brand {
    display: flex; align-items: center; gap: 10px;
    color: #fff; text-decoration: none;
    font-size: 1.3rem; font-weight: 700;
}
.hub-brand i { color: var(--lp-accent); }
.hub-topnav { display: flex; align-items: center; gap: 8px; }
.hub-topnav a {
    color: rgba(255, 255, 255, .9);
    text-decoration: none;
    padding: 9px 14px;
    border-radius: 8px;
    font-weight: 500;
}
.hub-topnav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.hub-topnav-cta {
    background: var(--lp-accent);
    color: #fff !important;
    font-weight: 600;
}
.hub-topnav-cta:hover { background: #278478 !important; }

/* Hero */
.hub-hero {
    background: linear-gradient(135deg, var(--lp-primary), var(--lp-primary-dark));
    color: #fff;
    padding: 64px 24px 72px;
}
.hub-hero-inner { max-width: 820px; margin: 0 auto; text-align: center; }
.hub-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255, 255, 255, .12);
    padding: 6px 14px; border-radius: 20px;
    font-size: .85rem; font-weight: 500; margin-bottom: 18px;
}
.hub-hero h1 { font-size: 2.4rem; font-weight: 700; margin: 0 0 12px; }
.hub-lead { font-size: 1.1rem; opacity: .92; margin: 0 auto 30px; max-width: 620px; }

.hub-hero-search {
    display: flex; align-items: center; gap: 10px;
    background: #fff;
    border-radius: 14px;
    padding: 8px 8px 8px 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
    max-width: 640px; margin: 0 auto;
}
.hub-hero-search i { color: var(--lp-muted); }
.hub-hero-search input {
    flex: 1; border: none; outline: none;
    font-size: 1rem; padding: 10px 4px; color: var(--lp-text);
    background: transparent;
}
.hub-hero-search button {
    background: var(--lp-primary); color: #fff; border: none;
    padding: 12px 22px; border-radius: 10px; font-weight: 600; cursor: pointer;
}
.hub-hero-search button:hover { background: var(--lp-primary-dark); }

.hub-quick {
    margin-top: 22px;
    display: flex; align-items: center; justify-content: center;
    gap: 10px; flex-wrap: wrap;
}
.hub-quick-label { font-size: .9rem; opacity: .85; }
.hub-chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: rgba(255, 255, 255, .14);
    color: #fff; text-decoration: none;
    padding: 8px 14px; border-radius: 20px;
    font-size: .9rem; font-weight: 500;
    transition: background .15s;
}
.hub-chip:hover { background: rgba(255, 255, 255, .26); color: #fff; }

/* Main / modules */
.hub-main { max-width: 1160px; margin: 0 auto; padding: 48px 24px 20px; }
.hub-section { margin-bottom: 44px; }
.hub-section h2 { font-size: 1.5rem; font-weight: 700; margin: 0 0 6px; }
.hub-section-sub { color: var(--lp-muted); margin: 0 0 22px; }

.hub-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.hub-module-card {
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    padding: 22px;
    box-shadow: var(--lp-shadow);
    display: flex; flex-direction: column;
    transition: transform .12s, box-shadow .12s;
}
.hub-module-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(16, 24, 40, .12); }
.hub-module-icon {
    width: 52px; height: 52px;
    display: grid; place-items: center;
    border-radius: 12px;
    background: rgba(31, 78, 140, .1);
    color: var(--lp-primary);
    font-size: 1.4rem; margin-bottom: 14px;
}
.hub-module-card h3 { font-size: 1.15rem; font-weight: 700; margin: 0 0 12px; }
.hub-module-tools { list-style: none; margin: 0 0 16px; padding: 0; flex: 1; }
.hub-module-tools li { margin-bottom: 8px; }
.hub-module-tools a {
    color: var(--lp-text); text-decoration: none; font-size: .95rem;
    display: inline-flex; align-items: center; gap: 8px;
}
.hub-module-tools a:hover { color: var(--lp-primary); }
.hub-module-tools a i { color: var(--lp-accent); font-size: .8rem; }
.soon-inline {
    color: var(--lp-muted); font-size: .95rem;
    display: inline-flex; align-items: center; gap: 8px;
}
.soon-inline i { font-size: .8rem; }
.soon-inline em {
    font-style: normal; font-size: .68rem; text-transform: uppercase;
    background: #eef1f5; color: var(--lp-muted);
    padding: 1px 7px; border-radius: 20px;
}
.hub-module-link {
    color: var(--lp-primary); text-decoration: none; font-weight: 600;
    font-size: .92rem; display: inline-flex; align-items: center; gap: 6px;
}
.hub-module-link:hover { gap: 9px; }

/* Footer */
.hub-footer { border-top: 1px solid var(--lp-border); background: var(--lp-surface); margin-top: 20px; }
.hub-footer-inner {
    max-width: 1160px; margin: 0 auto; padding: 20px 24px;
    display: flex; justify-content: space-between; align-items: center;
    color: var(--lp-text); font-size: .9rem;
}
.hub-footer-muted { color: var(--lp-muted); }

@media (max-width: 640px) {
    .hub-hero h1 { font-size: 1.8rem; }
    .hub-hero-search { flex-direction: column; padding: 12px; }
    .hub-hero-search button { width: 100%; }
    .hub-footer-inner { flex-direction: column; gap: 6px; }
}

/* ==========================================================================
   Welcome / home split screen (Stirling-PDF-Defensoria style)
   ========================================================================== */
:root {
    --lp-green: #1f5c3d;
    --lp-green-dark: #123a26;
}

.welcome-page { margin: 0; height: 100vh; overflow: hidden; }

.welcome-split {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Left panel: dark green with a subtle network texture */
.welcome-left {
    position: relative;
    width: 50%;
    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,.06) 0, transparent 40%),
        radial-gradient(circle at 70% 70%, rgba(255,255,255,.05) 0, transparent 35%),
        linear-gradient(135deg, var(--lp-green), var(--lp-green-dark));
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Diagonal cut on the right edge, so the green slants into the light side. */
    clip-path: polygon(0 0, 100% 0, calc(100% - 90px) 100%, 0 100%);
    padding: 40px 90px 40px 40px;
}
/* faint dotted-network overlay */
.welcome-left::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(rgba(255,255,255,.10) 1px, transparent 1.4px);
    background-size: 34px 34px;
    opacity: .5;
    pointer-events: none;
}
.welcome-left-content { position: relative; text-align: center; }

.welcome-love {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 26px;
}
.welcome-love-i { font-size: 2.6rem; font-weight: 800; }
.welcome-love-heart { color: #e23b3b; font-size: 2.1rem; }
.welcome-love-brand {
    font-size: 2rem; font-weight: 800; letter-spacing: 1px;
    color: #d8b24a;
}
.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    max-width: 360px;
}
.welcome-copyright {
    position: absolute;
    bottom: 26px;
    left: 0; right: 90px;
    text-align: center;
    font-size: .78rem;
    opacity: .75;
    margin: 0;
}

/* Right panel: light, with logo + tools grid */
.welcome-right {
    width: 50%;
    background: #fdfdfd;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.welcome-right-content {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.welcome-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 34px;
}
.welcome-logo > i {
    font-size: 2.6rem;
    color: var(--lp-green);
}
.welcome-logo-text { line-height: 1.15; color: #1f2937; }
.welcome-logo-text strong { display: block; font-size: 1.05rem; letter-spacing: .5px; }
.welcome-logo-text span { font-size: .8rem; color: var(--lp-muted); letter-spacing: 2px; }

/* Tools grid inside a soft card */
.welcome-tools {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    background: #fff;
    border: 1px solid var(--lp-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(16, 24, 40, .08);
}
.welcome-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    border: 1px solid var(--lp-border);
    border-radius: 12px;
    text-decoration: none;
    color: #374151;
    background: #fff;
    transition: transform .12s, box-shadow .12s, border-color .12s;
    min-width: 92px;
}
.welcome-tool:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 24, 40, .12);
    border-color: var(--lp-green);
}
.welcome-tool.disabled { opacity: .5; pointer-events: none; }
.welcome-tool-icon {
    width: 42px; height: 42px;
    display: grid; place-items: center;
    border-radius: 10px;
    font-size: 1.15rem;
    background: #eef2f7;
    color: var(--lp-green);
}
.welcome-tool-label {
    font-size: .78rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

/* Rotating accent colors for the icons, like the reference screen */
.welcome-tool-icon.c0 { background: #fdeaea; color: #d64545; }
.welcome-tool-icon.c1 { background: #e9f2ed; color: #1f5c3d; }
.welcome-tool-icon.c2 { background: #fdeeea; color: #c9820b; }
.welcome-tool-icon.c3 { background: #e8f0fb; color: #1f4e8c; }
.welcome-tool-icon.c4 { background: #f0eafd; color: #6b46c1; }
.welcome-tool-icon.c5 { background: #e9f6f2; color: #2f9e8f; }
.welcome-tool-icon.c6 { background: #eaf6ec; color: #1f9d55; }
.welcome-tool-icon.c7 { background: #fdf3e6; color: #b8791b; }
.welcome-tool-icon.c8 { background: #eef1f5; color: #475569; }

.welcome-all {
    margin-top: 22px;
    color: var(--lp-green);
    font-weight: 600;
    text-decoration: none;
    font-size: .92rem;
    display: inline-flex; align-items: center; gap: 6px;
}
.welcome-all:hover { gap: 9px; }

/* Responsive: stack the two panels on small screens */
@media (max-width: 860px) {
    .welcome-page { height: auto; overflow: auto; }
    .welcome-split { flex-direction: column; height: auto; }
    .welcome-left, .welcome-right { width: 100%; clip-path: none; padding: 48px 24px; }
    .welcome-copyright { position: static; right: 0; margin-top: 28px; }
    .welcome-title { max-width: none; }
}

/* ==========================================================================
   PDF para Markdown — workspace em duas colunas
   ========================================================================== */
body:has(.md-page) .app-main {
    max-width: 1440px;
    padding-top: 22px;
    padding-bottom: 22px;
}
.md-page {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: calc(100vh - 110px);
}
.md-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    border: 1px solid var(--lp-border);
    border-radius: 18px;
    padding: 24px 28px 24px;
    box-shadow: 0 10px 30px rgba(0, 49, 29, .10);
}
.md-card-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.md-card-copy { flex: 1; min-width: 220px; }
.md-card-icon {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #fdeaea;
    color: #e74c3c;
    font-size: 1.35rem;
}
.md-page.is-merge .md-card-icon {
    background: #fdf3e6;
    color: #f39c12;
}
.md-page.is-split .md-card-icon {
    background: #fdeee6;
    color: #e67e22;
}
.md-page.is-remove .md-card-icon {
    background: #e8f0fb;
    color: #3498db;
}
.md-page.is-extract .md-card-icon {
    background: #f0eafd;
    color: #9b59b6;
}
.md-page.is-compress .md-card-icon {
    background: #eaf6ec;
    color: #2ecc71;
}
.md-page.is-rotate .md-card-icon {
    background: #e9f6f2;
    color: #1abc9c;
}
.md-page.is-reorder .md-card-icon {
    background: #fdf8e6;
    color: #f1c40f;
}
.md-card-title {
    font-size: 1.55rem;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1f2937;
}
.md-card-sub {
    margin: 0;
    color: var(--lp-muted);
    font-size: .95rem;
    line-height: 1.45;
    max-width: 640px;
}
.md-steps {
    list-style: none;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 0 auto;
    padding: 0;
}
.md-steps li {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f4fbf7;
    color: #013622;
    border: 1px solid #d8eee4;
    border-radius: 999px;
    padding: 6px 12px 6px 6px;
    font-size: .82rem;
    font-weight: 600;
}
.md-steps li span {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #005e3c;
    color: #fff;
    font-size: .75rem;
}
.md-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, .75fr);
    gap: 24px;
    flex: 1;
    min-height: 0;
}
.md-col {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.md-col-upload { min-height: 420px; }
.md-dropzone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    border-color: #005e3c;
    color: #005e3c;
    background: #f4fbf7;
    border-radius: 16px;
    padding: 48px 24px;
    transition: background .15s, border-color .15s, color .15s;
}
.md-dropzone:hover {
    background: #e8f4ff;
    border-color: #8ec5f0;
    color: #1f4e8c;
}
.md-dropzone:hover .hint { color: #5b8fbf; }
.md-dropzone.dragover {
    background: #e8f4ff;
    border-color: #8ec5f0;
    color: #1f4e8c;
}
.md-dropzone i { font-size: 3rem; margin-bottom: 14px; }
.md-dropzone strong { font-size: 1.15rem; }
.md-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8faf9;
    border: 1px solid #d8eee4;
    border-radius: 16px;
    padding: 22px 22px 20px;
}
.md-panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: #013622;
}
.md-panel-copy {
    margin: 0 0 20px;
    color: var(--lp-muted);
    font-size: .92rem;
    line-height: 1.5;
}
.md-panel .tool-options {
    margin: 0 0 16px;
    background: #fff;
    box-shadow: none;
    padding: 14px;
}
.md-panel .tool-options input[type="text"],
.md-panel .tool-options input[type="number"],
.md-panel .tool-options select {
    max-width: none;
}
.md-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 0;
    cursor: pointer;
}
#quality-wrap { margin-top: 12px; }
.md-run {
    width: 100%;
    justify-content: center;
    margin-top: auto;
    background: #005e3c;
    padding: 14px 22px;
    border-radius: 12px;
    text-decoration: none;
    color: #fff;
}
.md-run:hover:not(:disabled) { background: #013622; }
.md-page .progress-wrap { margin-top: 18px; }
.md-page .progress-bar-lp > span { background: #00B96D; }
.md-result {
    margin-top: 18px;
    padding: 16px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #d8eee4;
}
.md-result h2 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.md-result h2 i { color: var(--lp-success); }
.md-result p {
    margin: 0 0 14px;
    color: var(--lp-muted);
}
.md-result .md-run { margin-top: 0; }

.md-hint-mobile { display: none; }
.md-run-short { display: none; }

.md-page .file-item .fname {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.md-page .progress-meta {
    flex-wrap: wrap;
    gap: 4px;
}

@media (max-width: 1100px) {
    body:has(.md-page) .app-main {
        max-width: 100%;
        padding: 18px 20px 20px;
    }
    .md-workspace {
        grid-template-columns: minmax(0, 1.1fr) minmax(240px, .9fr);
        gap: 16px;
    }
    .md-steps {
        flex-basis: 100%;
        margin-left: 0;
    }
    .md-col-upload,
    .md-dropzone { min-height: 320px; }
}

@media (max-height: 720px) and (min-width: 861px) {
    .md-page { min-height: 0; }
    .md-col-upload,
    .md-dropzone { min-height: 240px; }
}

@media (max-width: 860px) {
    .md-page { min-height: 0; }
    .md-workspace { grid-template-columns: 1fr; }
    .md-card { padding: 16px; }
    .md-card-head {
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 16px;
    }
    .md-col-upload,
    .md-dropzone { min-height: 240px; }
    .md-dropzone { padding: 32px 16px; }
    .md-run { margin-top: 16px; }
    .md-panel { padding: 18px 16px; }
}

@media (max-width: 640px) {
    body:has(.md-page) .app-main { padding: 12px 12px 18px; }
    .md-hint-desktop { display: none; }
    .md-hint-mobile { display: block; }
    .md-run-full { display: none; }
    .md-run-short { display: inline; }
    .md-card {
        padding: 14px 12px;
        border-radius: 14px;
    }
    .md-card-icon {
        width: 44px;
        height: 44px;
        font-size: 1.15rem;
        border-radius: 12px;
    }
    .md-card-title { font-size: 1.2rem; }
    .md-card-sub { font-size: .88rem; }
    .md-steps {
        width: 100%;
        gap: 6px;
    }
    .md-steps li {
        flex: 1 1 0;
        justify-content: center;
        font-size: .72rem;
        padding: 6px 6px 6px 4px;
        gap: 5px;
    }
    .md-steps li span {
        width: 18px;
        height: 18px;
        font-size: .68rem;
    }
    .md-col-upload,
    .md-dropzone { min-height: 180px; }
    .md-dropzone { padding: 24px 12px; }
    .md-dropzone i { font-size: 2rem; margin-bottom: 8px; }
    .md-dropzone strong { font-size: 1rem; }
    .md-panel { padding: 14px; }
    .md-panel-copy { margin-bottom: 14px; font-size: .88rem; }
    .md-result { padding: 14px; }
    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
    .lp-toast { min-width: 0; }
}

@media (max-width: 380px) {
    .md-steps li { font-size: 0; gap: 0; padding: 6px; }
    .md-steps li span {
        font-size: .72rem;
        width: 24px;
        height: 24px;
    }
}

/* ---------- Merge page thumbnails ---------- */
.page-board {
    margin-top: 18px;
    background: #fff;
    border: 1px solid var(--lp-border);
    border-radius: 14px;
    padding: 14px;
}
.page-board-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 14px;
    margin-bottom: 12px;
}
.page-board-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}
.page-board-hint {
    margin: 0;
    color: var(--lp-muted);
    font-size: .85rem;
}
.page-empty {
    margin: 0;
    color: var(--lp-muted);
    font-size: .9rem;
}
.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 12px;
}
.page-card {
    border: 1px solid var(--lp-border);
    border-radius: 12px;
    background: #fbfcfe;
    overflow: hidden;
    cursor: grab;
    transition: box-shadow .15s, border-color .15s, transform .15s;
}
.page-card:hover {
    border-color: #9ec5a8;
    box-shadow: 0 4px 14px rgba(0, 49, 29, .08);
}
.page-card.dragging {
    opacity: .45;
    transform: scale(.98);
}
.page-card-thumb {
    aspect-ratio: 3 / 4;
    background: #eef2f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.page-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.page-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-top: 1px solid var(--lp-border);
    background: #fff;
}
.page-card-num {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #005e3c;
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.page-card-label {
    flex: 1;
    min-width: 0;
    font-size: .72rem;
    color: var(--lp-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.page-card-remove {
    border: none;
    background: transparent;
    color: var(--lp-danger);
    cursor: pointer;
    padding: 2px;
    line-height: 1;
}
.md-page.is-merge .md-col-upload {
    min-height: 0;
}
.md-page.is-merge .md-dropzone {
    min-height: 180px;
}

@media (max-width: 640px) {
    .page-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        gap: 8px;
    }
}

/* ---------- Signature tools ---------- */
.md-page.is-sign .md-card-icon {
    background: linear-gradient(145deg, #1f5c3d, #0d3b26);
    color: #fff;
}
.sign-preview-wrap {
    margin-top: 16px;
    border: 1px solid var(--lp-border);
    border-radius: 14px;
    background: #fff;
    padding: 12px;
}
.sign-preview-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.sign-preview-toolbar select {
    min-width: 72px;
}
.sign-preview-hint {
    color: var(--lp-muted);
    font-size: .85rem;
}
.sign-preview-stage {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: #eef2f6;
    cursor: crosshair;
}
.sign-preview-stage img {
    display: block;
    width: 100%;
    height: auto;
}
.sign-marker {
    position: absolute;
    transform: translate(0, 0);
    min-height: 0;
    border: 2px dashed #005e3c;
    border-radius: 6px;
    background-color: rgba(0, 94, 60, .08);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center center;
    pointer-events: none;
    box-sizing: border-box;
    overflow: hidden;
}
.sign-marker.is-text {
    display: flex;
    align-items: flex-end;
    padding: 4px 8px 6px;
    font-size: .85rem;
    font-weight: 600;
    color: #111;
    border-bottom: 2px solid #222;
    background-size: auto;
}
#sig-canvas {
    width: 100%;
    max-width: 420px;
    height: 160px;
    border: 1px solid var(--lp-border);
    border-radius: 10px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}
.sign-draw-actions {
    margin-top: 8px;
}
.btn-secondary-lp {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--lp-border);
    background: #fff;
    color: var(--lp-text);
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 500;
}
.btn-secondary-lp:hover { background: #f3f6f4; }
.sign-thumb-wrap {
    margin-top: 10px;
    padding: 8px;
    border: 1px dashed var(--lp-border);
    border-radius: 10px;
    background: #fafafa;
    max-height: 110px;
    overflow: hidden;
}
.sign-thumb-wrap img {
    max-width: 160px;
    max-height: 90px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}
.md-page.is-sign .md-dropzone { min-height: 180px; }
