:root {
  color-scheme: light dark;
  --bg: #f6f7f6;
  --surface: #ffffff;
  --elevated: #eef1ef;
  --text: #1b1f1c;
  --muted: #5a635d;
  --line: #d9dfd9;
  --accent: #117a4b;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --radius-lg: 10px;
  --radius-sm: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111412;
    --surface: #191d1a;
    --elevated: #222824;
    --text: #eef2ef;
    --muted: #a1aba4;
    --line: #2d3530;
    --accent: #34a874;
    --accent-ink: #0c1711;
    --danger: #f87171;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: clip;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--elevated);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent);
  opacity: 0.92;
}

.btn-full {
  width: 100%;
  min-height: 44px;
  font-size: 14px;
}

.portal-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  height: 48px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow-x: auto;
}

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

.portal-brand {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.app-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.nav-tab:hover {
  background: var(--elevated);
  color: var(--text);
}

.nav-tab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

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

.user-pill {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.portal-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.overview-view {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 36px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.error-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--elevated);
  color: var(--danger);
  font-size: 12px;
}

.notice-banner {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--elevated);
  color: var(--accent);
  font-size: 12px;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.app-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.app-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.app-card-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.status-chip {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--elevated);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-chip.is-online {
  color: var(--accent);
}

.status-chip.is-offline {
  color: var(--danger);
}

.app-card-actions {
  display: flex;
  gap: 8px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.9fr);
  gap: 16px;
  margin-bottom: 24px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  min-width: 0;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}

th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.workspace-frame {
  flex: 1;
  width: 100%;
  height: calc(100vh - 48px);
  border: 0;
  background: var(--surface);
}

.board-summary {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.board-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.board-controls input[type="search"] {
  width: 220px;
}

.board-controls select {
  width: 130px;
}

.board-projects {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.board-panel {
  margin-bottom: 24px;
}

.board-create-form {
  display: grid;
  grid-template-columns: 170px minmax(200px, 1.4fr) 96px minmax(160px, 1fr) auto;
  gap: 8px;
  margin-bottom: 16px;
}

.board-col-check {
  width: 64px;
}

.board-col-meta {
  width: 220px;
}

.board-col-priority {
  width: 84px;
}

.board-col-time {
  width: 156px;
}

.board-col-action {
  width: 82px;
}

.board-task-title {
  font-weight: 600;
}

.board-task-title.is-done {
  color: var(--muted);
  text-decoration: line-through;
}

.board-task-desc {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.board-meta-line {
  font-size: 12px;
  color: var(--muted);
}

.board-empty {
  padding: 20px 8px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 960px) {
  .apps-grid {
    grid-template-columns: 1fr;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .board-create-form {
    grid-template-columns: 1fr;
  }
  .board-controls input[type="search"],
  .board-controls select {
    width: 100%;
  }
}
