:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e0ea;
  --line-soft: #e8edf4;
  --text: #172033;
  --muted: #61708a;
  --primary: #1f6fbf;
  --primary-strong: #155896;
  --green: #1e8b57;
  --green-bg: #e9f7ef;
  --red: #c83d3d;
  --red-bg: #fff0f0;
  --amber: #a86200;
  --amber-bg: #fff5dc;
  --blue-bg: #eaf3ff;
  --violet: #6851b8;
  --violet-bg: #f0edff;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  background: #162238;
  color: #f7fbff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #2b83d3;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small,
.sidebar-note small {
  margin-top: 3px;
  color: #aab7c9;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  color: #dce7f6;
  text-decoration: none;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
}

.nav-list a:hover,
.nav-list a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  font-size: 12px;
}

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-note span,
.sidebar-note strong,
.sidebar-note small {
  display: block;
}

.sidebar-note span {
  color: #aab7c9;
}

.sidebar-note strong {
  margin: 6px 0 4px;
  line-height: 1.35;
}

.main {
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  min-height: 82px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.job-pill,
.chip,
.status,
.metric-note {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.job-pill {
  color: var(--primary-strong);
  background: var(--blue-bg);
  border: 1px solid #cce2fb;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}

.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.view-root {
  padding: 22px 28px 32px;
  display: grid;
  gap: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card,
.panel,
.table-card,
.calendar-card,
.flow-card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.metric-card span {
  color: var(--muted);
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
}

.metric-note {
  justify-self: start;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
}

.panel,
.table-card,
.calendar-card,
.flow-card {
  padding: 16px;
}

.panel-header,
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
}

.field input[readonly] {
  background: var(--panel-soft);
  color: var(--muted);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.button,
.ghost-button {
  border: 1px solid transparent;
  min-height: 36px;
  border-radius: 6px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.button {
  color: #fff;
  background: var(--primary);
}

.button:hover {
  background: var(--primary-strong);
}

.ghost-button {
  background: #fff;
  color: var(--primary);
  border-color: #bcd6f1;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: var(--panel-soft);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfdff;
}

.time-stack {
  display: grid;
  gap: 4px;
}

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

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
}

.status {
  font-weight: 600;
  border: 1px solid transparent;
}

.status-on {
  color: var(--green);
  background: var(--green-bg);
}

.status-away {
  color: var(--primary-strong);
  background: var(--blue-bg);
}

.status-leave {
  color: var(--violet);
  background: var(--violet-bg);
}

.status-loan {
  color: #287a7a;
  background: #e5f6f4;
}

.status-risk,
.status-error {
  color: var(--red);
  background: var(--red-bg);
}

.status-warn,
.status-pending {
  color: var(--amber);
  background: var(--amber-bg);
}

.status-done {
  color: var(--green);
  background: var(--green-bg);
}

.chip {
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line-soft);
  margin: 0 4px 4px 0;
}

.empty {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(78px, 1fr));
  gap: 8px;
}

.weekday,
.day-cell {
  border-radius: 8px;
}

.weekday {
  padding: 8px;
  text-align: center;
  color: var(--muted);
  background: var(--panel-soft);
  font-weight: 600;
}

.day-cell {
  min-height: 94px;
  border: 1px solid var(--line-soft);
  background: #fff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.day-cell.is-muted {
  opacity: 0.45;
}

.day-cell.is-selected {
  outline: 2px solid var(--primary);
}

.day-num {
  font-weight: 800;
}

.day-meta {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.detail-list,
.rule-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-list li,
.rule-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-list li:last-child,
.rule-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.field.span-2 {
  grid-column: span 2;
}

.field.span-3 {
  grid-column: span 3;
}

.upload-box {
  min-height: 72px;
  border: 1px dashed #9fb8d4;
  border-radius: 8px;
  background: #f7fbff;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.approval-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.flow-step {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
}

.flow-step strong,
.flow-step span {
  display: block;
}

.flow-step span {
  margin-top: 6px;
  color: var(--muted);
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.device-card {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 10px;
}

.device-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 20, 34, 0.36);
  z-index: 20;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: #fff;
  z-index: 21;
  box-shadow: -20px 0 40px rgba(23, 32, 51, 0.16);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.drawer-body {
  padding: 18px;
  overflow: auto;
  display: grid;
  gap: 16px;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

@media (max-width: 1120px) {
  .summary-grid,
  .device-grid,
  .approval-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-note {
    display: none;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .view-root {
    padding: 16px;
  }

  .summary-grid,
  .device-grid,
  .approval-flow,
  .form-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .field.span-2,
  .field.span-3 {
    grid-column: auto;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(40px, 1fr));
    gap: 4px;
  }

  .day-cell {
    min-height: 82px;
    padding: 5px;
  }

  .day-meta {
    font-size: 11px;
  }
}
