:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #172033;
    --muted: #6b778c;
    --line: #e4e9f1;
    --primary: #2457e6;
    --primary-dark: #1743bc;
    --success: #14845b;
    --success-bg: #e9f8f1;
    --danger: #c83d4d;
    --danger-bg: #fff0f2;
    --warning: #a66b00;
    --warning-bg: #fff7df;
    --sidebar: #111a2e;
    --sidebar-2: #17233c;
    --shadow: 0 12px 35px rgba(21, 37, 68, .08);
    --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
code { background: #edf1f7; padding: 2px 6px; border-radius: 6px; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 258px; background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2)); color: white; padding: 24px 16px; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark, .auth-logo { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 900; letter-spacing: -.5px; background: linear-gradient(135deg, #5b8cff, #2b55d4); box-shadow: 0 10px 24px rgba(44, 86, 216, .35); }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: #9dadcc; margin-top: 3px; }
.sidebar nav { display: grid; gap: 7px; margin-top: 24px; }
.sidebar nav a { padding: 12px 13px; border-radius: 11px; color: #b9c5dc; display: flex; align-items: center; gap: 12px; transition: .18s ease; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.09); }
.sidebar nav a.active { box-shadow: inset 3px 0 0 #6e96ff; }
.sidebar-footer { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 5px; }
.sidebar-footer small { color: #8796b5; }
.sidebar-footer a { color: #88a7ff; margin-top: 7px; font-size: 14px; }
.main-content { margin-left: 258px; width: calc(100% - 258px); min-width: 0; }
.topbar { height: 92px; padding: 20px 32px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: -.6px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.menu-button { display: none; border: 0; background: #eef2f8; width: 42px; height: 42px; border-radius: 10px; cursor: pointer; }
.content { padding: 28px 32px 48px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-body { padding: 22px; }
.card-header { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.card-header h2, .card-header h3 { margin: 0; font-size: 17px; }
.stat-card { padding: 22px; display: flex; justify-content: space-between; gap: 20px; align-items: center; }
.stat-card small { display: block; color: var(--muted); font-weight: 600; }
.stat-card strong { display: block; font-size: 31px; margin-top: 7px; letter-spacing: -1px; }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: #edf2ff; color: var(--primary); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.button { border: 0; padding: 10px 15px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 14px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { background: #edf1f7; color: #34415a; }
.button-success { background: var(--success); color: white; }
.button-danger { background: var(--danger); color: white; }
.button-outline { background: white; border: 1px solid var(--line); color: #34415a; }
.button-small { padding: 7px 10px; border-radius: 8px; font-size: 12px; }
.button-block { width: 100%; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 14px; }
th { color: var(--muted); background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fbfcfe; }
.actions { display: flex; gap: 7px; align-items: center; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: #eef1f5; color: #667085; }
.alert { padding: 13px 15px; border-radius: 11px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #c7eddc; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #ffd2d8; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #f4dea2; }
form label { display: grid; gap: 7px; color: #44506a; font-weight: 700; font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid #d8deea; background: white; color: var(--text); border-radius: 10px; padding: 10px 12px; outline: none; min-height: 42px; }
input:focus, select:focus, textarea:focus { border-color: #7c9bf0; box-shadow: 0 0 0 3px rgba(36,87,230,.1); }
textarea { min-height: 100px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.device-card { padding: 20px; }
.device-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.device-title { display: flex; gap: 14px; }
.device-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: #eef3ff; color: var(--primary); font-size: 23px; }
.device-title h3 { margin: 1px 0 4px; }
.device-meta { margin-top: 18px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; color: var(--muted); font-size: 13px; }
.device-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.note { margin-top: 18px; padding: 13px; border-radius: 10px; background: #f3f6fb; color: #5d6a80; font-size: 13px; line-height: 1.55; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at top left, #e7edff 0, #f5f7fb 42%, #eef3fb 100%); }
.auth-card { width: min(430px, 100%); background: white; border: 1px solid var(--line); box-shadow: 0 25px 70px rgba(31, 51, 91, .14); border-radius: 22px; padding: 34px; }
.install-card { width: min(560px, 100%); }
.auth-logo { color: white; margin-bottom: 22px; }
.auth-card h1 { margin: 0 0 8px; letter-spacing: -.7px; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.auth-card form { display: grid; gap: 15px; }
.kpi-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.kpi-line:last-child { border-bottom: 0; }
.progress { height: 9px; border-radius: 99px; overflow: hidden; background: #edf1f6; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.pagination { display: flex; gap: 7px; padding: 16px; justify-content: flex-end; }
.pagination a, .pagination span { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; display: grid; place-items: center; border: 1px solid var(--line); background: white; font-size: 13px; }
.pagination .current { background: var(--primary); color: white; border-color: var(--primary); }
@media (max-width: 1050px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 780px) {
    .sidebar { transform: translateX(-100%); transition: .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.2); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; width: 100%; }
    .menu-button { display: block; }
    .topbar { padding: 18px; height: 82px; }
    .topbar h1 { font-size: 21px; }
    .content { padding: 20px 16px 40px; }
    .grid-4, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .toolbar { align-items: stretch; }
    .toolbar .filters { width: 100%; }
    .toolbar .filters > * { flex: 1 1 140px; }
}

/* Payroll and monthly schedule additions */
.day-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.check-chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; }
.check-chip input { width: auto; min-height: auto; margin: 0; }
.calculation-guide { display: grid; gap: 0; }
.calculation-guide > div { display: grid; gap: 5px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.calculation-guide > div:last-child { border-bottom: 0; }
.calculation-guide strong { color: var(--text); }
.calculation-guide span { color: var(--muted); line-height: 1.55; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.money-stat { font-size: 21px !important; letter-spacing: -.3px !important; }
.dense-table th, .dense-table td { padding: 10px 11px; font-size: 12px; }
tfoot th, tfoot td { background: #f1f5fb; font-weight: 800; border-top: 2px solid #d7dfeb; }
.toolbar .actions { flex-wrap: wrap; }
@media (max-width: 780px) {
    .day-checkboxes { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
    .money-stat { font-size: 18px !important; }
}

/* Language switch and RTL support */
.topbar-title { min-width: 0; }
.language-switch { margin-left: auto; display: inline-flex; gap: 5px; padding: 4px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 11px; }
.language-switch a { min-width: 34px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.language-switch a.active { background: var(--primary); color: white; }
.currency-input-group { display: grid; grid-template-columns: minmax(0, 1fr) 105px; gap: 8px; }
.currency-stack { display: grid; gap: 4px; }
.currency-stack strong { font-size: 18px; }
html[dir="rtl"] body { font-family: Tahoma, Arial, "Segoe UI", sans-serif; }
html[dir="rtl"] .sidebar { inset: 0 0 0 auto; }
html[dir="rtl"] .main-content { margin-left: 0; margin-right: 258px; }
html[dir="rtl"] .sidebar nav a.active { box-shadow: inset -3px 0 0 #6e96ff; }
html[dir="rtl"] th, html[dir="rtl"] td { text-align: right; }
html[dir="rtl"] .language-switch { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .header .right, html[dir="rtl"] .footer .right { text-align: left; }
@media (max-width: 780px) {
    html[dir="rtl"] .sidebar { transform: translateX(100%); }
    html[dir="rtl"] .sidebar.open { transform: translateX(0); }
    html[dir="rtl"] .main-content { margin-right: 0; }
    .language-switch a { min-width: 31px; }
    .currency-input-group { grid-template-columns: minmax(0, 1fr) 92px; }
}
.auth-language { position: fixed; top: 18px; right: 18px; display: flex; gap: 6px; background: white; border: 1px solid var(--line); border-radius: 11px; padding: 5px; box-shadow: var(--shadow); z-index: 5; }
.auth-language a { padding: 7px 10px; border-radius: 8px; font-size: 12px; font-weight: 800; color: var(--muted); }
.auth-language a:hover { background: var(--surface-2); color: var(--primary); }
html[dir="rtl"] .auth-language { right: auto; left: 18px; }
