:root {
    --bg: #eef1f7;
    --panel: rgba(255,255,255,.76);
    --panel-solid: #ffffff;
    --ink: #0d1117;
    --muted: #6b7280;
    --line: rgba(15,23,42,.08);
    --blue: #60a5fa;
    --blue-dark: #2563eb;
    --purple: #a78bfa;
    --green: #22c55e;
    --orange: #f59e0b;
    --red: #ef4444;
    --shadow: 0 24px 80px rgba(15,23,42,.10);
    --shadow-soft: 0 12px 35px rgba(15,23,42,.08);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 15% 8%, rgba(96,165,250,.28), transparent 28%),
        radial-gradient(circle at 80% 10%, rgba(167,139,250,.28), transparent 26%),
        linear-gradient(135deg, #f8fafc 0%, #eef1f7 44%, #e9edf6 100%);
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
.app-shell { display: flex; min-height: 100vh; padding: 20px; gap: 20px; }
.sidebar {
    position: sticky;
    top: 20px;
    width: 112px;
    height: calc(100vh - 40px);
    border: 1px solid rgba(255,255,255,.76);
    background: rgba(255,255,255,.54);
    backdrop-filter: blur(22px);
    box-shadow: var(--shadow-soft);
    border-radius: 34px;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    z-index: 5;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 4px 0 24px; }
.brand-mark {
    width: 48px; height: 48px; border-radius: 18px;
    display: grid; place-items: center;
    background: linear-gradient(145deg, #0b1020, #1f2937);
    color: #fff; font-weight: 800; box-shadow: 0 16px 28px rgba(15,23,42,.22);
}
.brand-text { display: none; line-height: 1.05; font-weight: 700; }
.nav-list { display: grid; gap: 10px; }
.nav-item {
    height: 58px; border-radius: 20px; display: flex; align-items: center; justify-content: center;
    color: #64748b; transition: .24s ease; position: relative;
}
.nav-item svg { width: 23px; height: 23px; }
.nav-item span { display: none; }
.nav-item:hover { color: var(--ink); background: rgba(255,255,255,.68); transform: translateY(-2px); }
.nav-item.active {
    color: #fff;
    background: linear-gradient(145deg, #111827, #1e293b 62%, #334155);
    box-shadow: 0 18px 30px rgba(15,23,42,.22);
}
.sidebar-foot { margin-top: auto; }
.mini-card { padding: 14px; border-radius: 22px; background: rgba(255,255,255,.72); border: 1px solid var(--line); display: grid; place-items: center; }
.mini-card div { display: none; }
.pulse { width: 12px; height: 12px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 8px rgba(34,197,94,.14); }
.main-area { flex: 1; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    margin-bottom: 22px; padding: 8px 6px;
}
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
h1 { margin: 0; font-family: 'Plus Jakarta Sans', Inter, sans-serif; font-size: clamp(26px, 3vw, 42px); letter-spacing: -.045em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.search-pill, .user-chip {
    height: 52px; border-radius: 18px; background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.86);
    box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 10px; padding: 0 15px; color: var(--muted);
}
.search-pill svg { width: 20px; height: 20px; }
.user-chip { color: var(--ink); }
.user-chip small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.avatar { width: 35px; height: 35px; border-radius: 14px; background: #111827; color:#fff; display:grid; place-items:center; font-weight:800; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.78);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 22px;
}
.card-solid { background: var(--panel-solid); }
.hero-card {
    position: relative; overflow: hidden; min-height: 250px;
    background:
        radial-gradient(circle at top right, rgba(96,165,250,.28), transparent 35%),
        linear-gradient(145deg, rgba(255,255,255,.82), rgba(255,255,255,.58));
}
.hero-card:after {
    content: ''; position: absolute; right: -80px; bottom: -110px; width: 280px; height: 280px; border-radius: 50%;
    background: radial-gradient(circle, rgba(167,139,250,.24), transparent 68%);
}
.hero-title { font-size: clamp(34px, 4vw, 58px); letter-spacing: -.06em; line-height: .96; margin: 8px 0 16px; }
.hero-sub { color: var(--muted); max-width: 660px; line-height: 1.8; }
.hero-actions { display:flex; flex-wrap:wrap; gap:10px; margin-top: 24px; position: relative; z-index: 2; }
.btn {
    border: 0; cursor: pointer; min-height: 44px; padding: 0 16px; border-radius: 15px; display:inline-flex; align-items:center; justify-content:center; gap:8px;
    font-weight: 700; transition: .22s ease;
}
.btn-primary { background: #111827; color:#fff; box-shadow: 0 18px 34px rgba(15,23,42,.24); }
.btn-blue { background: linear-gradient(145deg, var(--blue-dark), #7c3aed); color: white; box-shadow: 0 18px 34px rgba(37,99,235,.22); }
.btn-ghost { background: rgba(255,255,255,.68); border: 1px solid var(--line); color: #334155; }
.btn-soft { background: rgba(96,165,250,.13); color: #1d4ed8; border: 1px solid rgba(96,165,250,.22); }
.btn-danger { background: rgba(239,68,68,.1); color: #b91c1c; }
.btn:hover { transform: translateY(-2px); filter: saturate(1.05); }
.stat-card { position: relative; overflow: hidden; min-height: 138px; }
.stat-card small, .muted { color: var(--muted); }
.stat-value { font-size: 36px; font-weight: 800; letter-spacing: -.05em; margin: 14px 0 4px; }
.stat-card:after { content:''; position:absolute; right:18px; top:18px; width:48px; height:48px; border-radius:18px; background: linear-gradient(145deg, rgba(96,165,250,.28), rgba(167,139,250,.22)); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; }
.section-head h2, .section-title { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align:left; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; padding: 12px 10px; }
td { padding: 14px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.doc-type { font-weight: 800; color: #111827; }
.badge { display:inline-flex; align-items:center; border-radius: 99px; min-height: 30px; padding: 0 11px; font-size: 12px; font-weight: 800; border: 1px solid transparent; }
.badge-draft { background: rgba(100,116,139,.10); color: #475569; border-color: rgba(100,116,139,.16); }
.badge-review { background: rgba(245,158,11,.12); color: #b45309; border-color: rgba(245,158,11,.22); }
.badge-approved { background: rgba(37,99,235,.11); color: #1d4ed8; border-color: rgba(37,99,235,.20); }
.badge-signed { background: rgba(34,197,94,.12); color: #15803d; border-color: rgba(34,197,94,.22); }
.workflow { display: grid; gap: 14px; }
.flow-step { padding: 16px; border-radius: 22px; background: rgba(255,255,255,.64); border: 1px solid var(--line); display:flex; align-items:center; gap: 14px; }
.flow-number { width: 42px; height: 42px; border-radius: 16px; background:#111827; color:#fff; display:grid; place-items:center; font-weight:800; }
.flow-step b { display:block; margin-bottom: 4px; }
.flow-step small { color: var(--muted); }
.form-card { display:grid; gap: 15px; }
.form-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display:grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 800; font-size: 13px; color: #1f2937; }
input, textarea, select {
    width: 100%; border: 1px solid rgba(15,23,42,.10); background: rgba(255,255,255,.78);
    min-height: 48px; border-radius: 16px; padding: 12px 14px; outline: none; transition: .2s ease; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
input:focus, textarea:focus, select:focus { border-color: rgba(37,99,235,.42); box-shadow: 0 0 0 4px rgba(96,165,250,.16); background: #fff; }
.form-actions { display:flex; flex-wrap:wrap; gap: 10px; margin-top: 8px; }
.preview-panel { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.document-preview {
    background: #fff; border: 1px solid rgba(15,23,42,.08); border-radius: 24px; padding: 28px; min-height: 650px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.8);
}
.preview-brand { display:flex; justify-content:space-between; align-items:flex-start; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.preview-logo { width: 46px; height:46px; border-radius:16px; background:#111827; color:#fff; display:grid; place-items:center; font-weight:900; }
.preview-title { font-size: 24px; font-weight: 900; letter-spacing: -.04em; margin: 18px 0 12px; }
.preview-content { color:#334155; line-height: 1.75; white-space: pre-wrap; }
.signature-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.signature-box { border:1px dashed rgba(15,23,42,.22); border-radius:20px; min-height: 120px; padding: 16px; background:rgba(248,250,252,.74); }
.signature-line { margin-top: 50px; border-top: 1px solid rgba(15,23,42,.22); padding-top: 8px; font-weight:800; }
.notice { border-radius: 18px; padding: 14px 16px; margin-bottom: 16px; font-weight: 700; }
.notice-success { background: rgba(34,197,94,.12); color:#166534; border:1px solid rgba(34,197,94,.20); }
.notice-error { background: rgba(239,68,68,.10); color:#b91c1c; border:1px solid rgba(239,68,68,.20); }
.item-table input { min-height: 42px; border-radius: 13px; }
.item-table td { padding: 8px; }
.login-shell { min-height:100vh; display:grid; place-items:center; padding:22px; }
.login-card { width: min(1040px, 100%); display:grid; grid-template-columns: 1fr 440px; overflow:hidden; border-radius:38px; background:rgba(255,255,255,.68); border:1px solid rgba(255,255,255,.78); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.login-visual { padding:42px; background: linear-gradient(145deg, rgba(17,24,39,.98), rgba(30,41,59,.92)); color:#fff; position:relative; overflow:hidden; }
.login-visual:before { content:''; position:absolute; width:360px; height:360px; right:-140px; top:-120px; border-radius:50%; background:rgba(96,165,250,.22); }
.login-visual:after { content:''; position:absolute; width:240px; height:240px; left:50px; bottom:-90px; border-radius:50%; background:rgba(167,139,250,.18); }
.login-visual > * { position: relative; z-index:1; }
.login-title { font-size:52px; line-height:.96; letter-spacing:-.07em; margin:36px 0 18px; }
.login-form { padding:42px; display:grid; align-content:center; gap:16px; }
.login-form h2 { font-size:30px; letter-spacing:-.04em; margin:0; }
.kpi-row { display:grid; grid-template-columns: repeat(3, 1fr); gap:12px; margin-top:32px; }
.kpi { padding:16px; border-radius:20px; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.12); }
.kpi b { font-size:24px; display:block; }
.kpi small { color:rgba(255,255,255,.7); }
.client-card { display:flex; align-items:center; gap:14px; }
.client-avatar { width:46px; height:46px; border-radius:18px; display:grid; place-items:center; color:#fff; font-weight:900; background:linear-gradient(145deg,#111827,#334155); }
.stack { display:grid; gap: 16px; }
.empty-state { text-align:center; padding: 44px 20px; color: var(--muted); }
.footer-note { color: var(--muted); font-size: 13px; margin-top: 18px; }
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
    .preview-panel { position: static; max-height: none; }
    .topbar { align-items:flex-start; flex-direction:column; }
    .top-actions { width:100%; overflow-x:auto; padding-bottom: 4px; }
}
@media (max-width: 760px) {
    .app-shell { padding: 12px; display:block; }
    .sidebar { position: fixed; left: 12px; right: 12px; bottom: 12px; top: auto; height: 72px; width: auto; border-radius: 26px; padding: 9px; flex-direction: row; align-items:center; }
    .brand, .sidebar-foot { display:none; }
    .nav-list { display:flex; width:100%; justify-content:space-between; gap: 4px; }
    .nav-item { height:54px; flex:1; border-radius: 18px; }
    .nav-item span { display:none; }
    .main-area { padding-bottom: 86px; }
    .search-pill { display:none; }
    .user-chip { flex:1; }
    .grid-4, .grid-3, .form-grid, .signature-grid { grid-template-columns: 1fr; }
    .login-card { grid-template-columns: 1fr; }
    .login-visual { display:none; }
    .login-form { padding:28px; }
}
@media print {
    body { background:#fff; }
    .sidebar, .topbar, .no-print { display:none!important; }
    .app-shell { padding:0; display:block; }
    .card { box-shadow:none; border:0; background:#fff; padding:0; }
    .document-preview { border:0; box-shadow:none; border-radius:0; }
}

/* Landing page editor */
.builder-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.builder-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.builder-card {
    padding: 16px;
    border-radius: 24px;
    border: 1px solid rgba(15, 23, 42, .08);
    background: rgba(255, 255, 255, .72);
    box-shadow: 0 18px 50px rgba(15, 23, 42, .06);
}
.checkline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
}
.checkline input {
    width: 18px;
    height: 18px;
    accent-color: #4f46e5;
}
.site-link-card {
    color: inherit;
    text-decoration: none;
    margin-bottom: 10px;
}
.floating-savebar {
    position: sticky;
    bottom: 18px;
    z-index: 20;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding: 12px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, .85);
    background: rgba(255, 255, 255, .76);
    backdrop-filter: blur(18px);
    box-shadow: 0 20px 60px rgba(15, 23, 42, .12);
}

.portfolio-image-preview {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 12px;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(59, 130, 246, .08), rgba(124, 58, 237, .08));
    border: 1px solid rgba(59, 130, 246, .14);
}
.portfolio-image-preview img {
    width: 96px;
    height: 70px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid rgba(15, 23, 42, .08);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .12);
}
.portfolio-image-preview strong {
    display: block;
    color: #0f172a;
    font-size: 13px;
    margin-bottom: 2px;
}
.portfolio-image-preview span,
.field-hint,
.upload-placeholder {
    color: #64748b;
    font-size: 12px;
}
.upload-placeholder {
    padding: 12px;
    margin-bottom: 10px;
    border: 1px dashed rgba(15, 23, 42, .18);
    border-radius: 16px;
    background: rgba(248, 250, 252, .8);
}
.remove-image {
    margin-top: 8px;
}
.field input[type="file"] {
    padding: 11px;
    cursor: pointer;
}

@media (max-width: 1024px) {
    .builder-grid,
    .builder-grid-3 { grid-template-columns: 1fr; }
}

/* Landing editor refinements */
.section-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.builder-card { display: grid; gap: 13px; position: relative; }
.builder-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
}
.builder-card-head h3 { margin: 2px 0 0; font-size: 18px; letter-spacing: -.03em; }
.builder-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(37, 99, 235, .10);
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 13px;
    border: 1px solid rgba(15, 23, 42, .08);
    background: rgba(255, 255, 255, .72);
    color: #334155;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 22px;
    line-height: 1;
    transition: .2s ease;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(15, 23, 42, .10); }
.icon-btn.danger { color: #b91c1c; background: rgba(239, 68, 68, .08); border-color: rgba(239, 68, 68, .16); }
.landing-admin-form input::placeholder,
.landing-admin-form textarea::placeholder { color: #94a3b8; }
.landing-admin-form small { line-height: 1.5; }
@media (max-width: 760px) {
    .section-head { align-items: flex-start; flex-direction: column; }
    .section-actions, .section-actions .btn { width: 100%; }
}
