:root {
  --bg: #0f1419;
  --bg-elevated: #161d26;
  --bg-hover: #1c242f;
  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(255, 255, 255, 0.12);
  --txt: #e6edf3;
  --txt-muted: #7d8590;
  --accent: #58a6ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.12);
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.12);
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}

.brand b {
  font-size: 15px;
  font-weight: 600;
}

.brand span {
  font-size: 12px;
  color: var(--txt-muted);
}

.pill {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--bg-hover);
  color: var(--txt-muted);
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.card + .card {
  margin-top: 16px;
}

.card h2 {
  margin: 0 0 4px 0;
  font-size: 15px;
  font-weight: 600;
}

.card h3 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
}

.muted {
  color: var(--txt-muted);
  font-size: 13px;
}

/* Buttons */
.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--txt);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-focus);
}

.btn.primary {
  background: var(--accent-soft);
  border-color: rgba(88, 166, 255, 0.3);
  color: var(--accent);
}

.btn.primary:hover {
  background: rgba(88, 166, 255, 0.2);
}

.btn.danger {
  background: var(--danger-soft);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--danger);
}

.btn.danger:hover {
  background: rgba(248, 81, 73, 0.2);
}

.btn.ok {
  background: var(--ok-soft);
  border-color: rgba(63, 185, 80, 0.3);
  color: var(--ok);
}

.btn.warn {
  background: var(--warn-soft);
  border-color: rgba(210, 153, 34, 0.3);
  color: var(--warn);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

/* Forms */
input, select, textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

label {
  display: block;
  font-size: 12px;
  color: var(--txt-muted);
  margin: 12px 0 6px;
}

label:first-child {
  margin-top: 0;
}

.sep {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Tabs */
.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tab {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--txt-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}

.tab:hover {
  color: var(--txt);
  background: var(--bg-hover);
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Notices */
.notice {
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.notice.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.notice.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.notice.err {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Tags */
.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.tag {
  font-size: 11px;
  color: var(--txt-muted);
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--bg-hover);
}

.tag.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

/* List */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Schedule table */
.schedWrap {
  overflow: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
}

table.sched {
  border-collapse: collapse;
  width: 100%;
  min-width: 1100px;
  font-size: 13px;
}

table.sched th,
table.sched td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: top;
}

table.sched th:not(.left):not(.left2),
table.sched td:not(.left):not(.left2) {
  border-left: 1px solid var(--border);
}

table.sched thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 2;
  font-weight: 600;
  color: var(--txt-muted);
}

table.sched th.left,
table.sched td.left,
table.sched th.left2,
table.sched td.left2 {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg-elevated);
}

table.sched th.left2,
table.sched td.left2 {
  left: 56px;
}

table.sched td.left,
table.sched td.left2 {
  font-weight: 500;
  color: var(--txt-muted);
}

td.cell {
  cursor: pointer;
  min-width: 100px;
  transition: background 0.1s;
}

td.cell:hover {
  background: var(--bg-hover);
}

td.inactive {
  opacity: 0.5;
}

td.active {
  background: var(--ok-soft);
}

.cellName {
  font-weight: 500;
}

td.cell.on-leave {
  background: var(--warn-soft);
}

td.cell.on-leave .cellName {
  opacity: 0.5;
  text-decoration: line-through;
}

.on-leave-label {
  font-size: 11px;
  color: var(--warn);
  margin-top: 2px;
}

.cellSub {
  font-size: 11px;
  color: var(--txt-muted);
  margin-top: 2px;
}

/* Modal */
.modalBack {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  width: min(560px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.modalTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.cand {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.cand.grey {
  opacity: 0.5;
}

.cand .why {
  font-size: 12px;
  color: var(--txt-muted);
  margin-top: 4px;
}

/* Grid */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

code {
  background: var(--bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

/* Department calendar */
.depCalCard {
  padding: 16px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.depCalTop {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.depOrderBtns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.depOrderBtns .dep-move-btn {
  padding: 4px 8px;
  font-size: 12px;
  min-width: 28px;
}

.depOrderBtns .dep-move-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.depCalendarWrap {
  border-radius: 6px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

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

.depDow {
  text-align: center;
  font-size: 11px;
  color: var(--txt-muted);
  padding: 6px 0;
}

.depDay {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--txt);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s, border-color 0.1s;
}

.depDay:hover {
  background: var(--bg-hover);
}

.depDay.weekend {
  background: transparent;
  opacity: 0.6;
}

.depDay.on {
  background: var(--ok-soft);
  border-color: rgba(63, 185, 80, 0.4);
}

.depDay.blank {
  visibility: hidden;
  pointer-events: none;
}

.checkRow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--txt);
}

.checkRow input {
  width: auto;
}

/* Responsive */
@media (max-width: 900px) {
  .row,
  .row3,
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }

  .topbar {
    border-radius: 8px;
  }

  table.sched th.left2,
  table.sched td.left2 {
    left: 64px;
  }

  .item {
    flex-direction: column;
  }
}
