:root {
  color-scheme: light;
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-subtle: #f8fafb;
  --surface-hover: #f1f6f5;
  --text: #17212b;
  --muted: #687583;
  --line: #dfe6ea;
  --line-strong: #cbd7dd;
  --primary: #0a7d70;
  --primary-strong: #075f56;
  --primary-soft: #e5f4f1;
  --danger: #c63d36;
  --danger-soft: #fff0ef;
  --warning: #b76822;
  --warning-soft: #fff6ed;
  --expired: #f1f3f5;
  --shadow-sm: 0 1px 2px rgba(16, 32, 40, 0.04), 0 8px 24px rgba(16, 32, 40, 0.045);
  --shadow-lg: 0 22px 60px rgba(16, 32, 40, 0.18);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; white-space: nowrap; }
a { color: inherit; text-decoration: none; }
button:disabled { cursor: not-allowed; opacity: 0.46; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(8, 119, 107, 0.18);
  outline-offset: 2px;
}
.hidden { display: none !important; }
.shell { min-height: 100vh; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: #edf4f2;
}

.login-panel {
  width: min(420px, 100%);
  padding: 36px;
  background: var(--surface);
  border: 1px solid #d7e4e1;
  border-top: 4px solid var(--primary);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; line-height: 1.25; }
h2 { font-size: 21px; line-height: 1.3; }

.stack { display: grid; gap: 18px; margin-top: 30px; }
label { display: grid; gap: 8px; color: #52606d; font-size: 13px; font-weight: 700; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
input::placeholder, textarea::placeholder { color: #9aa6af; }
textarea { min-height: 80px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #afc0c7; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8, 119, 107, 0.12); }

.app-view {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 32px 32px 48px;
}

.topbar, .toolbar, .pager, .modal-head, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

.topbar {
  min-height: 92px;
  margin: -32px -32px 28px;
  padding: 18px max(32px, calc((100vw - 1396px) / 2));
  color: #fff;
  background: #173d39;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; background: #d7f0e8; border-radius: 7px; }
.brand-mark span { width: 14px; height: 14px; background: #0b7468; border-radius: 3px; box-shadow: 7px 7px 0 -4px #d58d3c; }
.topbar .eyebrow { margin-bottom: 3px; color: #b9dcd4; font-size: 10px; }
.topbar h1 { font-size: 25px; color: #fff; }
.topbar-actions, .modal-actions { display: flex; gap: 10px; }
.topbar .secondary-btn { color: #f6fffc; background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.24); }
.topbar .secondary-btn:hover { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.38); }
.download-extension { display: inline-flex; align-items: center; justify-content: center; }
.topbar .ghost-btn { color: #cce0db; }
.topbar .ghost-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn, .icon-btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 14px;
  font-weight: 750;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.primary-btn { color: #fff; background: var(--primary); box-shadow: 0 1px 1px rgba(0, 63, 57, 0.2); }
.primary-btn:hover { background: var(--primary-strong); }
.secondary-btn { color: #33414b; background: var(--surface); border-color: var(--line-strong); }
.secondary-btn:hover { background: var(--surface-hover); border-color: #aabdc0; }
.ghost-btn { color: var(--muted); background: transparent; }
.ghost-btn:hover { color: var(--text); background: var(--surface-hover); }
.danger-btn { color: var(--danger); background: #fff; border-color: #e7b8b5; }
.danger-btn:hover { background: var(--danger-soft); border-color: #d78a85; }
.compact { min-height: 36px; padding: 0 12px; font-size: 13px; }
.toolbar .compact { min-width: 70px; }
.selection-meta { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 650; white-space: nowrap; }
.icon-btn { display: grid; width: 36px; padding: 0; place-items: center; color: var(--muted); background: var(--surface-subtle); font-size: 24px; line-height: 1; }
.icon-btn:hover { color: var(--text); background: #edf1f2; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-item {
  position: relative;
  display: grid;
  min-height: 126px;
  align-content: start;
  gap: 5px;
  padding: 19px 20px 16px;
  overflow: hidden;
  color: var(--text);
  text-align: left;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.summary-item::before { position: absolute; top: 0; right: 0; bottom: 0; width: 4px; content: ""; background: #8fa6a4; }
.summary-item .summary-label { color: var(--muted); font-size: 13px; font-weight: 750; }
.summary-item strong { margin-top: 5px; font-size: 34px; line-height: 1; letter-spacing: 0; }
.summary-note { align-self: end; margin-top: auto; color: #82909a; font-size: 12px; font-weight: 600; }
.summary-item:hover { border-color: #a9bfc0; transform: translateY(-1px); }
.summary-item.is-active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-sm); }
.summary-item.is-active::before { background: var(--primary); }
.summary-item.danger { background: var(--danger-soft); border-color: #f1c7c4; }
.summary-item.danger::before { background: var(--danger); }
.summary-item.warning { background: var(--warning-soft); border-color: #f0d4b9; }
.summary-item.warning::before { background: var(--warning); }
.summary-item.muted { background: var(--expired); border-color: #dce2e5; }
.summary-item.muted::before { background: #79868d; }

.toolbar {
  min-height: 68px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.filter-group, .action-group { display: flex; align-items: center; gap: 9px; min-width: 0; }
.filter-group { flex: 1 1 500px; }
.action-group { margin-left: auto; }
.toolbar select { width: auto; min-width: 126px; }
#projectFilter { min-width: 168px; }
.search-wrap { display: flex; flex: 1 1 250px; align-items: center; gap: 8px; min-width: 220px; padding: 0 11px; color: #86949e; background: var(--surface-subtle); border: 1px solid var(--line); border-radius: 6px; }
.search-wrap:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(8, 119, 107, 0.1); }
.search-wrap input { min-width: 0; padding-left: 0; background: transparent; border: 0; box-shadow: none; }

.toolbar-divider { width: 1px; height: 24px; margin: 0 2px; background: var(--line); }
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.table-head { display: flex; align-items: center; min-height: 73px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.table-head h2 { font-size: 16px; font-weight: 800; }
.table-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
table { width: 100%; min-width: 1020px; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid #e9eef0; text-align: left; vertical-align: middle; font-size: 13px; }
th { position: sticky; top: 0; z-index: 1; color: #71808a; background: #f6f8f9; font-size: 11px; font-weight: 800; letter-spacing: 0.055em; text-transform: uppercase; }
tbody tr { transition: background 100ms ease; }
tbody tr:hover { background: #f5faf8; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.expired { color: #697780; background: var(--expired); }
tbody tr.expired:hover { background: #e9edef; }
tbody tr.due7 { background: #fff6f5; }
tbody tr.due7:hover { background: #ffefed; }
tbody tr.due15 { background: #fffaf4; }
tbody tr.due15:hover { background: #fff4e9; }
.select-col { width: 46px; min-width: 46px; text-align: center; }
.select-col input { width: 16px; height: 16px; min-height: auto; padding: 0; accent-color: var(--primary); }
.cycle-col { min-width: 104px; }
.status-col { min-width: 128px; }
.item-name { display: grid; min-width: 170px; gap: 4px; }
.item-name strong { color: #1e2a33; font-size: 13px; }
tbody tr.expired .item-name strong { color: #59656d; }
.item-name small, .muted-text { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 5px; color: #5d6a73; background: #edf2f3; font-size: 12px; font-weight: 750; }
.badge.danger { color: #fff; background: var(--danger); }
.badge.warning { color: #9a4e14; background: #ffe8d1; }
.badge.expired { color: #5e6a71; background: #d9dfe2; }
.state-line, .empty-state { padding: 32px; color: var(--muted); text-align: center; }

.pager { margin-top: 14px; color: var(--muted); justify-content: flex-end; }
.pager-controls { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.pager-controls select { width: auto; min-width: 104px; }
#pageInfo { min-width: 84px; text-align: center; font-size: 13px; font-weight: 650; }

dialog { width: min(760px, calc(100vw - 28px)); padding: 0; color: var(--text); background: var(--surface); border: 0; border-radius: 8px; box-shadow: var(--shadow-lg); }
#batchRenewDialog { width: min(460px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(19, 33, 40, 0.48); }
.modal-form { padding: 24px; }
.compact-modal { display: grid; gap: 18px; }
.modal-head { padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.wide { grid-column: 1 / -1; }
.modal-actions { justify-content: flex-end; padding-top: 18px; margin-top: 22px; border-top: 1px solid var(--line); }
.compact-modal .modal-actions { margin-top: 2px; }
.dialog-note { margin: 0; color: var(--muted); line-height: 1.65; }
.radio-grid { display: grid; gap: 9px; }
.radio-grid label { display: flex; align-items: center; gap: 10px; min-height: 45px; padding: 0 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.radio-grid label:hover { background: var(--surface-hover); border-color: #9fb7b5; }
.radio-grid input { width: 16px; min-height: auto; padding: 0; accent-color: var(--primary); }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 10000; display: grid; gap: 10px; }
.toast { width: min(360px, calc(100vw - 40px)); padding: 12px 14px; color: #fff; background: #26343a; border-radius: 6px; box-shadow: var(--shadow-lg); font-weight: 700; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { align-items: stretch; flex-direction: column; }
  .filter-group, .action-group { flex-wrap: wrap; }
  .action-group { margin-left: 0; }
}

@media (max-width: 760px) {
  .app-view { padding: 18px 14px 28px; }
  .topbar { min-height: auto; margin: -18px -14px 18px; padding: 14px; }
  .brand-lockup { gap: 9px; min-width: 0; }
  .brand-mark { width: 36px; height: 36px; flex: 0 0 36px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { font-size: 20px; white-space: nowrap; }
  .topbar-actions { gap: 5px; }
  .topbar-actions button, .topbar-actions .download-extension { padding: 0 10px; }
  .toolbar { align-items: stretch; }
  .filter-group, .action-group, .toolbar select, .search-wrap { width: 100%; }
  .filter-group, .action-group { align-items: stretch; flex-direction: column; }
  .action-group { gap: 8px; }
  .search-wrap { flex: 0 0 auto; min-height: 42px; }
  .toolbar-divider { display: none; }
  .toolbar .compact { min-width: 0; }
  .summary-grid, .form-grid { grid-template-columns: 1fr; }
  .summary-item { min-height: 88px; }
  .pager, .pager-controls { align-items: stretch; flex-direction: column; width: 100%; }
  .pager-controls > * { width: 100%; }
  #pageInfo { padding: 8px 0; }
  .modal-form { padding: 18px; }
  .modal-head { align-items: flex-start; }
  .table-head { min-height: 64px; padding: 12px 14px; }
}
