:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --line: #d7dee5;
  --line-strong: #bdc8d2;
  --text: #17202a;
  --muted: #637083;
  --accent: #146c63;
  --accent-strong: #0c514a;
  --danger: #b23b3b;
  --danger-weak: #f7e7e7;
  --ok: #176f4d;
  --warn: #93660f;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
}

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

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: var(--surface-2);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.danger:hover {
  background: #922d2d;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.12);
}

textarea {
  min-height: 118px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

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

.hidden {
  display: none !important;
}

.brandMark {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #24a39a, #146c63);
  color: #fff;
  font-weight: 700;
  flex: none;
}

.brandMark.small {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.loginView {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginCard {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
  display: grid;
  gap: 22px;
}

.loginHero {
  display: flex;
  align-items: center;
  gap: 14px;
}

.loginForm {
  display: grid;
  gap: 14px;
}

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

.checkRow input {
  width: 16px;
  height: 16px;
  flex: none;
}

.advancedLogin {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.advancedLogin summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.advancedLogin[open] {
  display: grid;
  gap: 12px;
}

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

.loginActions,
.topbarActions,
.toolbar,
.headActions,
.backupActionRow {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inlineStatus {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.appShell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brandText {
  display: grid;
  gap: 2px;
}

.status,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.status.ok,
.badge.ok {
  border-color: rgba(23, 111, 77, 0.24);
  background: #e9f5f0;
  color: var(--ok);
}

.status.error,
.badge.danger {
  border-color: rgba(178, 59, 59, 0.25);
  background: var(--danger-weak);
  color: var(--danger);
}

.badge.warn {
  border-color: rgba(147, 102, 15, 0.25);
  background: #f8efd9;
  color: var(--warn);
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 22px 0;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  border-radius: 6px 6px 0 0;
}

.tab:hover {
  background: #e9edf1;
  color: var(--text);
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  border-bottom-color: var(--surface);
}

main {
  padding: 18px 22px 28px;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

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

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.1;
}

.workspaceGrid {
  display: grid;
  grid-template-columns: minmax(560px, 1.2fr) minmax(420px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.backupLayout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.backupFullRow {
  grid-column: 1 / -1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(440px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.surface,
.subSurface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.surface {
  padding: 16px;
}

.subSurface {
  padding: 14px;
}

.sectionHead,
.detailHead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

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

.issueForm {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wideField {
  grid-column: span 2;
}

.issueForm .wideField {
  grid-column: span 4;
}

.toolbar {
  margin-top: 14px;
  flex-wrap: wrap;
}

.toolbar.wrap {
  align-items: stretch;
}

.tokenBox {
  margin-top: 14px;
}

.stickyTools {
  margin-bottom: 12px;
}

.tableWrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compactTable,
.deviceTable,
.small {
  border: none;
  background: transparent;
}

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

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

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  position: sticky;
  top: 0;
}

tr.selected {
  background: #eef6f4;
}

.emptyRow td {
  color: var(--muted);
  text-align: center;
  padding: 18px 12px;
}

.resultOk {
  color: var(--ok);
  font-weight: 600;
}

.resultDenied {
  color: var(--danger);
  font-weight: 600;
}

.tableCheck {
  color: var(--text);
}

.feedbackCell {
  display: grid;
  gap: 6px;
  min-width: 260px;
}

.feedbackCell strong {
  color: var(--text);
  font-size: 14px;
}

.feedbackContent {
  display: grid;
  gap: 8px;
}

.feedbackContent p {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
}

.feedbackImageLink {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
}

.feedbackImage {
  display: block;
  max-width: min(420px, 100%);
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.detail {
  position: sticky;
  top: 92px;
}

.rawDetail {
  margin-top: 14px;
}

.rawDetail summary {
  color: var(--muted);
  cursor: pointer;
}

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

.backupSummary div,
.backupMeta {
  color: var(--muted);
}

.backupSummary strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
}

.backupMeta {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  min-height: 52px;
}

.backupOptionLabel,
.backupMetaHint {
  color: var(--muted);
}

.backupCheckRow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
}

.backupCheckRow input {
  width: 16px;
  height: 16px;
  flex: none;
}

.backupExportCard,
.restoreZone {
  min-height: 330px;
}

.restoreStack {
  display: grid;
  gap: 12px;
}

.backupPreviewCard {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.backupPreviewTitle {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 10px;
}

.backupPreviewGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.backupPreviewItem span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.backupPreviewItem strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 15px;
}

.backupPreviewEmpty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.fileInfo,
.dangerNotice {
  font-size: 12px;
  color: var(--muted);
}

.dangerNotice {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid rgba(178, 59, 59, 0.15);
  background: var(--danger-weak);
  color: #7e2d2d;
}

pre {
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .topbar {
    display: block;
  }

  .topbarActions {
    margin-top: 12px;
  }

  .workspaceGrid,
  .backupLayout,
  .split {
    grid-template-columns: 1fr;
  }

  .backupFullRow {
    grid-column: auto;
  }

  .detail {
    position: static;
  }
}

@media (max-width: 760px) {
  .loginView,
  main {
    padding: 14px;
  }

  .loginCard,
  .topbar {
    padding: 14px;
  }

  .loginHero,
  .brand,
  .sectionHead,
  .detailHead,
  .topbarActions,
  .loginActions {
    display: grid;
    gap: 8px;
  }

  .metrics,
  .backupSummary,
  .backupPreviewGrid,
  .formGrid,
  .issueForm {
    grid-template-columns: 1fr;
  }

  .backupMeta {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .wideField,
  .issueForm .wideField {
    grid-column: span 1;
  }

  .toolbar button,
  .headActions button,
  .loginActions button,
  .topbarActions button {
    width: 100%;
  }
}
