:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --muted-blue: #64748b;
  --completed: #7c3aed;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(0deg, rgba(37,99,235,0.045) 0px, rgba(37,99,235,0.045) 1px, transparent 1px, transparent 46px),
    repeating-linear-gradient(90deg, rgba(37,99,235,0.045) 0px, rgba(37,99,235,0.045) 1px, transparent 1px, transparent 46px);
}

/* Login — calendar-grid + sunny gradient, vacation theme */
.login-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 100vh;
  background-color: #1e3a8a;
  background-image:
    radial-gradient(circle at 85% 12%, rgba(253,224,71,0.45) 0%, rgba(253,224,71,0) 55%),
    radial-gradient(circle at 8% 90%, rgba(45,212,191,0.35) 0%, rgba(45,212,191,0) 55%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.06) 0px, rgba(255,255,255,0.06) 1px, transparent 1px, transparent 42px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.06) 0px, rgba(255,255,255,0.06) 1px, transparent 1px, transparent 42px),
    linear-gradient(135deg, #2563eb 0%, #1e3a8a 55%, #0f2557 100%);
}

.login-box {
  background: var(--card);
  padding: 40px;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  width: 380px;
}

.login-box h1 {
  margin: 0 0 4px;
  color: var(--primary);
}

.login-box .subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-box label {
  display: block;
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 16px;
}

.footer-credit {
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  text-align: center;
  margin: 0;
}

.hint-inline {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-top: 8px;
}

/* Nav */
.topnav {
  display: flex;
  align-items: center;
  gap: 24px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--primary);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  vertical-align: middle;
  margin-right: 6px;
}

.login-box h1 .brand-icon {
  width: 28px;
  height: 28px;
}

.app-version {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  vertical-align: middle;
}

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}

.tab-btn:hover { background: var(--bg); }
.tab-btn.active { background: var(--primary); color: #fff; }

.subtab-btn {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.subtab-btn:hover { background: var(--bg); }
.subtab-btn.active { background: #dbeafe; color: var(--primary-dark); }

.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px 60px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-header h2 { margin: 0; }

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.secondary:hover { background: #cbd5e1; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }
.btn.ghost { background: #ede9fe; color: #5b21b6; }
.btn.small { padding: 5px 10px; font-size: 12px; margin-left: 6px; }
.btn.full { width: 100%; margin-top: 18px; }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.data-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.03em;
}

.row-actions { white-space: nowrap; text-align: right; }

/* Positions list */
.add-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.add-inline input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.simple-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.simple-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.simple-list li:last-child { border-bottom: none; }

/* Company settings form */
.company-form {
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  max-width: 480px;
}

.company-form label {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.company-form input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.save-confirmation {
  color: var(--success);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { margin-top: 0; }

.modal label {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.modal input, .modal select, .modal textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}

.modal textarea { min-height: 70px; resize: vertical; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Calendar */
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cal-title { font-weight: 700; font-size: 16px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding-bottom: 6px;
}

.cal-day {
  min-height: 78px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  font-size: 12px;
  cursor: default;
}

.cal-day.empty { background: transparent; border: none; }
.cal-day.weekend { background: #f8fafc; }
.cal-day.selected { outline: 2px solid var(--primary); background: #eff6ff; }
.cal-day.holiday { border-color: #f9a8d4; background: #fdf2f8; }
.calendar-clickable .cal-day.not-selectable { cursor: not-allowed; opacity: 0.6; }

.cal-daynum { font-weight: 700; margin-bottom: 4px; }

.cal-event {
  border-radius: 4px;
  padding: 2px 5px;
  margin-top: 2px;
  font-size: 10px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-event.confirmed { background: var(--success); }
.cal-event.planned { background: var(--warning); }
.cal-event.completed { background: var(--completed); }
.cal-event.more { background: var(--text-muted); }
.cal-event.holiday-tag { background: #db2777; }
.cal-event.colleague { background: #94a3b8; }

[data-nav] { cursor: pointer; }
.calendar-clickable .cal-day:not(.empty) { cursor: pointer; }
.calendar-clickable .cal-day:not(.empty):hover { border-color: var(--primary); }

.range-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.range-bar .field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.range-bar .field input, .range-bar .field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.legend-item { display: flex; align-items: center; gap: 6px; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.confirmed { background: var(--success); }
.dot.planned { background: var(--warning); }
.dot.completed { background: var(--completed); }
.dot.cancelled { background: var(--danger); }
.dot.holiday { background: #db2777; }
.dot.colleague { background: #94a3b8; }

/* Employee dashboard */
.summary-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1;
  min-width: 140px;
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.profile-details {
  background: var(--card);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.profile-details p { margin: 8px 0; font-size: 14px; }

.selection-box {
  background: var(--card);
  border-radius: 10px;
  padding: 16px 20px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.compensation-box {
  background: var(--card);
  border-radius: 10px;
  padding: 16px 20px;
  margin-top: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.compensation-box h3 { margin: 0 0 6px; font-size: 15px; }

.selection-box textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  margin-top: 4px;
}

/* Backup */
.backup-block {
  background: var(--card);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  max-width: 640px;
}

.backup-block h3 { margin: 0 0 12px; font-size: 15px; }

.backup-inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.backup-inline-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

#backup-restore-file { display: block; margin: 8px 0; }

/* Dashboard */
.dashboard-section { margin-bottom: 30px; }
.dashboard-section h3 { margin: 0 0 12px; font-size: 15px; }

.due-empty {
  background: var(--card);
  border-radius: 10px;
  padding: 16px 20px;
  color: var(--text-muted);
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.due-card {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.due-card .due-info { font-size: 13px; }
.due-card .due-info strong { font-size: 14px; }
.due-card .due-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.upcoming-list {
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.upcoming-empty {
  padding: 16px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Badges */
.badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}

.badge.planned { background: var(--warning); }
.badge.confirmed { background: var(--success); }
.badge.completed { background: var(--completed); }
.badge.cancelled { background: var(--danger); }

/* ===================== Responsive / mobile ===================== */

@media (max-width: 900px) {
  .container { padding: 0 12px 40px; }
  .summary-cards { gap: 10px; }
  .stat-card { min-width: 45%; padding: 14px; }
}

@media (max-width: 640px) {
  body { background-image: none; }

  .login-box { width: min(380px, 90vw); padding: 28px 22px; }

  .topnav {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
    row-gap: 8px;
  }
  .brand { font-size: 16px; flex: 1 1 auto; }
  .nav-right { order: 1; margin-left: auto; }
  .tabs {
    order: 2;
    flex-basis: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .tab-btn { flex: 0 0 auto; white-space: nowrap; padding: 7px 10px; font-size: 13px; }

  .container { padding: 0 10px 32px; margin: 14px auto; }

  .panel-header { flex-direction: column; align-items: stretch; }
  .panel-header h2 { font-size: 17px; }

  .subtabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .subtab-btn { flex: 0 0 auto; white-space: nowrap; }

  /* Tables: allow horizontal scroll instead of squeezing columns unreadably */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .data-table thead, .data-table tbody { display: table; width: 100%; }

  .add-inline { flex-direction: column; }
  .add-inline input { width: 100%; }

  .modal { width: min(380px, 92vw); padding: 20px; }

  .company-form { max-width: 100%; }

  .calendar-toolbar { flex-direction: column; align-items: stretch; }
  .calendar-toolbar .field select, .calendar-toolbar .field input { width: 100%; }

  .cal-grid { gap: 3px; }
  .cal-day { min-height: 54px; padding: 3px; font-size: 10px; }
  .cal-daynum { font-size: 11px; margin-bottom: 2px; }
  .cal-event { font-size: 8px; padding: 1px 3px; }
  .cal-weekday { font-size: 10px; }

  .range-bar { flex-direction: column; align-items: stretch; }
  .range-bar .field, .range-bar button { width: 100%; }
  .range-bar .field input { width: 100%; }

  .summary-cards { flex-direction: column; }
  .stat-card { min-width: 100%; }

  .due-card { flex-direction: column; align-items: stretch; }
  .due-actions { width: 100%; }
  .due-actions .btn { flex: 1; }

  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; min-width: 100px; }

  .legend { gap: 10px; }
}
