:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ef;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --focus: rgba(37, 99, 235, 0.28);
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --info-bg: #dbeafe;
  --info-text: #1d4ed8;
  --muted-bg: #e5e7eb;
  --muted-text: #374151;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);

  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

h1, h2, h3, p { margin-top: 0; }

input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #c4d2e5;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px var(--focus);
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  min-height: 40px;
  padding: 0.5rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

button,
.button-link {
  background: var(--primary);
  color: #fff;
}

button:hover,
.button-link:hover {
  background: var(--primary-hover);
  color: #fff;
  text-decoration: none;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1.2rem 1rem;
  border-right: 1px solid #1e293b;
  position: relative;
}

.sidebar h2 {
  margin: 0 0 1rem;
  color: #f8fafc;
  font-size: 1.05rem;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar a {
  display: block;
  color: #cbd5e1;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  text-decoration: none;
}

.sidebar a:hover {
  background: #1e293b;
  color: #fff;
}

.sidebar-close-btn {
  display: none;
}

.content {
  padding: 1rem 1.25rem 1.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.mobile-menu-btn {
  display: none;
}

.topbar-meta {
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline { display: inline-block; }

.lang-switch {
  position: relative;
}

.lang-flag-btn {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0.2rem 0.5rem 0.2rem 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-flag-btn:hover {
  background: #f8fafc;
  color: var(--text);
}

.lang-flag {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.08rem;
  border: 1px solid #e2e8f0;
  background: #fff;
}

.lang-code {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lang-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 156px;
  z-index: 8;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 0.25rem;
}

.lang-option-form {
  display: block;
}

.lang-option-btn {
  width: 100%;
  min-height: 38px;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  border: 0;
  justify-content: flex-start;
  gap: 0.5rem;
  font-weight: 600;
}

.lang-option-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.flash {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.65rem 0.8rem;
  margin: 0 0 0.75rem;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: #bbf7d0;
}

.flash-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #fecaca;
}

.hint {
  font-size: 0.86rem;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}

.filters > * {
  flex: 1 1 170px;
}

.filters a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.5rem 0.2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th,
td {
  border-bottom: 1px solid #ebf0f6;
  padding: 0.62rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

tr:last-child td { border-bottom: 0; }

thead th {
  background: var(--surface-soft);
  color: #1e293b;
  font-size: 0.87rem;
}

tbody tr:hover {
  background: #f8fbff;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 0.1rem;
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

form > label {
  width: 100%;
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  color: #334155;
}

.checkbox-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #334155;
}

.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

form > input,
form > select,
form > textarea,
form > button,
form > .button-link {
  flex: 1 1 180px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-status-planned {
  background: var(--info-bg);
  color: var(--info-text);
}

.badge-status-confirmed,
.badge-status-approved {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-status-pending,
.badge-status-proposed {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-status-rejected {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-status-cancelled,
.badge-status-default {
  background: var(--muted-bg);
  color: var(--muted-text);
}

.stats-grid { margin-top: 0.9rem; }

.stat-card {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-card h3 {
  font-size: 0.92rem;
  color: #334155;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
  margin: 0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.roster-wrap {
  overflow-x: auto;
}

.roster-table {
  min-width: 1120px;
}

.roster-table th,
.roster-table td {
  min-width: 84px;
  padding: 0.45rem;
}

.roster-user-cell {
  min-width: 220px !important;
  position: sticky;
  left: 0;
  z-index: 1;
  background: #fff;
}

.roster-day-cell {
  padding: 0;
}

.cell-link {
  min-height: 64px;
  text-decoration: none;
  color: inherit;
  padding: 0.3rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.cell-link:hover {
  background: #f8fbff;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
}

.schedule-weekday {
  font-weight: 700;
  text-align: center;
  font-size: 0.88rem;
  padding: 0.2rem;
  color: #334155;
}

.schedule-day {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 108px;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.schedule-day-empty {
  background: transparent;
  border: 1px dashed #d1d5db;
}

.schedule-day header {
  font-weight: 700;
  margin-bottom: 0.15rem;
  display: flex;
  flex-direction: column;
}

.schedule-day-date {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: radial-gradient(circle at top left, #e8efff 0%, #f3f6fb 45%, #eef2f7 100%);
}

.auth-card {
  width: min(420px, 100%);
}

.auth-title {
  margin-bottom: 0.3rem;
}

.auth-subtitle {
  margin: 0 0 1rem;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 0.75rem;
}

.auth-form button {
  width: 100%;
}

.auth-lang {
  margin-bottom: 0.75rem;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 210px minmax(0, 1fr);
  }

  .content {
    padding: 0.95rem;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #1e293b;
  }

  table {
    font-size: 0.9rem;
  }

  .schedule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .roster-user-cell {
    min-width: 180px !important;
  }
}

@media (max-width: 699px) {
  .role-employee .app-shell {
    grid-template-columns: 1fr;
  }

  .role-employee .content {
    padding: 0.8rem;
  }

  .role-employee .topbar {
    margin-bottom: 0.65rem;
  }

  .role-employee .topbar-meta {
    font-size: 0.95rem;
  }

  .role-employee .topbar-actions {
    margin-left: auto;
  }

  .role-employee .mobile-menu-btn {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.1rem;
    padding: 0.4rem;
  }

  .role-employee .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(82vw, 300px);
    height: 100vh;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    border-right: 1px solid #1e293b;
  }

  .role-employee .sidebar-close-btn {
    display: inline-flex;
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    min-width: 40px;
    min-height: 40px;
    background: transparent;
    border: 1px solid #334155;
    color: #e2e8f0;
  }

  .role-employee .sidebar-close-btn:hover {
    background: #1e293b;
  }

  .role-employee.nav-open .sidebar {
    transform: translateX(0);
  }

  .role-employee.nav-open {
    overflow: hidden;
  }

  .role-employee .grid,
  .role-employee .employee-dashboard-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .role-employee .card {
    padding: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .role-employee .month-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .role-employee .month-nav strong {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 0.15rem;
  }

  .role-employee .schedule-grid-employee {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .role-employee .schedule-grid-employee .schedule-weekday,
  .role-employee .schedule-grid-employee .schedule-day-empty {
    display: none;
  }

  .role-employee .schedule-grid-employee .schedule-day {
    min-height: 0;
    gap: 0.35rem;
    padding: 0.65rem;
  }

  .role-employee table.employee-data-table,
  .role-employee table.employee-data-table tbody,
  .role-employee table.employee-data-table tr,
  .role-employee table.employee-data-table td {
    display: block;
    width: 100%;
  }

  .role-employee table.employee-data-table thead {
    display: none;
  }

  .role-employee table.employee-data-table {
    border: 0;
    background: transparent;
  }

  .role-employee table.employee-data-table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 0.6rem;
    padding: 0.2rem;
  }

  .role-employee table.employee-data-table td {
    border-bottom: 1px solid #ebf0f6;
    padding: 0.5rem 0.55rem;
  }

  .role-employee table.employee-data-table td:last-child {
    border-bottom: 0;
  }

  .role-employee form.inline,
  .role-employee .employee-form-card form {
    display: grid;
    gap: 0.55rem;
  }

  .role-employee .employee-form-card input,
  .role-employee .employee-form-card select,
  .role-employee .employee-form-card button,
  .role-employee .employee-form-card .button-link {
    width: 100%;
    min-height: 44px;
  }

  .auth-card {
    width: 100%;
    max-width: 420px;
  }
}
