:root {
  color-scheme: light;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --primary: #1d4ed8;
  --primary-hover: #2563eb;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --danger: #dc2626;
  --page: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --inverse: #ffffff;
  --border: #e2e8f0;
  --border-soft: #edf2f7;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  font-family: var(--font-family);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 0;
  min-height: 100%;
  margin: 0;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-family);
}

body {
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--page);
}

.login-layout {
  width: min(920px, 100%);
  min-height: 520px;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(180deg, rgba(29, 78, 216, 0.18), rgba(29, 78, 216, 0) 36%),
    var(--sidebar);
  color: var(--inverse);
  padding: 30px;
}

.login-aside-brand,
.sidebar-brand,
.user-chip,
.topbar-right {
  display: flex;
  align-items: center;
}

.login-aside-brand {
  gap: 12px;
}

.brand-mark,
.sidebar-brand-mark {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--inverse);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
}

.login-aside-brand strong,
.sidebar-brand strong {
  display: block;
  font-size: 15px;
  line-height: 20px;
}

.login-aside-brand span,
.sidebar-brand span {
  display: block;
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
  line-height: 18px;
}

.login-aside-copy {
  max-width: 360px;
}

.login-aside-copy h1 {
  margin-bottom: 10px;
  color: var(--inverse);
  font-size: 28px;
  line-height: 1.25;
}

.login-aside-copy p {
  color: rgba(255, 255, 255, 0.68);
  font-size: 14px;
  line-height: 1.8;
}

.login-meta {
  display: grid;
  gap: 10px;
}

.login-meta div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.login-meta span {
  color: rgba(255, 255, 255, 0.52);
}

.login-meta strong {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 650;
}

.login-form-panel {
  align-self: center;
  width: min(360px, calc(100% - 48px));
  justify-self: center;
}

.login-head {
  margin-bottom: 24px;
}

.login-head h2 {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.3;
}

.login-head p {
  color: var(--text-secondary);
}

.form-stack {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: #111827;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(29, 78, 216, 0.16);
  border-color: var(--primary);
}

select:focus {
  outline: 3px solid rgba(29, 78, 216, 0.16);
  border-color: var(--primary);
}

.form-stack button {
  height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--inverse);
  font-weight: 700;
}

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

.alert {
  margin-bottom: 18px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
}

.alert-error {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.text-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.app-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  background: var(--page);
}

.sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(29, 78, 216, 0.08), rgba(29, 78, 216, 0) 34%),
    var(--sidebar);
  color: var(--inverse);
}

.sidebar-brand {
  height: 60px;
  gap: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0 14px;
}

.sidebar-brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  padding: 12px 8px;
}

.sidebar-nav a,
.nav-section {
  min-height: 40px;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
  padding: 0 10px;
}

.sidebar-nav a {
  gap: 10px;
  color: rgba(255, 255, 255, 0.74);
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-nav a.active {
  background: rgba(29, 78, 216, 0.96);
  color: #ffffff;
  font-weight: 650;
}

.sidebar-nav a.muted {
  color: rgba(255, 255, 255, 0.46);
}

.nav-section {
  min-height: 30px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 12px;
  font-weight: 700;
}

.nav-icon {
  width: 24px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 700;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr);
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  padding: 0 22px;
  backdrop-filter: blur(12px);
}

.page-heading {
  min-width: 0;
}

.page-heading h1 {
  color: var(--text);
  font-size: 16px;
  line-height: 22px;
}

.page-heading p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 18px;
}

.topbar-right {
  flex-shrink: 0;
  gap: 14px;
}

.status-pill {
  height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  background: #f0fdf4;
  color: #15803d;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 650;
}

.user-chip {
  gap: 8px;
  color: var(--text-secondary);
}

.user-chip strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 18px;
}

.user-chip span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 16px;
}

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--inverse);
  font-size: 12px;
  font-weight: 800;
}

.link-button {
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 650;
}

.main {
  min-width: 0;
  padding: 22px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  min-height: 110px;
  padding: 18px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

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

.panel {
  overflow: hidden;
}

.panel-header {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border-soft);
  padding: 0 18px;
}

.panel-header h2 {
  color: var(--text);
  font-size: 16px;
  line-height: 22px;
}

.panel-header span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-list {
  margin: 0;
  padding: 2px 18px;
}

.detail-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 16px;
  border-bottom: 1px solid var(--border-soft);
  padding: 15px 0;
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list dt {
  color: var(--text-muted);
  font-weight: 700;
}

.detail-list dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.status-list {
  display: grid;
  gap: 0;
  padding: 4px 18px;
}

.status-list div {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 0;
}

.status-list div:last-child {
  border-bottom: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.status-list strong {
  color: var(--text);
  font-weight: 650;
}

.status-list em {
  color: var(--success);
  font-size: 13px;
  font-style: normal;
  font-weight: 650;
}

.alert-success {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr) minmax(260px, 0.75fr);
  gap: 16px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.form-actions {
  display: flex;
  align-items: end;
}

.form-actions button,
.compact-form button {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--inverse);
  font-weight: 700;
}

.compact-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

td {
  color: var(--text);
  font-size: 13px;
}

.table-status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  background: #f0fdf4;
  color: #15803d;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 650;
}

.list-stack {
  display: grid;
  padding: 4px 18px;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(80px, 0.7fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  padding: 13px 0;
}

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

.list-item strong {
  color: var(--text);
  font-size: 13px;
}

.list-item span {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item em {
  color: var(--text-muted);
  font-size: 12px;
  font-style: normal;
}

.approval-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.42fr) minmax(0, 1fr);
  gap: 16px;
}

.approval-list-panel {
  min-width: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 18px;
}

.tabs a {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.tabs a.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.table-title {
  color: var(--text);
  font-weight: 700;
}

.priority-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-left: 6px;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  color: #c2410c;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-pending {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.status-approved {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.status-rejected {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.status-cancelled {
  background: var(--surface-muted);
  color: var(--text-muted);
}

.table-link {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.empty-cell {
  color: var(--text-muted);
  text-align: center;
}

.approval-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.description-box {
  border-top: 1px solid var(--border-soft);
  padding: 18px;
}

.description-box strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.description-box p {
  color: var(--text-secondary);
  line-height: 1.8;
}

.compact-form-separated {
  border-top: 1px solid var(--border-soft);
}

.danger-button {
  background: var(--danger) !important;
}

.done-box {
  color: var(--text-muted);
  padding: 18px;
}

.approval-log-panel {
  margin-top: 16px;
}

.timeline {
  display: grid;
  padding: 4px 18px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
  padding: 14px 0;
}

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

.timeline-item strong {
  color: var(--text);
}

.timeline-item p {
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 13px;
}

.timeline-item em {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: normal;
}

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

  .sidebar {
    min-height: auto;
  }

  .sidebar-brand {
    height: auto;
    padding: 14px 16px;
  }

  .workspace {
    grid-template-rows: auto minmax(0, 1fr);
  }

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

  .topbar-right {
    flex-wrap: wrap;
  }

  .metric-grid,
  .content-grid,
  .settings-grid,
  .data-grid,
  .approval-layout,
  .approval-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .auth-page {
    padding: 16px;
  }

  .login-layout {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .login-aside {
    gap: 26px;
    padding: 24px;
  }

  .login-aside-copy h1 {
    font-size: 24px;
  }

  .login-form-panel {
    width: 100%;
    padding: 24px;
  }

  .main {
    padding: 16px;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
