:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --secondary: #64748b;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0284c7;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar: #0f172a;
    --sidebar-text: #cbd5e1;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.auth-card-wide {
    max-width: 560px;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.auth-links {
    margin-top: 16px;
    text-align: center;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-link {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--sidebar-text);
    margin-bottom: 4px;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.sidebar-link.small {
    font-size: 13px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info {
    margin-bottom: 8px;
}

.user-info strong,
.user-info small {
    display: block;
}

.app-main {
    margin-left: 260px;
    flex: 1;
    min-width: 0;
}

.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h2 {
    margin: 0;
    font-size: 20px;
}

.app-content {
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
    padding: 16px 0;
    margin: -24px -24px 24px -24px;
    padding-left: 24px;
    padding-right: 24px;
}

.page-header h1 {
    margin: 0 0 4px;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card-highlight {
    border-color: var(--primary);
}

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    font-size: 18px;
}

.card-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s;
}

.password-toggle:hover {
    color: var(--text);
}

.password-toggle svg {
    display: block;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
background: var(--primary);
color: #fff;
}

.btn-secondary:hover {
background: var(--primary-dark);
text-decoration: none;
}

.btn-info {
background: #0284c7;
color: #fff;
}

.btn-info:hover {
background: #0369a1;
text-decoration: none;
}

.btn-success {
background: #059669;
color: #fff;
}

.btn-success:hover {
background: #047857;
text-decoration: none;
}

.btn-warning {
background: #d97706;
color: #fff;
}

.btn-warning:hover {
background: #b45309;
text-decoration: none;
}

.btn-danger {
background: #dc2626;
color: #fff;
}

.btn-danger:hover {
background: #b91c1c;
text-decoration: none;
}

.btn-secondary {
background: #e2e8f0;
color: var(--text);
}

.btn-block {
    width: 100%;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

.alert-info {
    background: #e0f2fe;
    color: #075985;
    word-break: break-all;
}

.text-muted {
    color: var(--text-muted);
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.table th {
    font-size: 13px;
    color: var(--text-muted);
}

.coming-soon {
    text-align: center;
    padding: 60px 20px;
}

.coming-soon h2 {
    margin-bottom: 8px;
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .app-wrapper {
        flex-direction: column;
    }

    .app-main {
        margin-left: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

.page-header.flex-header,
.flex-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar input {
    min-width: 220px;
}

.align-end {
    display: flex;
    align-items: end;
}

.actions {
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.link-btn.danger {
    color: var(--danger);
}

.preview-box {
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.invoice-lines-header {
    margin: 24px 0 12px;
}

.invoice-add-line {
    margin: 12px 0 20px;
}

.invoice-lines-table .line-number {
    width: 48px;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
}

.invoice-lines-table input,
.invoice-lines-table select {
    min-width: 90px;
}

.invoice-totals {
    margin: 20px 0;
    max-width: 420px;
    margin-left: auto;
}

.invoice-totals div {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.checkbox-group label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input {
    width: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user {
    font-size: 13px;
    color: var(--text-muted);
}

.admin-page {
    min-height: 100vh;
    background: var(--bg);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: #0f172a;
    color: #fff;
}

.admin-brand strong {
    display: block;
    font-size: 18px;
}

.admin-brand small {
    color: #94a3b8;
}

.admin-nav {
    display: flex;
    gap: 16px;
}

.admin-nav a {
    color: #cbd5e1;
}

.admin-nav a:hover {
    color: #fff;
    text-decoration: none;
}

.admin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.draft-row {
    background-color: #fee2e2;
}

.draft-row td {
    color: #991b1b;
}

.table tbody tr {
    border-bottom: 2px solid #3b82f6;
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.table tbody tr:nth-child(even) td {
    color: #1e293b;
}

.table tbody tr:nth-child(odd) td {
    color: #0f172a;
}

.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: #059669;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.toast-notification.toast-error {
    background: #dc2626;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.department-section {
    margin-bottom: 30px;
}

.department-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
    color: #374151;
}

/* Modal Styles */
.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;
}

.modal-content {
    background: var(--card);
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}
