:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #202725;
  background: #f6f8f7;
  font-size: 14px;
  letter-spacing: 0;
  --line: #dce3df;
  --muted: #64716a;
  --green: #08785b;
}
* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, a, select, summary, input[type="checkbox"] { cursor: pointer; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; border: 1px solid #cdd8d1; border-radius: 5px;
  background: white; color: #26372e; padding: 8px 13px; white-space: nowrap;
  transition: background-color 150ms, border-color 150ms;
}
button:hover { background: #edf3ef; border-color: #9aada0; }
button:disabled { opacity: .42; cursor: not-allowed; }
button.primary { color: white; background: var(--green); border-color: var(--green); }
button.primary:hover { background: #056447; }
.icon-button { width: 36px; height: 36px; min-height: 36px; padding: 8px; flex: 0 0 auto; }
svg { width: 18px; height: 18px; flex: 0 0 auto; stroke-width: 1.7; }
:focus-visible { outline: 2px solid #0b8d73; outline-offset: 3px; }
input:not([type="checkbox"]), select, textarea {
  width: 100%; min-height: 40px; border: 1px solid #bfcfc5; border-radius: 5px;
  padding: 9px 11px; color: #202e26; background: white;
}
textarea { line-height: 1.6; resize: vertical; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--green); }
[aria-invalid="true"] { border-color: #bc3030; }
label { display: grid; gap: 9px; font-weight: 500; }
h1, h2, p { margin: 0; }
h1 { font-size: 25px; line-height: 1.35; font-weight: 650; }
h2 { font-size: 19px; line-height: 1.4; }
.subtle { color: var(--muted); font-size: 13px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; }
.error { color: #b82f32; font-size: 13px; min-height: 18px; overflow-wrap: anywhere; }
.workspace { display: grid; grid-template-columns: 208px minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.sidebar {
  background: white; border-right: 1px solid var(--line); padding: 26px 16px 20px;
  display: flex; flex-direction: column; gap: 36px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; font-weight: 650; padding: 0 4px; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }
nav { display: grid; gap: 7px; }
nav a {
  display: flex; align-items: center; gap: 11px; padding: 13px 14px; border-radius: 5px;
  color: #526057; text-decoration: none;
}
nav a:hover { background: #f1f5f2; }
nav a[aria-current="page"] { color: #08674f; background: #eaf4ee; font-weight: 600; }
.sidebar-bottom { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 12px; color: var(--muted); font-size: 12px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #16956d; }
.main-shell { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar { height: 72px; display: flex; align-items: center; gap: 20px; padding: 0 32px; background: white; border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; font-weight: 500; }
#account-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
main { padding: 24px 32px; min-height: 0; overflow: auto; }
.view { max-width: 1736px; }
.licenses-view { height: 100%; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.licenses-view .table-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.licenses-view thead { position: sticky; top: 0; z-index: 1; }
.licenses-view .empty { border: 0; }
.licenses-view .pagination { padding: 12px 0 0; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-heading p { margin-top: 8px; }
.heading-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.unsaved { color: #936116; font-size: 12px; }
.filters { display: grid; grid-template-columns: minmax(120px, 340px) 140px auto 36px 36px; align-items: center; gap: 10px; justify-content: start; margin: 0 0 12px; }
.table-scroll { width: 100%; overflow-x: auto; background: white; border-block: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
th { background: #f0f4f1; color: #59685f; font-size: 12px; font-weight: 500; white-space: nowrap; height: 44px; }
td, th { padding: 12px 16px; border-bottom: 1px solid #e6ebe7; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8faf8; }
td { height: 65px; }
.licenses-table { min-width: 860px; }
.device-cell { white-space: nowrap; font-size: 12px; }
.openid { display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #617067; }
.date-cell { white-space: nowrap; font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { color: #0d7654; }
.badge.expired { color: #946528; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 20px 0; }
.pagination > span:first-child { margin-right: auto; }
.pagination select { width: 110px; font-size: 12px; }
.page-number { min-width: 48px; text-align: center; font-size: 13px; }
.rules-table { min-width: 860px; table-layout: fixed; }
.rules-table th:nth-child(1) { width: 62px; }
.rules-table th:nth-child(2) { width: 22%; }
.rules-table th:nth-child(3) { width: 90px; }
.rules-table th:nth-child(4) { width: 100px; }
.rules-table th:nth-child(6) { width: 62px; }
.rules-table th:last-child { width: 170px; }
.keyword-cell, .reply-cell { overflow-wrap: anywhere; }
.keyword-cell strong { font-weight: 550; }
.order-cell { color: #7a8980; font-size: 12px; }
.row-tools { display: flex; gap: 2px; }
.row-tools .icon-button { border-color: transparent; background: transparent; }
.row-tools .icon-button:hover { background: #e9efeb; }
.line-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: #66716a; }
.disabled-row .keyword-cell, .disabled-row .reply-cell { opacity: .5; }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); border-block: 1px solid var(--line); }
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #f3f6f4; }
.login-form { width: min(100%, 360px); display: grid; gap: 22px; }
.login-form h1 { font-size: 27px; margin-top: 8px; }
.login-form > .subtle { margin-top: -13px; }
.login-form .error { margin-top: -10px; }
.login-form > button { min-height: 44px; }
.modal {
  width: min(680px, calc(100% - 32px)); max-height: calc(100dvh - 40px);
  margin: auto; padding: 0; border: 1px solid #b7c6bd; border-radius: 8px;
  color: #202725; box-shadow: 0 18px 65px #142a1d30; overflow: hidden;
}
.modal[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.modal::backdrop { background: #152a2160; }
.modal-head, .modal-foot { display: flex; align-items: center; gap: 10px; padding: 16px 22px; background: white; }
.modal-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-body { overflow-y: auto; min-height: 0; padding: 24px; }
.editor-form { display: grid; gap: 23px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.check-field { display: flex; align-items: center; font-weight: 400; }
.byte-count { text-align: right; font-size: 12px; font-weight: 400; }
.detail-content { display: grid; gap: 24px; }
.details { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 17px 20px; margin: 0; font-size: 13px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.ticket-text { font-size: 12px; background: #f6f9f7; resize: vertical; }
.original-reply { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.7; margin-bottom: 0; }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px)); padding: 12px 20px; border-radius: 6px;
  background: #173e2e; color: white; box-shadow: 0 5px 20px #15362320; z-index: 10;
  overflow-wrap: anywhere;
}
.toast.is-error { background: #94383b; }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: 180px minmax(0, 1fr); }
  main { padding: 26px 22px; }
  .topbar { padding: 0 22px; }
}
@media (max-width: 780px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { padding: 14px 20px 0; border-right: 0; border-bottom: 1px solid var(--line); gap: 16px; }
  .brand small { display: none; }
  .brand img { width: 28px; height: 28px; }
  nav { display: flex; gap: 12px; }
  nav a { border-radius: 5px 5px 0 0; padding: 12px 18px; }
  .sidebar-bottom { display: none; }
  .topbar { height: 52px; padding: 0 20px; gap: 12px; }
  .topbar-title { font-size: 12px; color: var(--muted); }
  main { padding: 24px 20px; }
}
@media (max-width: 520px) {
  .sidebar { padding-inline: 16px; }
  main { padding: 22px 16px; }
  h1 { font-size: 23px; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
  .heading-tools { width: 100%; justify-content: flex-start; gap: 8px; }
  .heading-tools .unsaved { margin-right: auto; }
  .filters { grid-template-columns: minmax(0, 1fr) auto 42px 42px; gap: 8px; }
  .filters > input { grid-column: 1 / -1; }
  .pagination { gap: 6px; flex-wrap: wrap; }
  .pagination > span:first-child { width: 100%; margin-right: 0; }
  .pagination select { width: 100px; }
  .icon-button { width: 42px; height: 42px; min-height: 42px; }
  input:not([type="checkbox"]), select, textarea { font-size: 16px; }
  .modal { width: calc(100% - 16px); max-height: calc(100dvh - 20px); }
  .modal-head, .modal-foot { padding: 12px 16px; }
  .modal-head h2 { font-size: 18px; }
  .modal-body { padding: 20px 16px; }
  .modal-foot { gap: 8px; }
  .modal-foot button { padding: 9px 10px; font-size: 12px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .details { grid-template-columns: 80px minmax(0, 1fr); gap: 16px 12px; }
  .ticket-text { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
