:root {
    --pd-red: #d32f2f;
    --pd-red-dark: #b71c1c;
    --pd-ink: #14181f;
    --pd-muted: #5c6570;
    --pd-line: #e6e9ee;
    --pd-bg: #f3f5f8;
    --pd-card: #ffffff;
    --pd-ok: #1b7a4a;
    --pd-warn: #9a6b00;
    --pd-info: #0b5cab;
    --pd-radius: 16px;
    --pd-sidebar: 260px;
    --pd-font: "DM Sans", system-ui, sans-serif;
    --pd-display: "Instrument Sans", "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
.pd-body {
    font-family: var(--pd-font);
    color: var(--pd-ink);
    background:
        radial-gradient(1200px 500px at 10% -10%, rgba(211, 47, 47, .08), transparent 55%),
        radial-gradient(900px 400px at 100% 0%, rgba(20, 24, 31, .05), transparent 50%),
        var(--pd-bg);
    min-height: 100vh;
}
.hidden { display: none !important; }
.pd-skip {
    position: absolute; left: -9999px; top: auto;
}
.pd-skip:focus { left: 12px; top: 12px; z-index: 100; background: #fff; padding: 8px 12px; }

/* Sidebar */
.pd-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--pd-sidebar);
    background: linear-gradient(180deg, #171b22 0%, #10141a 100%);
    color: #fff; display: flex; flex-direction: column; z-index: 40;
    padding: 22px 16px;
}
.pd-brand { padding: 4px 10px 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 18px; }
.pd-logo { color: #ff6b6b; text-decoration: none; font-family: var(--pd-display); font-weight: 700; font-size: 1.35rem; letter-spacing: .04em; }
.pd-brand-sub { display: block; margin-top: 4px; font-size: .78rem; color: rgba(255,255,255,.55); }
.pd-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pd-nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    border: 0; background: transparent; color: rgba(255,255,255,.78);
    padding: 12px 14px; border-radius: 12px; font: inherit; font-weight: 500;
    cursor: pointer; text-align: left; transition: background .15s, color .15s;
}
.pd-nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.pd-nav-item.active { background: rgba(211, 47, 47, .22); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,107,107,.25); }
.pd-nav-ico { opacity: .7; width: 1.2em; text-align: center; }
.pd-sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.pd-user-chip { font-size: .82rem; color: rgba(255,255,255,.7); padding: 0 8px 10px; line-height: 1.35; word-break: break-word; }
.pd-logout {
    width: 100%; border: 1px solid rgba(255,255,255,.14); background: transparent;
    color: rgba(255,255,255,.85); border-radius: 10px; padding: 10px; font: inherit; cursor: pointer;
}
.pd-logout:hover { background: rgba(255,255,255,.06); }

/* Shell */
.pd-shell { margin-left: var(--pd-sidebar); min-height: 100vh; }
.pd-topbar {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 28px; position: sticky; top: 0; z-index: 20;
    background: rgba(243,245,248,.88); backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(230,233,238,.9);
}
.pd-menu-btn, .pd-refresh {
    border: 1px solid var(--pd-line); background: #fff; border-radius: 10px;
    width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem;
}
.pd-menu-btn { display: none; }
.pd-page-title { margin: 0; font-family: var(--pd-display); font-size: 1.35rem; font-weight: 700; }
.pd-page-sub { margin: 2px 0 0; color: var(--pd-muted); font-size: .9rem; }
.pd-refresh { margin-left: auto; }
.pd-main { padding: 22px 28px 48px; max-width: 1100px; }

/* Gate */
.pd-gate { display: flex; justify-content: center; padding: 60px 16px; }
.pd-gate-card {
    background: var(--pd-card); border-radius: var(--pd-radius); padding: 32px;
    max-width: 420px; text-align: center; box-shadow: 0 12px 40px rgba(20,24,31,.08);
}
.pd-gate-card h1 { margin: 0 0 10px; font-family: var(--pd-display); }

/* Views */
.pd-view { display: none; animation: pd-fade .25s ease; }
.pd-view.active { display: block; }
@keyframes pd-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* KPI */
.pd-kpi-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px;
}
.pd-kpi {
    background: var(--pd-card); border: 1px solid var(--pd-line); border-radius: var(--pd-radius);
    padding: 18px 16px; box-shadow: 0 4px 18px rgba(20,24,31,.03);
}
.pd-kpi-accent {
    background: linear-gradient(145deg, #1a1f27, #2a3140); color: #fff; border-color: transparent;
}
.pd-kpi-accent .pd-kpi-label { color: rgba(255,255,255,.65); }
.pd-kpi-label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--pd-muted); margin-bottom: 8px; }
.pd-kpi-value { font-family: var(--pd-display); font-size: 1.45rem; font-weight: 700; }

.pd-grid-2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; margin-bottom: 16px; }

.pd-panel {
    background: var(--pd-card); border: 1px solid var(--pd-line); border-radius: var(--pd-radius);
    padding: 20px; margin-bottom: 16px; box-shadow: 0 4px 18px rgba(20,24,31,.03);
}
.pd-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.pd-panel-head h2 { margin: 0; font-family: var(--pd-display); font-size: 1.05rem; }
.pd-link-btn { border: 0; background: none; color: var(--pd-red); font: inherit; font-weight: 600; cursor: pointer; }

.pd-actions { display: flex; flex-direction: column; gap: 10px; }
.pd-action {
    display: block; text-align: left; text-decoration: none; color: inherit;
    border: 1px solid var(--pd-line); background: #fafbfc; border-radius: 12px;
    padding: 14px 16px; cursor: pointer; font: inherit; transition: border-color .15s, background .15s;
}
.pd-action:hover { border-color: #f1b0b0; background: #fff7f7; }
.pd-action strong { display: block; margin-bottom: 2px; }
.pd-action span { color: var(--pd-muted); font-size: .88rem; }

.pd-meta { margin: 0; display: grid; gap: 12px; }
.pd-meta > div { display: grid; grid-template-columns: 100px 1fr; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--pd-line); }
.pd-meta > div:last-child { border-bottom: 0; padding-bottom: 0; }
.pd-meta dt { color: var(--pd-muted); font-size: .85rem; margin: 0; }
.pd-meta dd { margin: 0; font-weight: 600; word-break: break-word; }

.pd-list { display: flex; flex-direction: column; gap: 8px; }
.pd-list-item {
    display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: 12px; background: #f8f9fb; border: 1px solid var(--pd-line);
}
.pd-list-item strong { display: block; font-size: .95rem; }
.pd-list-item span { color: var(--pd-muted); font-size: .82rem; }
.pd-badge {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    padding: 4px 8px; border-radius: 999px; background: #eee; color: #444; white-space: nowrap;
}
.pd-badge-ok { background: #e7f6ee; color: var(--pd-ok); }
.pd-badge-warn { background: #fff4d6; color: var(--pd-warn); }
.pd-badge-info { background: #e8f1fb; color: var(--pd-info); }
.pd-badge-bad { background: #fdecea; color: #b71c1c; }
.pd-empty { color: var(--pd-muted); text-align: center; padding: 28px 12px; margin: 0; }

/* Banners */
.pd-banner {
    border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; border: 1px solid;
}
.pd-banner strong { display: block; margin-bottom: 4px; }
.pd-banner p { margin: 0; font-size: .92rem; }
.pd-banner-warn { background: #fff8e8; border-color: #f0d58a; color: #6d5200; }
.pd-banner-info { background: #eef5fc; border-color: #b7d4f0; color: #0b5cab; }
.pd-banner-ok { background: #eef8f1; border-color: #b7e0c6; color: #1b7a4a; }

/* Buttons */
.pd-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; text-decoration: none;
    transition: opacity .15s, transform .15s;
}
.pd-btn:active { transform: scale(.98); }
.pd-btn:disabled, .pd-btn.is-loading { opacity: .7; cursor: wait; pointer-events: none; }
.pd-btn-primary { background: var(--pd-red); color: #fff; }
.pd-btn-primary:hover { background: var(--pd-red-dark); }
.pd-btn-secondary { background: #fff; border-color: var(--pd-line); color: var(--pd-ink); }
.pd-btn-ghost { background: transparent; color: var(--pd-muted); border-color: transparent; }
.pd-btn-block { width: 100%; }
.pd-btn-spinner {
    width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: pd-spin .7s linear infinite;
}
@keyframes pd-spin { to { transform: rotate(360deg); } }

/* Wizard */
.pd-wizard { max-width: 720px; }
.pd-wizard-progress {
    display: flex; gap: 8px; margin-bottom: 22px;
}
.pd-wiz-dot {
    flex: 1; height: 4px; border-radius: 99px; background: var(--pd-line); position: relative;
}
.pd-wiz-dot.active { background: var(--pd-red); }
.pd-wiz-dot.done { background: #f3a6a6; }
.pd-step { display: none; }
.pd-step.active { display: block; animation: pd-fade .25s ease; }
.pd-step-head { margin-bottom: 20px; }
.pd-step-kicker {
    margin: 0 0 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--pd-red);
}
.pd-step-head h2 { margin: 0 0 6px; font-family: var(--pd-display); font-size: 1.35rem; }
.pd-step-head p { margin: 0; color: var(--pd-muted); }

.pd-fields { display: flex; flex-direction: column; gap: 14px; }
.pd-fields-nested {
    display: flex; flex-direction: column; gap: 14px;
    padding: 14px; border-radius: 12px; background: #f8f9fb; border: 1px solid var(--pd-line);
}
.pd-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pd-field label, .pd-label {
    display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: #2c3340;
}
.pd-field input, .pd-field select, .pd-field textarea {
    width: 100%; border: 1px solid var(--pd-line); border-radius: 12px;
    padding: 12px 14px; font: inherit; background: #fff; color: var(--pd-ink);
    transition: border-color .15s, box-shadow .15s;
}
.pd-field input:focus, .pd-field select:focus, .pd-field textarea:focus {
    outline: none; border-color: #ef9a9a; box-shadow: 0 0 0 3px rgba(211,47,47,.12);
}
.pd-field-hint {
    display: block; margin-top: 6px; color: var(--pd-muted); font-size: .78rem;
}
.tafuta-phone-row { display: flex; gap: 8px; align-items: stretch; }
.tafuta-phone-dial {
    flex: 0 0 auto; max-width: 48%; min-width: 140px; padding: 12px 10px;
    border: 1px solid var(--pd-line); border-radius: 12px; font: inherit; background: #fff;
}
.tafuta-phone-national {
    flex: 1; min-width: 0; padding: 12px 14px;
    border: 1px solid var(--pd-line); border-radius: 12px; font: inherit; background: #fff;
}
.tafuta-phone-dial:focus, .tafuta-phone-national:focus {
    outline: none; border-color: #ef9a9a; box-shadow: 0 0 0 3px rgba(211,47,47,.12);
}
.pd-gps-status { margin: 0; color: var(--pd-muted); font-size: .9rem; }
.pd-form-error {
    background: #fdecea; color: #b71c1c; border: 1px solid #f5c6c2;
    border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; font-size: .92rem;
}
.pd-review {
    background: #f8f9fb; border: 1px solid var(--pd-line); border-radius: 12px; padding: 16px;
}
.pd-review-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--pd-line); font-size: .92rem; }
.pd-review-row:last-child { border-bottom: 0; }
.pd-review-row span { color: var(--pd-muted); }
.pd-review-row strong { text-align: right; }

.pd-wizard-nav {
    display: flex; justify-content: space-between; gap: 10px; margin-top: 24px;
    padding-top: 18px; border-top: 1px solid var(--pd-line);
}

/* Upload zones (compat with upload-zones.js) */
.upload-zone {
    border: 1.5px dashed #cfd5de; border-radius: 14px; padding: 18px; text-align: center;
    cursor: pointer; background: #fafbfc; position: relative; transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.is-drag { border-color: #ef9a9a; background: #fff7f7; }
.upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.upload-zone-empty strong { font-size: .95rem; }
.upload-hint { color: var(--pd-muted); font-size: .82rem; }
.upload-btn {
    display: inline-block; margin-top: 4px; background: var(--pd-red); color: #fff;
    padding: 6px 14px; border-radius: 8px; font-size: .85rem; font-weight: 600;
}
.upload-zone-preview img { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; margin: 0 auto 8px; }
.upload-remove {
    border: 1px solid var(--pd-line); background: #fff; border-radius: 8px; padding: 6px 12px;
    cursor: pointer; font: inherit; font-size: .85rem;
}
.upload-status { margin: 8px 0 0; font-size: .82rem; color: var(--pd-muted); min-height: 1.2em; }

.pd-overlay {
    position: fixed; inset: 0; background: rgba(10,12,16,.45); z-index: 35;
}
.pd-toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 80;
    width: min(420px, calc(100vw - 32px)); padding: 16px 18px;
    border: 1px solid #a8d8ba; border-radius: 14px;
    background: #effaf3; color: #155e38;
    box-shadow: 0 16px 44px rgba(20,24,31,.18);
    animation: pd-fade .25s ease;
}
.pd-toast strong, .pd-toast span { display: block; }
.pd-toast span { margin-top: 4px; font-size: .9rem; line-height: 1.45; }

@media (max-width: 960px) {
    .pd-kpi-grid { grid-template-columns: 1fr 1fr; }
    .pd-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .pd-sidebar {
        transform: translateX(-105%); transition: transform .2s ease;
    }
    .pd-sidebar.open { transform: translateX(0); }
    .pd-shell { margin-left: 0; }
    .pd-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .pd-main { padding: 16px; }
    .pd-topbar { padding: 14px 16px; }
    .pd-field-row { grid-template-columns: 1fr; }
    .pd-toast { right: 16px; bottom: 16px; }
}
