:root {
    --bg-body: #f5f6f7;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-topbar: #ffffff;
    --border-soft: #e0e0e0;
    --text-main: #222222;
    --text-muted: #777777;
    --primary: #0f70b7;
    --primary-soft: #e3f2fd;
    --accent: #94c11f;
    --danger: #c0392b;
    --warning: #f1c40f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
}

/* Layout */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
}

.sidebar.show {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-soft);
}

.sidebar-logo img {
    height: 36px;
}

.sidebar-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
}

.sidebar-menu {
    padding: 8px 0;
}

.sidebar-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: var(--text-main);
    border-left: 3px solid transparent;
}

.sidebar-menu li.active > a {
    background: var(--primary-soft);
    border-left-color: var(--primary);
}

.sidebar-menu .icon img {
    width: 18px;
    height: 18px;
    margin-right: 10px;
}

/* Topbar & main */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    z-index: 40;
}

.topbar-left {
    display: flex;
    align-items: center;
}

.topbar-title {
    font-weight: 600;
    margin-left: 8px;
}

.icon-button {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
}

.icon-button img {
    width: 22px;
    height: 22px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.notification-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notification-icon img {
    width: 20px;
    height: 20px;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    padding: 1px 5px;
    font-size: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    text-align: right;
}

.logout-link {
    font-size: 12px;
    color: var(--primary);
}

/* Main content area */

.main-content {
    margin-top: 56px;
    padding: 12px;
    width: 100%;
}

/* Page header */

.page-header {
    margin-bottom: 16px;
}

.page-header h1 {
    margin: 0;
    font-size: 20px;
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

/* Cards */

.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.card-primary {
    border-left: 4px solid var(--primary);
}

.card-success {
    border-left: 4px solid var(--accent);
}

.card-warning {
    border-left: 4px solid var(--warning);
}

.card-neutral {
    border-left: 4px solid #999;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.card-main-number {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.card-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.clickable {
    cursor: pointer;
}

/* Forms */

.form-card {
    background: var(--bg-card);
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.form-row {
    display: flex;
    flex-direction: column;
}

.form-row label {
    font-size: 12px;
    margin-bottom: 3px;
}

.form-row input,
.form-row select,
.form-row textarea {
    padding: 7px 9px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 13px;
}

.form-row.full {
    grid-column: 1 / -1;
}

/* Buttons */

.btn-primary,
.btn-secondary,
.btn-light,
.btn-danger,
.btn-warning {
    display: inline-block;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 13px;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-secondary {
    background: #f0f0f0;
    color: var(--text-main);
}

.btn-light {
    background: #f9f9f9;
    color: var(--text-main);
    border: 1px solid var(--border-soft);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-icon {
    padding: 2px 6px;
    font-size: 14px;
    border-radius: 999px;
}

/* Alerts */

.alert {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 8px;
}

.alert-success {
    background: #e6f7e9;
    color: #1b5e20;
}

.alert-error {
    background: #ffe5e5;
    color: #b70000;
}

/* Tables */

.table-card {
    background: var(--bg-card);
    padding: 10px 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
    margin-bottom: 14px;
}

.table-card-header h2 {
    margin: 0 0 8px 0;
    font-size: 14px;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table thead th {
    background: #f0f0f0;
    padding: 6px;
    border: 1px solid #ddd;
    text-align: left;
}

.data-table tbody td {
    border: 1px solid #eee;
    padding: 6px;
    vertical-align: top;
}

.data-table tbody tr:nth-child(odd) {
    background: #fafafa;
}

.totals-row {
    background: #eef6ff;
    font-weight: 600;
}

.horizontal-scroll {
    overflow-x: auto;
}

/* Employee avatars */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 999px;
    object-fit: cover;
}

.avatar.placeholder,
.avatar-large.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ddd;
    color: #555;
}

/* Toolbar / filters */

.toolbar {
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-bar {
    margin: 10px 0;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.filter-form label {
    display: flex;
    flex-direction: column;
    font-size: 11px;
}

/* Pagination */

.pagination {
    margin-top: 8px;
}

.page-link {
    display: inline-block;
    padding: 3px 6px;
    margin-right: 3px;
    font-size: 12px;
    border-radius: 4px;
    border: 1px solid var(--border-soft);
    color: var(--text-main);
}

.page-link.active {
    background: var(--primary);
    color: #fff;
}

/* Notes */

.note-unread {
    background: #fdf8e4;
}

.dot-green {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 999px;
    display: inline-block;
}

/* Loading overlay */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 4px solid #ddd;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Clickable rows */

.clickable-row {
    cursor: pointer;
}

/* Footer */

.footer {
    border-top: 1px solid var(--border-soft);
    padding: 8px 12px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-card);
    margin-top: 14px;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
}

/* Desktop layout */

@media (min-width: 900px) {
    .sidebar {
        transform: none;
    }
    .main-content {
        margin-left: 260px;
    }
}

/* Mobile: hide underline on hover (تم بالفعل في layout_header) */
a { text-decoration: none; }
a:hover { text-decoration: none; }
