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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background: #1e3a5f;
    color: #fff;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.nav-brand { font-size: 18px; font-weight: 700; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 4px;
    font-size: 14px;
    transition: background .15s;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-logout { color: #fca5a5 !important; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; color: #1e3a5f; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background .15s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #6b7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 5px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert a { color: inherit; font-weight: 600; }

/* Table */
.table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
    border-collapse: collapse;
}
.table th {
    background: #f8fafc;
    text-align: left;
    padding: 10px 14px;
    font-size: 12px;
    text-transform: uppercase;
    color: #64748b;
    border-bottom: 2px solid #e2e8f0;
}
.table td {
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 1px solid #f1f5f9;
}
.table tr:hover { background: #f8fafc; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }
.actions form { display: inline; }

/* Search bar */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.search-input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}
.search-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.search-info { font-size: 13px; color: #6b7280; margin-bottom: 12px; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.page-current { pointer-events: none; }
.page-info { margin-left: 12px; font-size: 13px; color: #6b7280; }

/* Duplicate button */
.btn-duplicate { background: #7c3aed; color: #fff; }
.btn-duplicate:hover { background: #6d28d9; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.empty-state p { margin-bottom: 16px; color: #6b7280; }

/* Forms */
.form-card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}
.form-section {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
}
.form-section:last-of-type { border-bottom: none; }
.form-section h3 {
    font-size: 16px;
    color: #1e3a5f;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}
.form-group {
    margin-bottom: 12px;
    flex: 1;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-row {
    display: flex;
    gap: 16px;
}
.form-row.three-cols .form-group { flex: 1; }
.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
}

/* Login */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 24px rgba(0,0,0,.15);
}
.login-box h1 {
    text-align: center;
    color: #1e3a5f;
    margin-bottom: 4px;
}
.login-subtitle {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 24px;
}

/* ANAF lookup */
.input-with-btn {
    display: flex;
    gap: 8px;
}
.input-with-btn input { flex: 1; }
.input-with-btn .btn { white-space: nowrap; align-self: center; }
.anaf-status {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
}
.anaf-status.loading { color: #2563eb; }
.anaf-status.success { color: #16a34a; }
.anaf-status.error { color: #dc2626; }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-size: 13px;
}

/* Print: hide app chrome */
@media print {
    .navbar { display: none !important; }
    .footer { display: none !important; }
    .container { max-width: none; padding: 0; margin: 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
    .navbar { flex-direction: column; height: auto; padding: 12px; gap: 8px; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}
