:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --sidebar: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-border: #3b82f6;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #1e293b;
    --primary-hover: #334155;
    --blue: #3b82f6;
    --emerald: #10b981;
    --amber: #f59e0b;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(15, 23, 42, 0.18);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: inherit; text-decoration: none; }

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--sidebar);
}

.login-card,
.panel,
.stat-card,
.alert,
.user-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--line);
}

.login-card {
    width: min(480px, 100%);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
}

.brand-mark {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: #f1f5f9;
    color: var(--sidebar);
    font-size: 24px;
    font-weight: 800;
    margin: 0 auto 16px;
}

.login-card h1 {
    margin: 0;
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.login-card > p {
    margin: 6px 0 24px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

.eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 700;
}

.stack-form,
.compact {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
}

input,
select,
textarea,
button,
.button {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    padding: 12px 14px;
    font: inherit;
}

input,
select,
textarea {
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

button,
.button {
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

button:hover,
.button:hover { background: var(--primary-hover); }
button:active,
.button:active { transform: scale(0.98); }

.secondary,
.button.ghost {
    background: #e2e8f0;
    color: #334155;
}

.secondary.danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.hint-box {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
}

.alert {
    padding: 14px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 700;
}

.alert.success { background: var(--success-soft); color: var(--success); }
.alert.danger { background: var(--danger-soft); color: #b91c1c; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 256px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}

.sidebar > div:first-child {
    padding: 24px;
    background: rgba(15, 23, 42, 0.18);
}

.sidebar h1 {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.sidebar-copy {
    margin-top: 8px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.6;
}

.nav-list {
    display: grid;
    gap: 4px;
    padding: 16px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.nav-link:hover {
    background: #334155;
}

.nav-link.active {
    background: #334155;
    border-left: 4px solid var(--sidebar-border);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding-left: 10px;
}

.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.user-card {
    margin: 12px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.45);
    border-color: #334155;
    color: #fff;
}

.user-card span {
    color: #cbd5e1;
    font-size: 12px;
}

.meta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 14px;
}

.badge,
.team-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.badge { background: #2563eb; color: #fff; }
.badge.owner { background: #2563eb; }
.badge.admin { background: #059669; }
.badge.sales { background: #d97706; }
.team-pill { background: #f1f5f9; color: #475569; }

.main-content {
    flex: 1;
    min-width: 0;
    background: var(--bg);
    padding: 0;
}

.page-header {
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.page-header h2 {
    margin: 2px 0 0;
    font-size: 18px;
    font-weight: 700;
}

.header-pill {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid var(--line);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.main-content > .alert,
.main-content > section,
.main-content > .stats-grid,
.main-content > .split-grid,
.main-content > .team-grid {
    margin-left: 24px;
    margin-right: 24px;
}

.main-content > .alert:first-of-type,
.main-content > section:first-of-type,
.main-content > .stats-grid:first-of-type,
.main-content > .split-grid:first-of-type,
.main-content > .team-grid:first-of-type {
    margin-top: 24px;
}

.stats-grid,
.split-grid,
.team-grid {
    display: grid;
    gap: 24px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.split-grid,
.team-grid {
    grid-template-columns: 1fr 1.2fr;
}

.stat-card,
.panel {
    padding: 24px;
}

.stat-card {
    border-left: 4px solid var(--blue);
}

.sales-card { border-left-color: var(--blue); }
.profit-card { border-left-color: var(--emerald); }
.komisi-card { border-left-color: var(--amber); }

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    font-weight: 800;
}

.sales-card strong { color: var(--text); }
.profit-card strong { color: var(--emerald); }
.komisi-card strong { color: var(--amber); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.panel-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #1e293b;
}

.text-link,
.mini-link,
.link-button {
    width: auto;
    padding: 0;
    border: none;
    background: none;
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.link-button { cursor: pointer; }
.table-wrap {
    overflow-x: auto;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: #f1f5f9;
    color: #475569;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    font-weight: 700;
}

th,
 td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    vertical-align: top;
}

tr:hover td { background: #f8fafc; }
.empty-row,
.muted { color: #94a3b8; font-style: italic; }

.action-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.action-cell form { margin: 0; }
.form-panel.narrow { max-width: 1024px; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-grid.single { grid-template-columns: 1fr; }
.full { grid-column: 1 / -1; }
.button-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.inline-note {
    padding: 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
}

@media (max-width: 1100px) {
    .app-shell,
    .split-grid,
    .team-grid,
    .stats-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
    }

    .app-shell {
        flex-direction: column;
    }
}

@media (max-width: 680px) {
    .page-header {
        padding: 0 16px;
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .main-content > .alert,
    .main-content > section,
    .main-content > .stats-grid,
    .main-content > .split-grid,
    .main-content > .team-grid {
        margin-left: 16px;
        margin-right: 16px;
    }

    .button-row,
    .action-cell {
        flex-direction: column;
        align-items: stretch;
    }
}

.sidebar {
    background-color: #1e293b;
    transition: all 0.3s ease-in-out;
}

.sidebar-overlay {
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(1px);
}

.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

.table-container table {
    min-width: 640px;
}

.table-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

th {
    background-color: #f1f5f9;
    color: #475569;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.btn-primary {
    background-color: #1e293b;
    color: white;
    transition: background 0.2s;
}

.btn-primary:hover {
    background-color: #334155;
}

.nav-item.active {
    background-color: #334155;
    border-left: 4px solid #3b82f6;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.nav-item:hover,
.nav-item-group:hover,
.sidebar-logout:hover {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.2);
}

.sidebar-nav {
    padding-bottom: 12px;
}

.sidebar-group {
    display: grid;
    gap: 8px;
}

.nav-item-group {
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-chevron {
    font-size: 10px;
    color: #94a3b8;
    transition: transform 0.25s ease;
}

.sidebar-chevron.active {
    transform: rotate(180deg);
}

.sidebar-submenu {
    display: grid;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-left: 12px;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding-top 0.25s ease;
}

.sidebar-submenu.active {
    max-height: 320px;
    opacity: 1;
    padding-top: 2px;
}

.sidebar-submenu-nested {
    padding-left: 14px;
}

.sidebar-submenu-nested.active {
    max-height: 420px;
}

.sidebar-sublink {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 16px;
    border-radius: 10px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    background: rgba(15, 23, 42, 0.32);
    border: 1px solid transparent;
}

.sidebar-sublink:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.sidebar-sublink.active {
    color: #fff;
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
}

.sidebar-sublink-group {
    justify-content: space-between;
}

.sidebar-group-nested {
    gap: 6px;
}

.sidebar-logout {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.12);
}

.btn-danger {
    background-color: #ef4444;
    color: white;
    transition: background 0.2s;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-edit {
    background-color: #3b82f6;
    color: white;
    transition: background 0.2s;
}

.btn-edit:hover {
    background-color: #2563eb;
}

.login-bg {
    background-color: #1e293b;
}

.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.readonly-note {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
}

.sao-form {
    display: grid;
    gap: 24px;
}

.form-section {
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 20px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.form-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.form-section-title {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.form-section-copy {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.6;
}

.form-section-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.form-section-grid.compact-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-card {
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
}

.field-card.soft {
    background: #f8fafc;
}

.field-span-2 {
    grid-column: 1 / -1;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.summary-box {
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
    padding: 16px 18px;
}

.summary-box strong {
    display: block;
    margin-top: 6px;
    font-size: 22px;
    line-height: 1.1;
    color: #1d4ed8;
    letter-spacing: -0.03em;
}

.summary-box span {
    display: block;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.section-note {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 600;
}

.no-print {
    display: flex;
}

.a4-document {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 36px;
    border: 1px solid #cbd5e1;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

.a4-document__header {
    padding-bottom: 16px;
    border-bottom: 2px solid #1e293b;
}

.a4-document__title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    text-transform: uppercase;
    color: #0f172a;
}

.a4-document__meta {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.a4-meta-grid,
.a4-financial-grid {
    display: grid;
    gap: 12px 18px;
}

.a4-meta-grid--double,
.a4-financial-grid--double {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.a4-meta-grid--triple,
.a4-financial-grid--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.a4-meta-item,
.a4-financial-item,
.a4-summary-item {
    display: grid;
    grid-template-columns: 150px 12px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.a4-meta-label {
    font-weight: 700;
    color: #334155;
}

.a4-meta-separator {
    color: #475569;
    font-weight: 700;
    text-align: center;
}

.a4-meta-value {
    color: #0f172a;
    font-weight: 600;
    word-break: break-word;
}

.a4-section {
    margin-top: 18px;
}

.a4-section__label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    color: #334155;
}

.a4-section__box {
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    padding: 14px 16px;
    background: #f8fafc;
}

.a4-list {
    margin: 0;
    padding-left: 20px;
    display: grid;
    gap: 6px;
    font-size: 13px;
    line-height: 1.6;
    color: #0f172a;
}

.a4-list--plain {
    list-style: disc;
}

.a4-summary-stack {
    display: grid;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1.5px solid #cbd5e1;
}

@page {
    size: A4;
    margin: 14mm 12mm;
}

@media print {
    html,
    body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #main-app,
    #main-app * {
        visibility: hidden !important;
    }

    .a4-document,
    .a4-document *,
    .print-data-document,
    .print-data-document *,
    .print-data-title,
    .print-data-title * {
        visibility: visible !important;
    }

    .no-print,
    .sidebar,
    .sidebar-overlay,
    .page-header,
    .main-content > .alert,
    .main-content > .stats-grid,
    .main-content > .split-grid,
    .main-content > .team-grid,
    header,
    footer {
        display: none !important;
    }

    .main-content,
    .main-content > section,
    .card,
    .p-6,
    .print\:p-8 {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        box-shadow: none !important;
        border: none !important;
        overflow: visible !important;
    }

    .card,
    .a4-document {
        box-shadow: none !important;
        border: none !important;
    }

    .a4-document {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0 2mm;
        border-radius: 0;
        background: #fff !important;
    }

    .a4-section__box {
        background: #fff !important;
    }

    .print-data-title {
        display: block !important;
        margin-bottom: 8px !important;
        padding: 0 !important;
        color: #0f172a !important;
    }

    .print-data-title h1 {
        margin: 0 0 4px !important;
        font-size: 14px !important;
        font-weight: 800 !important;
        text-transform: uppercase !important;
    }

    .print-data-title p {
        margin: 0 0 8px !important;
        font-size: 9px !important;
        color: #334155 !important;
    }

    .print-data-document {
        position: absolute !important;
        left: 0 !important;
        top: 22px !important;
        width: 100% !important;
        overflow: visible !important;
        border-radius: 0 !important;
    }

    .print-data-document table {
        width: 100% !important;
        min-width: 0 !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
    }

    .print-data-document th,
    .print-data-document td {
        padding: 2px 3px !important;
        border: 1px solid #cbd5e1 !important;
        font-size: 5.5px !important;
        line-height: 1.25 !important;
        word-break: break-word !important;
        white-space: normal !important;
    }

    .print-data-document th {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        font-weight: 800 !important;
    }
}

@media (max-width: 767px) {
    .sidebar {
        width: min(18rem, 85vw);
    }

    .form-section-grid,
    .form-section-grid.compact-3,
    .summary-strip,
    .a4-meta-grid--double,
    .a4-meta-grid--triple,
    .a4-financial-grid--double,
    .a4-financial-grid--triple {
        grid-template-columns: 1fr;
    }

    .form-section {
        padding: 16px;
    }

    .a4-document {
        padding: 20px;
    }

    .a4-meta-item,
    .a4-financial-item,
    .a4-summary-item {
        grid-template-columns: 120px 12px minmax(0, 1fr);
    }
}
