:root {
  --bg-top: #f4e9d8;
  --bg-bottom: #fffaf1;
  --card: #fffdf8;
  --card-soft: #fff8ec;
  --line: #e4d8c4;
  --line-strong: #b4c7de;
  --text: #2f2416;
  --muted: #7b6851;
  --primary: #2f6fbe;
  --primary-strong: #24599a;
  --primary-soft: #f3eadc;
  --warn: #ffefcc;
  --danger: #9f1239;
  --radius: 14px;
  --shadow: 0 10px 26px rgba(87, 63, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom) 44%);
  color: var(--text);
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 36px;
}

.card {
  max-width: 430px;
  margin: 64px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

h1, h2, h3, h4 {
  margin: 0 0 8px;
}

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

input,
select,
button {
  width: 100%;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid #c3d3e6;
  font: inherit;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid #9ec4f8;
  border-color: #78abef;
}

button {
  background: linear-gradient(180deg, #1c6fdd, var(--primary));
  border: none;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 98, 201, 0.25);
  min-height: 38px;
}

button:hover {
  background: linear-gradient(180deg, #1263ca, var(--primary-strong));
}

button.secondary {
  background: #e7effb;
  color: #174173;
  box-shadow: none;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.brand p {
  margin: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions #logoutBtn {
  width: auto;
  padding: 9px 14px;
}

.top-actions button {
  width: auto;
  min-height: 34px;
}

#catBtn {
  font-size: 16px;
  line-height: 1;
  padding: 8px 10px;
}

#catVanity {
  position: fixed;
  right: 24px;
  top: 86px;
  font-size: 28px;
  opacity: 0;
  transform: translateY(14px) scale(0.85);
  pointer-events: none;
  z-index: 60;
}

#catVanity.play {
  animation: cat-pop 820ms ease-in-out forwards;
}

@keyframes cat-pop {
  0% { opacity: 0; transform: translateY(14px) scale(0.85) rotate(0deg); }
  18% { opacity: 1; transform: translateY(-18px) scale(1.1) rotate(-10deg); }
  45% { opacity: 1; transform: translateY(-26px) scale(1.12) rotate(8deg); }
  70% { opacity: 1; transform: translateY(-8px) scale(1.02) rotate(-4deg); }
  100% { opacity: 0; transform: translateY(16px) scale(0.86) rotate(0deg); }
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f6ebda;
  color: #5f4a2f;
  border: 1px solid #e4d4bb;
  font-size: 12px;
  font-weight: 600;
}

.pill.subtle {
  background: #f8f1e6;
  color: #7b6851;
  border-color: #e8dbc7;
}

.tabs,
.subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tab {
  width: auto;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #dfceb5;
  background: #f8efe2;
  color: #5c4a32;
  box-shadow: none;
}

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

.content {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  align-items: end;
}

.toolbar > * {
  margin-bottom: 0;
}

.toolbar > button {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 10px 16px;
  justify-self: stretch;
  align-self: end;
}

.manager-track-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -2px 0 12px;
  align-items: end;
}

.manager-track-bar label {
  margin: 0;
  flex: 1 1 240px;
  min-width: 220px;
}

.manager-track-bar button {
  width: auto;
  min-width: 240px;
  max-width: 100%;
  min-height: 40px;
}

#saveBranding,
#yearEndPreview,
#applyYearEnd {
  width: auto;
  min-width: 190px;
  min-height: 40px;
  padding: 10px 16px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

th,
td {
  padding: 8px 9px;
  vertical-align: top;
  border-bottom: 1px solid #e4ecf7;
}

td button {
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
  margin: 2px 6px 2px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

li button {
  width: auto;
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
  margin: 4px 6px 0 0;
  display: inline-flex;
  align-items: center;
}

.manager-access-panel {
  margin-bottom: 12px;
}

.manager-access-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  align-items: end;
}

.manager-access-form label {
  margin-bottom: 0;
}

.manager-access-perms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 12px;
  margin: 10px 0;
}

.manager-access-perms label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 600;
}

.manager-access-perms input[type="checkbox"],
.manager-access-table input[type="checkbox"] {
  width: auto;
}

.manager-access-actions {
  display: flex;
  justify-content: flex-start;
}

.manager-access-actions button {
  width: auto;
  min-width: 180px;
}

.manager-access-table td:last-child {
  white-space: nowrap;
}

th {
  text-align: left;
  background: var(--primary-soft);
  color: #0f3f78;
  font-weight: 700;
}

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

tr:nth-child(even) td {
  background: #fff9ef;
}

.focus-row td {
  background: #e8f4ff !important;
  box-shadow: inset 0 0 0 1px #8dc0f8;
}

.warn td {
  background: var(--warn) !important;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

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

.split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 10px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  user-select: none;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

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

.day {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 100px;
  padding: 4px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease;
  user-select: none;
}

.day.empty {
  background: transparent;
  border-style: dashed;
  border-color: rgba(128, 144, 168, 0.35);
  cursor: default;
}

.day:hover {
  border-color: #8bb4ea;
}

.day.sel {
  outline: 2px solid #5b8ed9;
}

.day.range {
  border-color: #5294e7;
  box-shadow: 0 0 0 2px rgba(82, 148, 231, 0.18), inset 0 0 0 1px rgba(82, 148, 231, 0.2);
  background: linear-gradient(180deg, #ffffff, #f2f8ff);
}

.day.inspect {
  border-color: #1668c7;
  box-shadow: 0 0 0 2px rgba(22, 104, 199, 0.28), inset 0 0 0 1px rgba(22, 104, 199, 0.25);
}

.day-number {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

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

.leave-bar.pending {
  opacity: 0.45;
}

.leave-bar.manager-leave {
  border: 1px dashed rgba(255, 255, 255, 0.85);
  font-weight: 700;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--card-soft);
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.row > * {
  margin: 0;
}

ul {
  margin: 8px 0;
  padding-left: 18px;
}

li {
  margin-bottom: 4px;
}

@media (max-width: 980px) {
  .split {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar > button,
  #saveBranding,
  #yearEndPreview,
  #applyYearEnd {
    width: 100%;
    min-width: 0;
  }

  .manager-track-bar button,
  .manager-access-actions button {
    width: 100%;
    min-width: 0;
  }
}

body.dark {
  --bg-top: #0f1b2d;
  --bg-bottom: #0b1422;
  --card: #172338;
  --card-soft: #1a2940;
  --line: #2d3f5d;
  --line-strong: #3b5173;
  --text: #e8effa;
  --muted: #a7bbd9;
  --primary: #4f93ff;
  --primary-strong: #2f79ea;
  --primary-soft: #223653;
  --warn: #4e3e1f;
  --danger: #ff8aa5;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

body.dark input,
body.dark select {
  background: #0f1e33;
  color: #e8effa;
  border-color: #35527a;
}

body.dark input::placeholder {
  color: #9fb5d5;
}

body.dark .tab {
  background: #1c2e48;
  color: #d8e6fb;
  border-color: #35527a;
}

body.dark .tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: #6ba8ff;
  box-shadow: 0 0 0 1px rgba(107, 168, 255, 0.35) inset;
}

body.dark .pill {
  background: #1d3150;
  color: #d7e8ff;
  border-color: #38557f;
}

body.dark .pill.subtle {
  background: #1a2a41;
  color: #b9cbe6;
  border-color: #314a6c;
}

body.dark button.secondary {
  background: #273b58;
  color: #d8e8ff;
}

body.dark th {
  color: #d7e8ff;
}

body.dark tr:nth-child(even) td {
  background: #1a2941;
}

body.dark .focus-row td {
  background: #203b59 !important;
}

body.dark .day.range {
  background: linear-gradient(180deg, #1b2c45, #1f3656);
}

body.dark .day {
  background: #18283f;
}

body.dark .day.inspect {
  border-color: #67a7ff;
}
