* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #027ABB;
    --primary-dark: #015EA0;
    --success: #16a34a;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-100);
    min-height: 100vh;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* Login Section */
.login-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    padding: 10px;
}

.login-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-card h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 5px;
}

.login-card > p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.95rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 122, 187, 0.1);
}

.form-group input::placeholder {
    color: var(--gray-400);
}

.help-text {
    display: block;
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-primary:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

/* Dashboard */
.admin-container {
    min-height: 100vh;
}

.dashboard-section {
    min-height: 100vh;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.admin-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.admin-header h1 {
    font-size: 1.2rem;
    color: var(--gray-800);
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-back {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-back:hover { background: var(--gray-200); }

.btn-logout {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    background: var(--danger);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover { background: #b91c1c; }

/* Admin Content */
.admin-content {
    max-width: 700px;
    margin: 24px auto;
    padding: 0 20px;
}

.settings-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.card-header svg {
    color: var(--primary);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 20px;
}

.section-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--gray-100);
}

.section-label:first-child {
    margin-top: 0;
}

.section-desc {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 16px;
}

/* Logo Upload */
.logo-upload-area {
    text-align: center;
}

.file-input {
    display: block;
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--gray-300);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.file-input:hover {
    border-color: var(--primary);
}

.logo-preview {
    margin: 16px auto;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--gray-200);
    background: var(--gray-100);
}

.logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.mode-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: var(--gray-600);
}

.mode-option input {
    accent-color: var(--primary);
}

.mode-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(2, 122, 187, 0.08);
    color: var(--primary);
}

/* Background Watermark Preview */
.bg-preview-box {
    margin: 16px auto;
    width: 220px;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--gray-200);
    background: linear-gradient(135deg, #027ABB 0%, #015EA0 100%);
    position: relative;
}

.bg-preview-pattern {
    position: absolute;
    inset: -40%;
    background-repeat: repeat;
    background-image: none;
    background-size: 120px auto;
    transform: rotate(30deg);
}

.color-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-row input[type="color"] {
    width: 48px;
    height: 40px;
    padding: 2px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.color-row input[type="text"] {
    flex: 1;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    height: 6px;
    cursor: pointer;
}

.form-group label span {
    font-weight: 600;
    color: var(--primary);
}

/* Contacts List */
.contacts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.contact-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.contact-item .form-group {
    margin-bottom: 0;
}

.contact-item .form-group label {
    font-size: 0.75rem;
}

.contact-item .form-group input {
    padding: 8px 10px;
    font-size: 0.85rem;
}

.btn-remove-contact {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-remove-contact:hover { background: #b91c1c; }

.btn-add-contact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary);
    background: white;
    border: 2px dashed var(--primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-contact:hover {
    background: var(--primary);
    color: white;
}

/* Copyright Wrapper */
.copyright-wrapper {
    display: flex;
    gap: 8px;
}

.copyright-wrapper input {
    flex: 1;
}

.btn-unlock {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-200);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--gray-600);
}

.btn-unlock:hover {
    background: var(--gray-300);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.modal-content > p {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.modal-content input {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.95rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    outline: none;
    margin-bottom: 16px;
}

.modal-content input:focus {
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-cancel {
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--gray-100);
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-cancel:hover { background: var(--gray-200); }

.btn-confirm {
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

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

/* Textarea */
textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.95rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
    font-family: inherit;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 122, 187, 0.1);
}

code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary);
}

/* Template Preview */
.rich-editor {
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.rich-editor:focus-within {
    border-color: var(--primary);
}

.rich-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    flex-wrap: wrap;
}

.rich-toolbar button {
    min-width: 30px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.rich-toolbar button:hover {
    background: white;
    color: var(--primary);
    border-color: var(--gray-200);
}

.rich-toolbar .rich-sep {
    width: 1px;
    height: 20px;
    background: var(--gray-200);
    margin: 0 4px;
}

.rich-content {
    min-height: 140px;
    max-height: 320px;
    overflow-y: auto;
    padding: 12px 14px;
    background: white;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--gray-700);
    outline: none;
}

.rich-content:empty::before {
    content: attr(data-placeholder);
    color: var(--gray-400);
    font-style: italic;
}

.rich-content h3 {
    margin: 12px 0 4px;
    font-size: 1.1rem;
    color: var(--primary);
}

.rich-content ul {
    margin: 6px 0 6px 20px;
    padding: 0;
}

.rich-content li {
    margin-bottom: 4px;
}

.rich-content a {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 600;
}

.template-preview {
    margin-top: 16px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
    border: 1px solid var(--gray-200);
}

.template-preview strong {
    font-size: 0.85rem;
    color: var(--gray-700);
}

.preview-text {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--gray-600);
    line-height: 1.6;
}

/* Save Section */
.save-section {
    text-align: center;
    padding: 20px 0 40px;
}

.btn-save {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--success);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover { background: #15803d; }

.btn-save:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

.save-status {
    margin-top: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}

.save-status.success { color: var(--success); }
.save-status.error { color: var(--danger); }

/* Admin Nav Tabs */
.settings-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.settings-menu button {
    padding: 9px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 999px;
    background: white;
    color: var(--gray-600);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-menu button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.settings-menu button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.admin-nav {
    display: flex;
    gap: 8px;
    padding: 16px 24px 0;
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 73px;
    z-index: 99;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-500);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn svg {
    color: var(--gray-400);
}

.nav-btn:hover {
    color: var(--primary);
    background: var(--gray-50);
}

.nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(2, 122, 187, 0.06);
}

.nav-btn.active svg {
    color: var(--primary);
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

/* KRS Management */
.krs-content {
    max-width: 1100px;
}

.krs-toolbar {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.krs-toolbar .form-group {
    margin-bottom: 0;
}

.krs-search-wrap {
    flex: 1;
    min-width: 200px;
}

.krs-toolbar select {
    padding: 10px 12px;
    font-size: 0.85rem;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    background: white;
    outline: none;
    color: var(--gray-700);
    cursor: pointer;
}

.krs-toolbar select:focus {
    border-color: var(--primary);
}

.krs-refresh-btn {
    width: auto;
    padding: 10px 16px;
    white-space: nowrap;
}

.krs-summary {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.summary-chip {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 0.78rem;
    color: var(--gray-600);
}

.summary-chip b {
    color: var(--gray-800);
}

.summary-chip.green b {
    color: var(--success);
}

.summary-chip.red b {
    color: var(--danger);
}

.krs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--gray-500);
    font-size: 0.9rem;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.krs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.krs-table thead th {
    background: var(--gray-50);
    padding: 7px 9px;
    text-align: left;
    color: var(--gray-600);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.krs-table tbody td {
    padding: 6px 9px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    white-space: nowrap;
}

.krs-table tbody tr:hover {
    background: var(--gray-50);
}

.krs-table tbody tr:last-child td {
    border-bottom: none;
}

.krs-table td:nth-child(2) {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.krs-table td:nth-child(3) {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.req-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 9px;
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    min-width: 18px;
}

.req-badge.ok {
    background: #dcfce7;
    color: var(--success);
}

.req-badge.no {
    background: #fee2e2;
    color: var(--danger);
}

.req-badge.out {
    background: var(--gray-200);
    color: var(--gray-500);
}

.btn-buka-krs {
    display: inline-block;
    padding: 6px 10px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s;
}

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

.btn-krs-paksa {
    display: inline-block;
    padding: 6px 10px;
    background: #d97706;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-krs-paksa:hover {
    background: #b45309;
}

.btn-danger {
    background: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

.warning-text {
    color: var(--danger) !important;
    font-weight: 600;
}

#krsPaksaModal .modal-content input {
    margin-top: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
}

#krsPaksaModal .modal-content input:focus {
    border-color: var(--danger);
}

.krs-note {
    color: var(--gray-400);
    font-size: 0.72rem;
}

/* Sticky action column - button selalu terlihat */
.krs-table th:last-child,
.krs-table td:last-child {
    position: sticky;
    right: 0;
    background: #fff;
    z-index: 1;
    box-shadow: -4px 0 6px -4px rgba(0, 0, 0, 0.15);
}

.krs-table thead th:last-child {
    background: var(--gray-50);
}

.krs-table tbody tr:hover td:last-child {
    background: var(--gray-50);
}

.history-empty {
    text-align: center;
    color: var(--gray-400);
    font-size: 0.85rem;
    padding: 16px 0;
}

/* Responsive */
@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .admin-header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .admin-content {
        padding: 0 12px;
    }

    .card-body {
        padding: 16px;
    }
}
