:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f3f4f6;
  line-height: 1.45;
}

* { box-sizing: border-box; }

body { margin: 0; }

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

button {
  border: 0;
  border-radius: 8px;
  padding: 9px 13px;
  background: #111827;
  color: white;
  cursor: pointer;
}

button.secondary {
  background: #e5e7eb;
  color: #111827;
}

button.success {
  background: #166534;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.topbar {
  background: #111827;
  color: white;
  padding: 16px max(16px, calc((100% - 1200px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

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

h1 { margin-bottom: 2px; font-size: 1.35rem; }
h2 { margin-bottom: 6px; }

.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgb(0 0 0 / 8%);
}

.auth-card {
  max-width: 420px;
  margin: 70px auto;
}

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

input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 11px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
}

.toolbar, .admin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar strong, .admin-toolbar strong {
  min-width: 180px;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 700px;
}

th, td {
  border: 1px solid #e5e7eb;
  padding: 8px;
  text-align: center;
  white-space: nowrap;
}

th {
  background: #f9fafb;
  font-weight: 700;
}

th:first-child, td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: white;
  z-index: 1;
}

.admin-cell select {
  min-width: 90px;
  margin: 0;
  padding: 7px;
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 14px;
  color: #4b5563;
  font-size: .9rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.muted { color: #6b7280; }
.error { color: #b91c1c; margin-top: 10px; }
.hidden { display: none !important; }

#preferenceForm {
  max-width: 700px;
}

#preferenceStatus {
  margin-left: 8px;
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    display: flex;
    flex-direction: column;
  }

  .container {
    margin-top: 12px;
  }

  .card {
    padding: 14px;
  }

  .toolbar strong, .admin-toolbar strong {
    min-width: 130px;
  }
}

.warning-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}

.warning-list {
  margin-top: 8px;
  line-height: 1.7;
}

.success-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.current-user-row td {
  font-weight: 700;
  background-image:
    linear-gradient(
      rgba(17, 24, 39, 0.10),
      rgba(17, 24, 39, 0.10)
    );
}

.current-user-row td:first-child {
  font-weight: 800;
  border-left: 4px solid #111827;
}

.today-column {
  box-shadow:
    inset 2px 0 0 rgba(17, 24, 39, 0.22),
    inset -2px 0 0 rgba(17, 24, 39, 0.22);
}

th.today-column {
  font-weight: 800;
  background: #e5e7eb;
}

.current-user-row td.today-column {
  outline: 2px solid #111827;
  outline-offset: -2px;
}

/* RADNE SMJENE */

.shift-816 {
  background: #CAEDFB;   /* plava */
}

.shift-917,
.shift-1018,
.shift-1220 {
  background: #E49EDD;   /* ljubičasta */
}

.shift-1422 {
  background: #DAF2D0;   /* zelena */
}

/* NERADNI STATUSI TIJEKOM RADNOG DANA */

.shift-off,
.shift-go,
.shift-bo,
.shift-pd {
  background: #FFFFFF;
  color: #111827;
}


/* VIKENDI I BLAGDANI - OVO IMA PRIORITET */

.calendar-nonworking {
  background: #F7C7AC !important;
  color: #111827;
}

.section-divider {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 20px 0;
}

.date-range {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.date-range label {
  flex: 1;
  min-width: 180px;
}

#annualLeaveForm {
  max-width: 700px;
}

#annualLeaveStatus {
  margin-left: 8px;
}

.annual-leave-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.annual-leave-item:last-child {
  border-bottom: 0;
}

.annual-leave-main {
  min-width: 0;
}

.annual-leave-dates {
  margin-left: 8px;
  font-weight: 600;
}

.annual-leave-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: .8rem;
  font-weight: 700;
}

.annual-leave-note {
  margin-top: 5px;
}

.annual-leave-info {
  margin-top: 3px;
  font-size: .85rem;
}

@media (max-width: 640px) {
  .annual-leave-item {
    flex-direction: column;
  }

  .annual-leave-dates,
  .annual-leave-badge {
    margin-left: 0;
    margin-right: 6px;
  }
}

.has-planned-leave {
  position: relative;
}

.planned-leave-marker {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 11px;
  line-height: 1;
  cursor: help;
}

.shift-text {
  position: relative;
}

.admin-preference-item {
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.admin-preference-item:last-child {
  border-bottom: 0;
}

.admin-preference-name {
  font-weight: 700;
  margin-bottom: 4px;
}

.admin-preference-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

.admin-preference-empty {
  color: #6b7280;
}

.shift-early {
  background: #CAEDFB;
}

.shift-middle {
  background: #E49EDD;
}

.shift-late {
  background: #DAF2D0;
}

.shift-nonwork {
  background: #FFFFFF;
  color: #111827;
}

.shift-type-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.shift-type-item:last-child {
  border-bottom: 0;
}

.shift-type-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.shift-type-label {
  font-weight: 700;
  min-width: 70px;
}

.shift-type-time {
  color: #6b7280;
}

.shift-type-inactive {
  opacity: 0.55;
}

.shift-type-badge {
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f3f4f6;
}

.shift-cell {
  position: relative;
  padding: 0 !important;
  height: 30px;
  min-height: 30px;
}

.cell-shift-stack {
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;
  align-items: stretch;

  line-height: 1;
}

.cell-segment {
  flex: 1 1 0;
  min-height: 0;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0 2px;

  white-space: nowrap;
  overflow: hidden;

  font-weight: 600;
}

.cell-segment + .cell-segment {
  border-top: 1px solid rgba(0, 0, 0, 0.18);
}

.shift-segment {
  background: transparent;
}

.overtime-entry {
  background: #b42323;
  color: #ffffff;

  border-radius: 0;
  max-width: none;
  cursor: help;
}

/* Normalna ćelija */
.cell-shift-stack-1 .cell-segment {
  font-size: 12px;
}

/* Smjena + jedan prekovremeni */
.cell-shift-stack-2 .cell-segment {
  font-size: 10px;
}

/* Smjena + dva prekovremena */
.cell-shift-stack-3 .cell-segment {
  font-size: 8px;
}

.overtime-palette-button {
  background: #dc2626;
  color: white;
  border-color: #b91c1c;
}

.overtime-palette-button:hover {
  background: #b91c1c;
}

.overtime-palette-button.selected {
  outline: 2px solid #7f1d1d;
  outline-offset: 1px;
}


/* MODAL ZA PREKOVREMENE */

.overtime-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;
}

.overtime-modal-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(0, 0, 0, 0.45);
}

.overtime-modal-dialog {
  position: relative;
  z-index: 1;

  width: min(420px, 100%);
  background: white;

  border-radius: 10px;
  padding: 18px;

  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.25);
}

.overtime-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;

  margin-bottom: 16px;
}

.overtime-modal-header h3 {
  margin: 0 0 4px 0;
}

.overtime-modal-close {
  min-width: 36px;
  padding: 4px 10px;

  font-size: 20px;
  line-height: 1;
}

.overtime-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.overtime-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;

  margin-top: 14px;
}

#overtimeModalStatus {
  min-height: 20px;
  margin-top: 8px;
}

button.danger {
  background: #dc2626;
  color: white;
  border-color: #b91c1c;
}

button.danger:hover {
  background: #b91c1c;
}

@media (max-width: 500px) {
  .overtime-time-row {
    grid-template-columns: 1fr;
  }
}

#accountCard form {
  max-width: 520px;
}

.account-current {
  margin-bottom: 16px;
}

.account-status {
  margin-top: 8px;
  min-height: 20px;
}

#accountCard hr {
  margin-top: 24px;
  margin-bottom: 20px;
}