/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --primary: #004835;
    --primary-light: #006b4f;
    --primary-dark: #003425;
    --secondary: #f5f5f7;
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f7;
    --gray-200: #e8e8ed;
    --gray-300: #d2d2d7;
    --gray-400: #a1a1a6;
    --gray-500: #6e6e73;
    --gray-600: #424245;
    --gray-700: #2c2c2e;
    --gray-800: #1d1d1f;
    --green-light: #ecfdf5;
    --green-badge: #059669;
    --blue-light: #eff6ff;
    --blue-badge: #2563eb;
    --yellow-light: #fffbeb;
    --yellow-badge: #d97706;
    --red-light: #fef2f2;
    --red-badge: #dc2626;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
    --transition: 150ms ease;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--secondary);
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* ── Auth Pages ───────────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo img { height: 48px; width: auto; }

.auth-card h1 {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-form .form-group { margin-bottom: 1rem; }

.auth-footer {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    margin-top: 2rem;
}

/* ── Form Elements ────────────────────────────────────────────────────────── */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--white);
    color: var(--gray-800);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 72, 53, 0.1);
}

input::placeholder, textarea::placeholder { color: var(--gray-400); }

.input-readonly {
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: default;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 0.25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input[type="checkbox"] { width: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
}

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

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-300); }

.btn-full { width: 100%; margin-top: 0.5rem; }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.82rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--gray-200); color: var(--primary); }
.btn-icon-danger:hover { background: var(--red-light); color: var(--red-badge); }
.btn-contact:hover { background: var(--primary); color: var(--white); }

.action-buttons { display: flex; gap: 0.25rem; justify-content: center; }

/* ── App Layout ───────────────────────────────────────────────────────────── */
.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo { height: 32px; width: auto; }

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--gray-300);
}

.header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-700);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-user {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
}

.header-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--gray-500);
    transition: all var(--transition);
}
.header-link:hover { background: var(--gray-100); color: var(--primary); }

.header-link-text {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.header-link-text:hover { background: var(--gray-100); color: var(--primary); }

.app-main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.app-footer {
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--gray-400);
    font-size: 0.8rem;
    border-top: 1px solid var(--gray-200);
}

/* ── Flash Messages ───────────────────────────────────────────────────────── */
.flash-container { padding: 1rem 2rem 0; max-width: 1200px; margin: 0 auto; width: 100%; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.alert-error { background: var(--red-light); color: var(--red-badge); border: 1px solid #fecaca; }
.alert-success { background: var(--green-light); color: var(--green-badge); border: 1px solid #a7f3d0; }
.alert-warning { background: var(--yellow-light); color: var(--yellow-badge); border: 1px solid #fde68a; }

/* ── Stats Cards ──────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-green .stat-icon { background: var(--green-light); color: var(--green-badge); }
.stat-blue .stat-icon { background: var(--blue-light); color: var(--blue-badge); }
.stat-gray .stat-icon { background: var(--gray-100); color: var(--gray-500); }
.stat-red .stat-icon { background: var(--red-light); color: var(--red-badge); }

.stat-content { display: flex; flex-direction: column; }

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.15rem;
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-500);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-btn:hover { color: var(--gray-700); background: var(--gray-50); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot-yellow { background: var(--yellow-badge); }
.dot-blue { background: var(--blue-badge); }
.dot-green { background: var(--green-badge); }
.dot-red { background: var(--red-badge); }

.tab-count {
    background: var(--gray-100);
    color: var(--gray-500);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.tab-btn.active .tab-count {
    background: rgba(0, 72, 53, 0.1);
    color: var(--primary);
}

.tab-panel { display: none; padding: 0; }
.tab-panel.active { display: block; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.cases-table-wrap { overflow-x: auto; }

.cases-table {
    width: 100%;
    border-collapse: collapse;
}

.cases-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.cases-table td {
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.cases-table tbody tr:hover { background: var(--gray-50); }
.cases-table tfoot td {
    background: var(--gray-50);
    border-top: 2px solid var(--gray-200);
    font-size: 0.9rem;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.cell-subject { font-weight: 500; color: var(--gray-800); }
.cell-amount { font-variant-numeric: tabular-nums; font-weight: 600; }

.table-note {
    padding: 0.75rem 1rem;
    font-size: 0.78rem;
    color: var(--gray-400);
    font-style: italic;
    border-top: 1px solid var(--gray-100);
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.badge-yellow { background: var(--yellow-light); color: var(--yellow-badge); }
.badge-blue { background: var(--blue-light); color: var(--blue-badge); }
.badge-green { background: var(--green-light); color: var(--green-badge); }
.badge-red { background: var(--red-light); color: var(--red-badge); }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
    padding: 3rem 2rem;
    text-align: center;
    color: var(--gray-400);
}
.empty-state svg { margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Section ──────────────────────────────────────────────────────────────── */
.section { margin-bottom: 2rem; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

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

.section .cases-table-wrap {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

/* ── Form Card ────────────────────────────────────────────────────────────── */
.form-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    max-width: 640px;
}

.form-card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--gray-800);
}

.form-description {
    font-size: 0.88rem;
    color: var(--gray-500);
    margin: -1rem 0 1.5rem;
}

.admin-form .form-group { margin-bottom: 1.25rem; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    justify-content: flex-end;
}

/* ── Import Page ──────────────────────────────────────────────────────────── */
.import-form .form-card { max-width: none; }

.import-files {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.import-file-card {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    transition: all var(--transition);
}
.import-file-card:hover { border-color: var(--primary); }

.import-file-icon {
    color: var(--gray-400);
    margin-bottom: 0.75rem;
}

.import-file-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.import-file-card p {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.import-file-card input[type="file"] {
    display: none;
}

.file-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: var(--white) !important;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition);
}
.file-label:hover { background: var(--primary-light); }

.file-name {
    display: block;
    font-size: 0.78rem;
    color: var(--gray-400);
    margin-top: 0.5rem;
}
.file-name.file-selected { color: var(--green-badge); font-weight: 500; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 200ms ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    font-size: 1.3rem;
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }

.modal-body { padding: 1.5rem; }
.modal-body .form-group { margin-bottom: 1rem; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
    .import-files { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .app-header { padding: 0 1rem; }
    .app-main { padding: 1rem; }
    .header-title { display: none; }
    .header-divider { display: none; }
    .header-user { display: none; }
    .stats-grid { grid-template-columns: 1fr; }
    .stats-grid-3 { grid-template-columns: 1fr; }
    .form-card { padding: 1.25rem; }
    .auth-card { padding: 1.5rem; }
    .tab-btn { padding: 0.75rem 0.75rem; font-size: 0.78rem; }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
    .stat-value { font-size: 1.2rem; }
}

/* ── Password Created Page ────────────────────────────────────────────────── */

.password-result {
    text-align: center;
    padding: 1rem 0;
}

.password-icon {
    margin-bottom: 1rem;
}

.password-result h2 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
}

.password-subtitle {
    color: var(--gray-500);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.password-details {
    text-align: left;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.password-field {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
}

.password-field + .password-field {
    border-top: 1px solid var(--gray-200);
}

.password-field label {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 500;
}

.password-field span {
    font-weight: 600;
    color: var(--gray-800);
    overflow-wrap: break-word;
    word-break: normal;
}

.password-highlight {
    background: var(--green-light);
    margin: 0.5rem -1.25rem;
    padding: 0.75rem 1.25rem !important;
    border-radius: var(--radius-sm);
}

.password-highlight span {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 1.1rem;
    color: var(--primary);
    letter-spacing: 0.5px;
}

.password-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--yellow-light);
    color: var(--yellow-badge);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-align: left;
}

.password-warning svg {
    flex-shrink: 0;
}
