:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: 14px;
  --ink: #16262f;
  --text: var(--ink);
  --muted: #576a73;
  --quiet: #687d85;
  --line: #d9e3e6;
  --border: var(--line);
  --bg: #edf2f3;
  --surface: #fff;
  --panel: var(--surface);
  --surface-alt: #f5f8f9;
  --surface-muted: var(--surface-alt);
  --accent: #006a69;
  --primary: var(--accent);
  --accent-hover: #005554;
  --accent-soft: #e3f3ee;
  --danger: #a72c39;
  --danger-soft: #fcebed;
  --warning: #80521d;
  --warning-soft: #fff2da;
  --success: #176548;
  --success-soft: #e7f4eb;
  --rail: #142a34;
  --rail-hover: #24424d;
  --rail-active: #345760;
  --rail-text: #c7d9de;
  --rail-mark: #a4eccf;
  --radius: 8px;
  --shadow: 0 2px 6px #142a3408;
  --sidebar-width: 216px;
  --header-height: 62px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: var(--bg); color: var(--ink); line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button, input[type="checkbox"], select { accent-color: var(--accent); }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid #007b78; outline-offset: 3px; }
::selection { color: var(--rail); background: #c6eae1; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { line-height: 1.24; }
h1 { font-size: clamp(24px, 2.25vw, 34px); letter-spacing: -.035em; }
h2 { font-size: 19px; letter-spacing: -.022em; }
h3 { font-size: 15px; }
table { width: 100%; border-spacing: 0; }
caption { text-align: left; }

.visually-hidden, .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.page-head, .page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px 24px;
  margin-bottom: 20px;
}
.page-head p, .page-header p { color: var(--muted); margin-top: 6px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card, .panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-body, .panel-body { padding: 20px; }
.card + .card, .panel + .panel { margin-top: 16px; }
.card-head, .panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.numeric, .number, .money { font-variant-numeric: tabular-nums; }
.align-right { text-align: right; }
.nowrap { white-space: nowrap; }

.actions, .button-row, .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar { gap: 10px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
}
.btn:hover { border-color: #a8bfbe; background: var(--surface-alt); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .58; }
.btn-primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger, .btn.danger { border-color: #ebc7cc; color: var(--danger); }
.btn-danger:hover, .btn.danger:hover { border-color: #d6959e; background: var(--danger-soft); }
.btn-quiet, .btn.quiet { border-color: transparent; background: transparent; color: var(--accent); }
.btn-sm { min-height: 30px; padding: 5px 10px; font-size: .9rem; }

.field { display: grid; align-content: start; gap: 5px; min-width: 0; }
.field label, .field-label { color: var(--ink); font-size: .95rem; font-weight: 600; }
.field small, .help-text { color: var(--muted); font-size: .85rem; }
input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]), select, textarea {
  min-height: 36px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid #bfced1;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}
.field :is(input, select, textarea):not([type="checkbox"], [type="radio"]) { width: 100%; }
input::placeholder, textarea::placeholder { color: var(--quiet); opacity: 1; }
input[readonly], input:disabled, select:disabled { background: var(--surface-alt); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 16px; }
.form-error, .form-status { margin-top: 12px; }
.form-error { color: var(--danger); }
.form-status { color: var(--success); }
.field :is(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger); }

.table-wrap, .table-scroll { max-width: 100%; overflow: auto; }
.data-table { white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 9px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { font-size: .87rem; font-weight: 650; color: var(--muted); background: var(--surface-alt); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f3f9f8; }
.data-table .align-right { text-align: right; }
.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty-state h1, .empty-state h2 { margin-bottom: 10px; color: var(--ink); }
.empty-state p + p, .empty-state p + .btn { margin-top: 14px; }
.badge, .pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-alt); color: var(--muted); font-size: .85rem; white-space: nowrap; }
.badge-success, .badge.success { background: var(--success-soft); color: var(--success); }
.badge-warning, .badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger, .badge.danger { background: var(--danger-soft); color: var(--danger); }

.skip-link {
  position: fixed;
  z-index: 10;
  inset: 8px auto auto 8px;
  transform: translateY(-160%);
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--surface);
}
.skip-link:focus { transform: none; }

.workspace { display: grid; min-height: 100vh; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: auto;
  padding: 22px 15px 16px;
  background: var(--rail);
  color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 18px; font-weight: 700; letter-spacing: .015em; }
.sidebar .brand { min-height: 38px; margin: 0 0 22px 7px; }
.brand-mark { display: grid; flex: 0 0 auto; place-content: center; width: 34px; height: 34px; border-radius: 7px; background: var(--rail-mark); color: var(--rail); }
.brand-mark::before { width: 17px; height: 16px; content: ""; border: 2px solid currentColor; border-radius: 2px; background: linear-gradient(currentColor, currentColor) center 4px / 9px 1px no-repeat, linear-gradient(currentColor, currentColor) center 8px / 9px 1px no-repeat; }
.nav-groups, .nav-group { display: grid; gap: 4px; }
.nav-groups { gap: 18px; }
.nav-heading { padding: 0 9px 3px; color: #a7bfc8; font-size: 11px; font-weight: 600; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 7px 9px; border-radius: 6px; color: var(--rail-text); text-decoration: none; }
.nav-item:hover { background: var(--rail-hover); color: #fff; }
.nav-item[aria-current] { background: var(--rail-active); color: #fff; font-weight: 650; }
.nav-item[aria-current]::before { position: absolute; inset: 9px auto 9px 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--rail-mark); content: ""; }
.sidebar :focus-visible, .auth-side :focus-visible { outline-color: var(--rail-mark); }
.nav-icon { display: grid; flex: 0 0 auto; place-content: center; width: 19px; height: 19px; color: #afc7cf; font-family: "Segoe UI Symbol", sans-serif; font-size: 16px; font-weight: 400; line-height: 1; }
.nav-item[aria-current] .nav-icon { color: var(--rail-mark); }

.workspace-body { min-width: 0; }
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: var(--header-height);
  padding: 0 clamp(16px, 2.25vw, 36px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.breadcrumbs { display: flex; align-items: center; gap: 9px; color: var(--muted); white-space: nowrap; }
.breadcrumbs strong { color: var(--ink); font-weight: 650; }
.breadcrumbs span[aria-hidden="true"] { color: #819599; }
.menu-toggle { display: none; }
.nav-overlay { display: none; }
.user-ticket { position: relative; margin-left: auto; }
.user-ticket summary { display: flex; align-items: center; gap: 9px; max-width: 245px; min-height: 38px; padding: 4px 6px; border-radius: 6px; cursor: pointer; list-style: none; }
.user-ticket summary::-webkit-details-marker { display: none; }
.user-ticket summary:hover, .user-ticket[open] summary { background: var(--surface-alt); }
.user-ticket summary::after { width: 6px; height: 6px; margin: -3px 5px 0; flex: 0 0 auto; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); content: ""; }
.user-avatar { display: grid; place-content: center; flex: 0 0 auto; width: 31px; height: 31px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .9rem; font-weight: 700; }
.user-ticket-name { display: block; overflow: hidden; max-width: 118px; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; line-height: 1.2; }
.user-ticket-role { display: block; color: var(--muted); font-size: .77rem; line-height: 1.2; }
.user-menu { position: absolute; right: 0; z-index: 2; display: grid; gap: 2px; width: 180px; margin-top: 7px; padding: 5px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 20px #142a3429; }
.user-menu :is(a, button) { display: block; width: 100%; padding: 8px 11px; border: 0; border-radius: 4px; background: transparent; color: var(--ink); text-align: left; text-decoration: none; }
.user-menu :is(a, button):hover { background: var(--surface-alt); }

.workspace-content { min-width: 0; padding: clamp(18px, 2.25vw, 36px); }
.workspace-content:focus { outline: none; }
.route-view { min-width: 0; }
.route-loading { padding: 32px 0; color: var(--muted); }
.notifications { position: fixed; z-index: 6; right: 18px; bottom: 18px; display: flex; align-items: flex-end; flex-direction: column; gap: 8px; width: min(385px, calc(100% - 36px)); pointer-events: none; }
.toast { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; width: max-content; max-width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; background: var(--surface); box-shadow: 0 5px 20px #142a3420; pointer-events: auto; overflow-wrap: anywhere; }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast button { flex: 0 0 auto; padding: 0 4px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; }

.boot-screen { display: grid; min-height: 100vh; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; color: var(--muted); }
.boot-screen .brand-mark { margin-bottom: 2px; }
.auth-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(315px, .82fr) minmax(360px, 1fr); background: var(--surface); }
.auth-side { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 80px; padding: clamp(24px, 5vw, 76px); background: var(--rail); color: #fff; }
.auth-side::before, .auth-side::after { position: absolute; z-index: -1; inset: auto -20% -32% 22%; aspect-ratio: 1; border: 1px solid #a4eccf36; border-radius: 19%; transform: rotate(-28deg); content: ""; }
.auth-side::after { inset: auto -34% -41% 36%; background: #a4eccf13; }
.auth-side-copy { max-width: 25ch; margin-bottom: auto; color: #e4f1f1; font-size: clamp(29px, 4.3vw, 64px); letter-spacing: -.05em; line-height: 1.2; font-weight: 650; }
.auth-body { display: grid; place-content: center; justify-items: stretch; padding: 36px 24px; }
.auth-form { display: grid; gap: 18px; width: min(360px, calc(100vw - 48px)); }
.auth-form h1 { margin-bottom: 4px; }
.auth-form .field :is(input, select) { min-height: 43px; }
.auth-form .btn { min-height: 44px; margin-top: 4px; }
.auth-form .form-error { margin: -6px 0 0; }

.dialog { width: min(450px, calc(100% - 32px)); max-height: calc(100% - 32px); padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); box-shadow: 0 14px 45px #142a3440; }
.dialog::backdrop { background: #0c222b85; }
.team-member-dialog form { padding: 22px; }
.dialog-fields { display: grid; gap: 14px; margin-top: 19px; }
.team-member-dialog .actions { justify-content: flex-end; margin-top: 20px; }
.team-role-filter { max-width: 190px; }
.account-card { max-width: 540px; }
.account-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 18px; margin: 0; }
.account-details dt { color: var(--muted); }
.account-details dd { margin: 0; overflow-wrap: anywhere; }
.account-form { display: grid; gap: 14px; }
.account-form .form-error { margin-top: 0; }

@media (max-width: 840px) {
  :root { --sidebar-width: 177px; --header-height: 55px; }
  .sidebar { padding: 17px 10px; }
}

@media (max-width: 680px) {
  .workspace { display: block; }
  .sidebar { position: fixed; z-index: 5; inset: 0 auto 0 0; width: min(247px, calc(100% - 46px)); visibility: hidden; transform: translateX(-100%); }
  .workspace.nav-open .sidebar { visibility: visible; transform: none; box-shadow: 9px 0 20px #12272f40; }
  .workspace.nav-open .nav-overlay { position: fixed; z-index: 4; inset: 0; display: block; border: 0; background: #142a346b; }
  .menu-toggle { display: inline-grid; min-width: 38px; min-height: 38px; place-content: center; padding: 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); }
  .menu-toggle::before { width: 15px; height: 11px; border-block: 1.5px solid currentColor; background: linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat; content: ""; }
  .topbar { gap: 9px; padding-inline: 12px; }
  .breadcrumbs .crumb-home, .breadcrumbs .crumb-divider { display: none; }
  .workspace-content { padding: 17px 12px 24px; }
  .page-head, .page-header { flex-wrap: wrap; gap: 11px; margin-bottom: 15px; }
  .card-body, .panel-body, .card-head, .panel-head { padding: 14px; }
  .auth-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-side { gap: 0; padding: 18px 22px; }
  .auth-side-copy { display: none; }
  .auth-body { place-content: start center; padding-top: clamp(36px, 12vh, 88px); }
  .field :is(input, select, textarea), .auth-form .field :is(input, select) { font-size: 16px; }
}

@media print {
  .sidebar, .topbar, .notifications, .skip-link, .nav-overlay { display: none !important; }
  .workspace { display: block; }
  .workspace-content { padding: 0; }
  body { background: #fff; }
}
