:root {
  --aldi-blue: #00549f;
  --aldi-blue-dark: #003f78;
  --aldi-orange: #f39200;
  --aldi-red: #e2001a;
  --aldi-yellow: #ffcc00;
  --green: #1a8f4c;
  --green-bg: #e5f6ec;
  --red: #c81e2c;
  --red-bg: #fbe8e9;
  --grey: #6b7280;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --border: #d8dee5;
  font-size: 18px;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  line-height: 1.4;
}

.topbar {
  background: var(--aldi-blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 14px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }

.logo { display: flex; flex-direction: column; align-items: flex-start; flex-shrink: 0; }
.logo-word {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  color: white;
}
.logo-stripes {
  display: block;
  width: 90px;
  height: 5px;
  margin-top: 3px;
  background: linear-gradient(90deg, var(--aldi-orange) 0 25%, var(--aldi-red) 25% 50%, var(--aldi-yellow) 50% 75%, white 75% 100%);
  border-radius: 3px;
}
.logo-img { height: 42px; display: block; }

.user-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

.icon { width: 20px; height: 20px; flex-shrink: 0; }

.screen { max-width: 900px; margin: 0 auto; padding: 10px 12px 24px; }

.loading-screen {
  text-align: center;
  padding-top: 90px;
  font-size: 19px;
  font-weight: 700;
  color: var(--aldi-blue);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

h1 { font-size: 26px; margin-top: 0; }
h2 { font-size: 22px; margin: 0; }
h3 { font-size: 19px; margin-top: 0; }

label {
  display: block;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 16px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  font-size: 18px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--text);
}

select:focus, input:focus { outline: 3px solid var(--aldi-blue); border-color: var(--aldi-blue); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

.btn-primary { background: var(--aldi-blue); color: white; }
.btn-primary:hover { background: var(--aldi-blue-dark); }
.btn-secondary { background: #e7ebef; color: var(--text); }
.btn-danger { background: var(--red); color: white; }
.btn-big { width: 100%; font-size: 19px; padding: 14px; }
.btn-round { width: 48px; height: 48px; border-radius: 50%; background: white; border: 2px solid var(--aldi-blue); color: var(--aldi-blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }
.eye-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--grey);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.eye-toggle .icon { width: 22px; height: 22px; }
.btn-link { background: none; color: var(--aldi-blue); text-decoration: underline; font-size: 16px; padding: 2px; display: block; margin: 0 auto 6px auto; }

.dni-input { text-transform: uppercase; letter-spacing: 1px; }

.auth-card { max-width: 420px; margin: 40px auto; }
.auth-tabs { display: flex; margin-bottom: 18px; border-radius: 8px; overflow: hidden; border: 2px solid var(--aldi-blue); }
.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: white;
  color: var(--aldi-blue);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.auth-tabs .tab-btn.active { background: var(--aldi-blue); color: white; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs .tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 10px;
  background: white;
  border: 2px solid var(--border);
  color: var(--text);
}
.tabs .tab-btn.active { background: var(--aldi-orange); color: white; border-color: var(--aldi-orange); }

.error-text { color: var(--red); font-weight: 700; }
.info-text { color: var(--green); font-weight: 700; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 4px; }
#monthLabel { min-width: 220px; text-align: center; text-transform: uppercase; font-size: 26px; letter-spacing: 0.5px; }

.calendar-wrap { overflow-x: auto; margin-bottom: 16px; }
table.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.calendar th {
  background: var(--aldi-blue);
  color: white;
  padding: 6px 2px;
  font-size: 13px;
}
table.calendar td {
  position: relative;
  vertical-align: top;
  border: 1px solid var(--border);
  height: 76px;
  padding: 0;
  background: white;
  cursor: pointer;
  overflow: hidden;
}
.day-cell-content {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 3px;
}
table.calendar td.outside-month { opacity: 0.5; }
table.calendar td.is-holiday .day-number { color: var(--aldi-red); }
table.calendar td.is-holiday::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aldi-red);
}
table.calendar td.week-total {
  background: #eef3f8;
  cursor: default;
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  vertical-align: middle;
  padding: 3px;
  color: var(--aldi-blue-dark);
  white-space: nowrap;
}
.week-diff { display: block; font-size: 10px; font-weight: 400; margin-top: 2px; white-space: nowrap; }
.week-diff.positive { color: var(--green); }
.week-diff.negative { color: var(--red); }
table.calendar td.is-today { outline: 3px solid var(--aldi-orange); outline-offset: -3px; }
table.calendar td.has-work { background: var(--green-bg); }
table.calendar td.has-vacation { background: #fff6d9; }
table.calendar tr.current-week td {
  box-shadow: inset 0 0 0 999px rgba(0, 84, 159, 0.13);
}

.day-number { justify-self: start; font-weight: 700; font-size: 15px; }
.day-shift-main {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  line-height: 1.25;
  overflow: hidden;
}
.day-shift-time { font-weight: 700; color: var(--aldi-blue-dark); white-space: nowrap; }
.day-shift-hours {
  text-align: center;
  padding-top: 1px;
  font-weight: 400;
  font-size: 11px;
  color: var(--grey);
}
.day-vacation-tag { display: block; color: #8a6d00; font-weight: 900; font-size: 26px; line-height: 1; }

.month-summary { display: flex; gap: 24px; flex-wrap: wrap; font-size: 17px; }
#monthTotalHours { font-size: 24px; font-weight: 800; color: var(--aldi-blue-dark); }

.balance-total { text-align: center; }
.balance-label { font-size: 17px; color: var(--grey); font-weight: 600; }
.balance-value { font-size: 44px; font-weight: 900; margin-top: 6px; }
.balance-value.positive { color: var(--green); }
.balance-value.negative { color: var(--red); }

.balance-list { list-style: none; padding: 0; margin: 0; }
.balance-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}
.balance-list li .b-hours.positive { color: var(--green); font-weight: 800; }
.balance-list li .b-hours.negative { color: var(--red); font-weight: 800; }
.balance-list .b-delete { background: none; border: none; color: var(--red); cursor: pointer; display: inline-flex; align-items: center; padding: 6px; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-overlay:not([hidden]) { display: flex; }
.modal { width: 100%; max-width: 440px; margin: 0; }
#dayModalTitle {
  text-align: center;
  text-transform: uppercase;
  font-weight: bold;
  -webkit-text-stroke: 0.6px white;
  font-size: 19px;
  letter-spacing: 0.3px;
  margin: -18px -18px 16px -18px;
  padding: 16px 12px;
  background: var(--aldi-blue);
  color: white;
  border-radius: 12px 12px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#workFields > label {
  text-align: center;
  text-transform: uppercase;
  font-size: 17px;
  letter-spacing: 0.5px;
}

.day-type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.type-btn.active[data-type="trabajo"] { background: var(--aldi-blue); color: white; border-color: var(--aldi-blue); }
.type-btn.active[data-type="vacaciones"] { background: #c9971e; color: white; border-color: #c9971e; }

.time-select { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.time-select select { width: 96px; font-size: 23px; font-weight: 700; text-align: center; }
.time-select span { font-size: 23px; font-weight: 700; }

.hours-preview { font-size: 18px; font-weight: 700; color: var(--aldi-blue-dark); text-align: center; }
.break-note { display: block; font-size: 13px; font-weight: 400; color: var(--grey); margin-top: 4px; }

.modal-actions { display: flex; gap: 8px; margin-top: 10px; }
.modal-actions .btn { flex: 1; }

@media (max-width: 480px) {
  :root { font-size: 15px; }

  .topbar { padding: 8px 10px; }
  .logo-word { font-size: 21px; }
  .logo-stripes { width: 70px; height: 4px; }
  .user-name { font-size: 13px; max-width: 38vw; }
  .btn-logout, #btnLogout { padding: 8px 12px; font-size: 14px; min-height: 38px; }

  .card { padding: 12px; margin-bottom: 12px; }
  #dayModalTitle { margin: -12px -12px 14px -12px; font-size: 16px; padding: 14px 8px; }
  h1 { font-size: 21px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }

  label { font-size: 14px; margin-bottom: 10px; }
  input, select { font-size: 16px; padding: 10px; }
  .tabs .tab-btn { font-size: 14px; padding: 10px 4px; gap: 4px; }

  .month-nav { gap: 10px; }
  #monthLabel { min-width: 0; font-size: 20px; }
  .btn-round { width: 40px; height: 40px; }

  table.calendar th { font-size: 11px; padding: 4px 1px; }
  table.calendar td { height: 76px; }
  .day-cell-content { padding: 2px; }
  .day-number { font-size: 13px; }
  .day-shift-main { font-size: 9px; line-height: 1.15; }
  .day-vacation-tag { font-size: 18px; }
  .day-shift-time { white-space: normal; font-size: 10.5px; }
  .day-shift-time .t-sep { display: none; }
  .day-shift-time .t-start,
  .day-shift-time .t-end { display: block; }
  .day-shift-hours { font-size: 8px; }
  td.week-total { font-size: 8px; padding: 2px; }
  .week-diff { font-size: 7px; }
  #monthTotalHours { font-size: 19px; }

  .month-summary { font-size: 14px; gap: 10px 16px; }

  .balance-value { font-size: 30px; }
  .balance-label { font-size: 15px; }
  .balance-list li { font-size: 14px; padding: 8px 2px; flex-wrap: wrap; gap: 4px; }

  .modal { max-width: 100%; }
  .type-btn { font-size: 14px; padding: 10px 6px; }
}
