/* Modern UI: clean, responsive, and interactive */
* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  overflow-y: scroll;
}
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.55;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Theme */
:root {
  --bg: #0b0f14;
  --surface-1: #0f151c;
  --surface-2: #121a23;
  --surface-3: #16212c;
  --text-1: #e7edf3;
  --text-2: #a8b0b9;
  --brand: #7c9cff;
  --brand-2: #3a7bff;
  --ok: #2ecc71;
  --warn: #f5a524;
  --danger: #ef4444;
  --muted: #2a3542;
  --border: #233040;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --radius: 12px;
}
[data-theme="light"] {
  --bg: #f6f8fb;
  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #f3f6fb;
  --text-1: #0b1220;
  --text-2: #5b6675;
  --brand: #355cff;
  --brand-2: #2248e6;
  --ok: #2e7d32;
  --warn: #b36b00;
  --danger: #c62828;
  --muted: #e8edf5;
  --border: #e1e7ef;
  --shadow: 0 8px 24px rgba(16,24,40,.08);
}

/* Layout */
.layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  border-right: 1px solid var(--border);
  padding: 20px 16px; gap: 16px; display: flex; flex-direction: column;
}
.sidebar .brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 8px; text-align: center; cursor: pointer; border-radius: 10px; transition: background 0.15s ease; }
.sidebar .brand:hover { background: var(--surface-3); }
.brand img { height: 48px; width: auto; max-width: 180px; object-fit: contain; }
.brand .title { font-weight: 700; color: var(--text-1); letter-spacing: .2px; font-size: 14px; }
.nav { display: grid; gap: 4px; }
.nav a { text-decoration: none; color: var(--text-2); padding: 10px 12px; border-radius: 10px; display: flex; gap: 10px; align-items: center; border: 1px solid transparent; }
.nav a:hover { background: var(--surface-3); border-color: var(--border); color: var(--text-1); }
.nav a.is-active { background: rgba(124,156,255,.12); border-color: rgba(124,156,255,.3); color: var(--brand); }

/* User Profile Dropdown */
.user-profile { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); position: relative; }
.user-info { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background 0.15s ease; background: var(--surface-3); border: 1px solid var(--border); }
.user-info:hover { background: var(--surface-2); border-color: var(--brand); }
.user-email { color: var(--text-1); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.dropdown-arrow { color: var(--text-2); font-size: 10px; margin-left: 8px; transition: transform 0.2s ease; }
.user-dropdown { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 -8px 24px rgba(0,0,0,.35); margin-bottom: 8px; opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.2s ease; z-index: 50; }
.user-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item { width: 100%; padding: 12px 16px; background: transparent; border: none; color: var(--text-1); font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: background 0.15s ease; border-radius: 8px; margin: 4px; }
.dropdown-item:hover { background: var(--surface-3); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: color-mix(in oklab, var(--danger) 15%, var(--surface-2)); }

.content { position: relative; display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(0,0,0,0); backdrop-filter: saturate(140%) blur(8px); padding: 12px 20px; display: flex; align-items: center; gap: 12px; }
.topbar.elevated { box-shadow: var(--shadow); background: color-mix(in oklab, var(--surface-1) 88%, transparent); border-bottom: 1px solid var(--border); }
.topbar .sidebar-toggle { display: none; }
.topbar .spacer { flex: 1; }
.topbar .theme-toggle { background: var(--surface-3); border: 1px solid var(--border); color: var(--text-1); padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.topbar .theme-toggle:hover { border-color: var(--brand); color: var(--brand); }
@media (max-width: 980px) { 
  .sidebar { position: fixed; left: -100%; width: 88%; max-width: 320px; z-index: 30; transition: left .25s ease; }
  body.sidebar-open .sidebar { left: 0; }
  .topbar .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; height: 36px; width: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-3); color: var(--text-1); }
  .layout { grid-template-columns: 1fr; }
}

main.page { padding: 20px; }
.container { max-width: 1200px; margin-inline: auto; }

/* Cards & sections */
.section { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.section + .section { margin-top: 20px; }
.section-title { margin: 0 0 12px; color: var(--text-1); font-size: 18px; font-weight: 700; }

.dashboard-header { display: flex; align-items: center; gap: 12px; justify-content: space-between; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.dashboard-header h2 { margin: 0; font-size: 22px; color: var(--text-1); }
.dashboard-header .subtitle { margin: 0; color: var(--text-2); }
.subtitle { color: var(--text-2); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; }
.stat-card h3, .stat-card h4 { margin: 0; color: var(--text-2); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat-number { font-size: 40px; margin-top: 12px; color: var(--text-1); font-weight: 800; letter-spacing: -.02em; }
.stat-card-warning { border-left: 4px solid var(--warn); }
.stat-card-info { border-left: 4px solid var(--brand); }
.stat-card-success { border-left: 4px solid var(--ok); }

/* Movement cards */
.movement-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.movement-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px; transition: transform .15s ease, border-color .15s ease; }
.movement-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.movement-card.overdue { border-left: 4px solid var(--danger); }
.movement-header { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.movement-card h4 { margin: 0 0 8px; font-size: 16px; color: var(--text-1); }
.movement-details p { margin: 4px 0; color: var(--text-2); font-size: 13px; }

/* Badges */
.badge { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-3); color: var(--text-1); text-align: center; }
.badge-status { background: transparent; }
.badge-onboarding { background: rgba(46, 204, 113, .12); color: #37d07d; border-color: rgba(46, 204, 113, .35); }
.badge-job_change { background: rgba(124, 156, 255, .12); color: var(--brand); border-color: rgba(124, 156, 255, .35); }
.badge-immediate_termination { background: rgba(239, 68, 68, .18); color: #ff5252; border-color: rgba(239, 68, 68, .45); }
.badge-planned_termination { background: rgba(245, 165, 36, .12); color: var(--warn); border-color: rgba(245, 165, 36, .35); }
.badge-other { background: rgba(168, 176, 185, .12); color: var(--text-2); border-color: rgba(168,176,185,.35); }
.badge-scheduled { background: rgba(124, 156, 255, .12); color: var(--brand); border-color: rgba(124,156,255,.35); }
.badge-completed { background: rgba(46, 204, 113, .12); color: #37d07d; border-color: rgba(46,204,113,.35); }
.badge-not_completed { background: rgba(239, 68, 68, .12); color: #ef4444; border-color: rgba(239,68,68,.35); }
.badge-cancelled { background: rgba(168, 176, 185, .12); color: var(--text-2); border-color: rgba(168,176,185,.35); }

/* Tables */
.table-container { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-1); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-1); text-align: left; z-index: 1; }
tbody tr:hover { background: var(--surface-3); }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:hover { background: var(--surface-3); }
.th-sortable { cursor: pointer; user-select: none; }
th[data-sort="asc"]::after { content: ' \25B2'; color: var(--brand); }
th[data-sort="desc"]::after { content: ' \25BC'; color: var(--brand); }
.view-field { padding: 10px; background: var(--surface-3); border-radius: 8px; color: var(--text-1); min-height: 20px; }

/* Filters & Inputs */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 16px; }
.filters label { color: var(--text-2); font-size: 13px; }
.filters select, .filters input { appearance: none; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-1); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.filters select:focus, .filters input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-1); font-weight: 600; cursor: pointer; transition: transform .06s ease, border-color .15s ease; box-shadow: var(--shadow); text-decoration: none; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--surface-2); color: var(--brand); border: 1px solid var(--border); }
.btn-primary:hover { background: rgba(124, 156, 255, .08); border-color: var(--brand); }
.btn-secondary { background: var(--surface-3); }
.btn-danger { background: color-mix(in oklab, var(--danger) 22%, var(--surface-2)); border-color: color-mix(in oklab, var(--danger) 40%, var(--border)); color: #ffdfe0; }
.btn-sm { padding: 6px 10px; font-size: 12px; box-shadow: none; }

/* Top nav links in sidebar replacement */
.nav-links { list-style: none; padding: 0; margin: 0; }
.nav-links li { margin: 0; }

/* Status text helpers */
.loading, .no-data, .error { text-align: center; padding: 24px; color: var(--text-2); }
.error { color: var(--danger); }

/* Modal */
.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.modal-content { background: var(--surface-1); margin: 5% auto; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); width: 90%; max-width: 600px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); animation: modalSlideIn 0.2s ease; }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; color: var(--text-1); font-size: 20px; }
.modal-header .close { color: var(--text-2); font-size: 32px; font-weight: 300; cursor: pointer; line-height: 1; transition: color 0.15s ease; }
.modal-header .close:hover { color: var(--danger); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* Forms */
.form-group { margin: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--text-1); font-weight: 600; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; color: var(--text-1); font-size: 14px; font-family: inherit; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 20%, transparent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input[type="date"] { appearance: none; -webkit-appearance: none; }
.form-group small { display: block; margin-top: 6px; font-size: 12px; color: var(--text-2); line-height: 1.4; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; background: var(--surface-1); padding: 8px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.tab-button { flex: 1; padding: 12px 20px; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--text-2); font-weight: 600; cursor: pointer; transition: all 0.15s ease; }
.tab-button:hover { background: var(--surface-3); color: var(--text-1); }
.tab-button.active { background: var(--brand); color: white; border-color: transparent; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Settings Page */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.integration-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-top: 16px; }
.integration-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.integration-header h4 { margin: 0 0 8px; color: var(--text-1); font-size: 18px; }
.integration-form { display: grid; gap: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.text-muted { color: var(--text-2); font-size: 14px; }

/* Info Grid */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 16px; }
.info-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.info-label { color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; font-weight: 600; }
.info-value { color: var(--text-1); font-size: 20px; font-weight: 700; }

/* Data Management */
.data-management-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.management-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.management-card h4 { margin: 0 0 8px; color: var(--text-1); font-size: 16px; }
.management-card p { margin: 8px 0 16px; }

/* Checkbox */
.checkbox-label { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text-1); font-weight: normal; }
.checkbox-label input[type="checkbox"] { width: auto; cursor: pointer; }

/* Login Page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); padding: 20px; }
.login-container { width: 100%; max-width: 440px; }
.login-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { height: 60px; width: auto; max-width: 200px; object-fit: contain; margin-bottom: 16px; }
.login-header h1 { margin: 0 0 8px; color: var(--text-1); font-size: 28px; font-weight: 700; }
.login-form { margin-bottom: 24px; }
.login-divider { position: relative; text-align: center; margin: 24px 0; }
.login-divider::before { content: ''; position: absolute; left: 0; top: 50%; width: 100%; height: 1px; background: var(--border); }
.login-divider span { position: relative; background: var(--surface-1); padding: 0 12px; color: var(--text-2); font-size: 12px; font-weight: 600; }
.login-footer { text-align: center; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.theme-toggle-login { background: var(--surface-3); border: 1px solid var(--border); color: var(--text-1); padding: 8px 12px; border-radius: 10px; cursor: pointer; margin-bottom: 12px; }
.theme-toggle-login:hover { border-color: var(--brand); color: var(--brand); }
.btn-block { width: 100%; }
.error-message { padding: 12px; background: color-mix(in oklab, var(--danger) 15%, var(--surface-2)); border: 1px solid color-mix(in oklab, var(--danger) 40%, var(--border)); border-radius: 8px; color: var(--danger); margin-bottom: 16px; font-size: 14px; }

/* Employee Directory Styles */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* Accessibility helpers */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Responsive tweaks */
@media (max-width: 720px) {
  .dashboard-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .movement-list { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .tabs { flex-direction: column; }
  .tab-button { width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
  .data-management-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  main.page { padding: 16px; }
  .section { padding: 16px; }
  .stat-card { padding: 16px; min-height: 100px; }
  .stat-number { font-size: 32px; }
}

/* Collapsible Sections */
.collapsible-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
  min-height: 80px;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid transparent;
  min-height: 80px;
  box-sizing: border-box;
}

.collapsible-header:hover {
  background: var(--surface-3);
}

.collapse-arrow {
  font-size: 14px;
  color: var(--text-2);
  transition: transform 0.2s ease;
  display: inline-block;
  min-width: 16px;
}

.collapsible-content {
  padding: 24px;
  animation: slideDown 0.2s ease;
}

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

