:root {
    --bg: #f0f7ff;
    --surface: #ffffff;
    --surface-2: #f4f9ff;
    --border: #dbeafe;
    --text: #0f2942;
    --text-muted: #5b7693;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-soft: #e0f2fe;
    --accent: #38bdf8;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --info: #0369a1;
    --info-soft: #e0f2fe;
    --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #e6f4fe 100%);
    --sidebar-text: #1e3a5f;
    --radius: 12px;
    --shadow: 0 4px 16px rgba(14, 165, 233, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* App Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid #bae6fd;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #dbeafe;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #38bdf8, #0284c7);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.28);
}

.brand-text h1 {
    margin: 0;
    font-size: 15px;
    color: #0c4a6e;
    font-weight: 800;
}

.brand-text span {
    font-size: 11px;
    color: #5b7693;
}

.sidebar-nav {
    padding: 14px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #0284c7;
    padding: 12px 12px 4px;
    font-weight: 700;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 9px;
    color: var(--sidebar-text);
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: #e0f2fe;
    color: #0369a1;
    text-decoration: none;
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 10px rgba(14, 165, 233, 0.28);
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid #bae6fd;
    background: rgba(255, 255, 255, 0.65);
    font-size: 12px;
}

.user-chip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 10px;
}

.user-chip strong {
    color: #0c4a6e;
    font-size: 13px;
}

.user-chip span {
    color: #5b7693;
    font-size: 11px;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-toggle {
    display: none;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 16px;
}

.page-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.content {
    padding: 24px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* Cards & Grids */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    margin-top: 6px;
    color: var(--text);
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: #1e293b;
}

.form-control, select.form-control, textarea.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-warning {
    background: #d97706;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th, .table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table th {
    background: var(--surface-2);
    color: #334155;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tr:hover td {
    background: #fafcff;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-info    { background: var(--info-soft); color: var(--info); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.alert-error   { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.alert-info    { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }

/* Signature Pad */
.sig-pad-wrap {
    border: 2px dashed #94a3b8;
    border-radius: 10px;
    background: #fff;
    padding: 8px;
    max-width: 440px;
}

.sig-canvas {
    width: 100%;
    height: 170px;
    display: block;
    cursor: crosshair;
    touch-action: none;
    background: #fcfdfd;
    border-radius: 6px;
}

.sig-preview {
    max-height: 90px;
    max-width: 240px;
    object-fit: contain;
    display: block;
    margin: 6px auto;
}

/* Official Printable Document (Kontrak & Surat Jalan) */
.doc-paper {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 36px 42px;
    max-width: 900px;
    margin: 0 auto 24px;
    box-shadow: var(--shadow);
    color: #000;
}

.doc-kop {
    border-bottom: 3px double #0f172a;
    padding-bottom: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.doc-kop h2 {
    margin: 0;
    font-size: 19px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.doc-kop p {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: #334155;
}

.doc-title-block {
    text-align: center;
    margin: 18px 0 22px;
}

.doc-title-block h3 {
    margin: 0;
    font-size: 17px;
    text-decoration: underline;
    text-transform: uppercase;
}

.doc-title-block .doc-num {
    font-size: 13px;
    margin-top: 4px;
    font-weight: 600;
}

.doc-meta-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.doc-meta-table td {
    padding: 4px 6px;
    vertical-align: top;
}

.doc-sign-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    margin-top: 32px;
}

.doc-sign-box {
    text-align: center;
    padding: 10px;
}

.doc-sign-space {
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin: 8px 0;
}

.digital-stamp {
    display: inline-block;
    border: 1.5px solid #0284c7;
    color: #0284c7;
    background: #f0f9ff;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 700;
    margin-top: 4px;
}

/* Auth & Public Pages */
.public-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #ffffff 0%, #e0f2fe 45%, #7dd3fc 100%);
    padding: 32px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: #fff;
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 18px 45px rgba(2, 132, 199, 0.16);
}

.public-reg-card {
    background: #fff;
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 820px;
    box-shadow: 0 18px 45px rgba(2, 132, 199, 0.16);
}

.demo-accounts {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-top: 16px;
    font-size: 12px;
}

.demo-btn {
    display: inline-block;
    margin: 3px 4px 0 0;
    padding: 4px 8px;
    background: #e2e8f0;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 11.5px;
    font-weight: 600;
}

.demo-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

/* Checkbox Pills for Petugas Selection */
.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}

.check-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    cursor: pointer;
    font-size: 13px;
}

.check-pill input {
    accent-color: var(--primary);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    max-width: 780px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    padding: 20px;
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .mobile-toggle {
        display: inline-flex;
    }
    .grid-2, .grid-3, .doc-sign-grid {
        grid-template-columns: 1fr;
    }
    .doc-paper {
        padding: 20px 18px;
    }
}

/* Print Styles */
@media print {
    body {
        background: #fff !important;
    }
    .sidebar, .topbar, .no-print, .alert {
        display: none !important;
    }
    .public-wrapper {
        background: #fff !important;
        padding: 0 !important;
        min-height: auto !important;
        display: block !important;
    }
    .public-reg-card {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    .content {
        padding: 0 !important;
        max-width: 100% !important;
    }
    .doc-paper {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }
}
