:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1f2633;
  --muted: #6d7788;
  --soft: #98a2b3;
  --line: #e6ebf2;
  --blue: #1677ff;
  --blue-soft: #eaf3ff;
  --green: #18a058;
  --red: #d92d20;
  --amber: #b76e00;
  --shadow: 0 10px 30px rgba(26, 40, 60, .06);
}

* {
  box-sizing: border-box;
}

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

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: linear-gradient(180deg, #eef6ff 0, #f6f8fb 45%, #f6f8fb 100%);
}

.login-panel {
  width: min(100%, 25rem);
  display: grid;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.eyebrow {
  color: var(--blue);
  font-size: .76rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.15;
}

h2 {
  font-size: 1.1rem;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

form {
  margin: 0;
}

.login-panel form {
  display: grid;
  gap: .9rem;
}

label {
  display: grid;
  gap: .34rem;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 760;
}

.auto-expiry-field {
  display: grid;
  gap: .34rem;
  min-width: 0;
}

.auto-expiry-field span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 760;
}

.auto-expiry-field strong {
  min-height: 2.45rem;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--text);
  padding: .6rem .7rem;
  font-size: .84rem;
  font-weight: 720;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(22, 119, 255, .55);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, .1);
}

textarea {
  min-height: 4.6rem;
  resize: vertical;
  line-height: 1.55;
}

button,
.link-actions a {
  min-height: 2.15rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: .42rem .78rem;
  font-size: .82rem;
  font-weight: 740;
  text-decoration: none;
  cursor: pointer;
}

button.is-danger {
  border-color: rgba(217, 45, 32, .28);
  color: var(--red);
}

button[type="submit"] {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

button:hover,
.link-actions a:hover {
  border-color: rgba(22, 119, 255, .4);
  color: var(--blue);
}

button[type="submit"]:hover {
  color: #fff;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: .84rem;
}

.console-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 3.8rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  padding: 0 1.25rem;
  box-shadow: 0 6px 18px rgba(26, 40, 60, .04);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  color: var(--text);
  text-decoration: none;
}

.brand strong {
  color: var(--blue);
  font-size: 1.12rem;
}

.brand span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 720;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  min-width: 0;
}

.top-nav span {
  border-radius: 6px;
  color: var(--muted);
  padding: .48rem .78rem;
  font-size: .88rem;
  font-weight: 760;
}

.top-nav span.is-active {
  background: var(--blue-soft);
  color: var(--blue);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.console-main {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 1rem .75rem;
}

.sidebar strong {
  display: block;
  color: var(--soft);
  padding: .45rem .65rem .75rem;
  font-size: .76rem;
}

.sidebar button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: .7rem .75rem;
  font-size: .88rem;
  font-weight: 760;
  text-align: left;
}

.sidebar button em {
  color: var(--soft);
  font-size: .72rem;
  font-style: normal;
}

.sidebar button.is-active {
  background: var(--blue-soft);
  color: var(--blue);
}

.sidebar button.is-active em {
  color: var(--blue);
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 1rem;
  padding: 1.1rem;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.page-head p {
  margin-top: .35rem;
  font-size: .9rem;
}

.page-domain {
  display: grid;
  justify-items: end;
  gap: .18rem;
}

.page-domain span,
.summary-grid span,
.table-head span,
.link-meta span,
.link-card__main small {
  color: var(--soft);
  font-size: .75rem;
  font-weight: 720;
}

.page-domain strong {
  color: var(--blue);
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}

.summary-grid article,
.management-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.summary-grid article {
  display: grid;
  gap: .18rem;
  min-width: 0;
  padding: .9rem 1rem;
}

.summary-grid strong {
  min-width: 0;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.management-panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: .95rem 1rem;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.panel-head p {
  margin-top: .22rem;
  font-size: .84rem;
}

.table-head,
.link-card {
  display: grid;
  grid-template-columns: minmax(12rem, .9fr) minmax(22rem, 1.55fr) minmax(8rem, .65fr) minmax(9rem, .7fr);
  gap: .85rem;
  align-items: start;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(9rem, .75fr) minmax(8rem, .65fr) minmax(14rem, 1fr) auto;
  align-items: end;
  gap: .65rem;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  padding: .85rem 1rem;
}

.filter-search {
  min-width: 0;
}

.new-link-panel {
  display: grid;
  gap: .75rem;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
  padding: .95rem 1rem;
}

.new-link-grid {
  display: grid;
  grid-template-columns: minmax(8rem, .65fr) minmax(12rem, 1fr) minmax(10rem, .8fr);
  gap: .65rem;
}

.new-link-grid.is-wide {
  grid-template-columns: minmax(0, 1fr) minmax(12rem, .75fr);
}

.new-link-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}

.table-head {
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  padding: .72rem 1rem;
}

.link-list {
  display: grid;
}

.link-card {
  border-bottom: 1px solid var(--line);
  padding: .95rem 1rem;
}

.link-card.is-archived {
  background: #fbfbfc;
}

.link-card:last-child {
  border-bottom: 0;
}

.row-cell {
  min-width: 0;
}

.link-card__main {
  display: grid;
  gap: .3rem;
}

.link-card__main a {
  min-width: 0;
  color: var(--blue);
  overflow-wrap: anywhere;
  text-decoration: none;
  font-size: .88rem;
  font-weight: 760;
}

.link-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem;
}

.link-title strong {
  font-size: .98rem;
}

.link-title em {
  border-radius: 999px;
  background: rgba(183, 110, 0, .1);
  color: var(--amber);
  padding: .14rem .45rem;
  font-size: .68rem;
  font-style: normal;
  font-weight: 820;
}

.link-title em.is-active {
  background: rgba(24, 160, 88, .11);
  color: var(--green);
}

.link-title em.is-expired {
  background: rgba(217, 45, 32, .11);
  color: var(--red);
}

.link-title em.is-archived,
.link-title em.category-badge {
  background: rgba(109, 119, 136, .12);
  color: var(--muted);
}

.link-title em.category-badge {
  background: var(--blue-soft);
  color: var(--blue);
}

.field-stack {
  display: grid;
  gap: .55rem;
}

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .45rem;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-btn {
  min-height: 2.15rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(22, 119, 255, .28);
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: .42rem .78rem;
  font-size: .82rem;
  font-weight: 740;
  cursor: pointer;
}

.taobao-tools {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) auto auto;
  align-items: center;
  gap: .55rem;
  border: 1px solid rgba(22, 119, 255, .13);
  border-radius: 8px;
  background: rgba(22, 119, 255, .045);
  padding: .55rem .65rem;
}

.check-line {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--text);
  font-size: .86rem;
  font-weight: 760;
}

.check-line input {
  width: 1rem;
  height: 1rem;
  padding: 0;
  accent-color: var(--blue);
}

.rotation-field {
  width: auto;
  display: grid;
  grid-template-columns: auto 4.5rem auto;
  align-items: center;
  gap: .35rem;
  white-space: nowrap;
}

.rotation-field span,
.rotation-field em,
.taobao-tools small {
  color: var(--muted);
  font-size: .78rem;
  font-style: normal;
  font-weight: 680;
}

.rotation-field input {
  min-height: 2rem;
  padding: .38rem .5rem;
}

.field-line {
  display: grid;
  grid-template-columns: minmax(8rem, .8fr) minmax(12rem, 1fr);
  gap: .55rem;
}

.link-meta {
  display: grid;
  gap: .35rem;
}

.link-actions {
  display: grid;
  gap: .45rem;
  justify-items: stretch;
}

.empty-state {
  display: grid;
  gap: .25rem;
  padding: 2rem 1rem;
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: .95rem;
}

.empty-state span {
  color: var(--muted);
  font-size: .84rem;
}

.switch {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  margin-top: .25rem;
}

.switch input {
  width: 1rem;
  height: 1rem;
  padding: 0;
  accent-color: var(--blue);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 20;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(31, 38, 51, .94);
  color: #fff;
  padding: .65rem 1rem;
  font-size: .86rem;
  font-weight: 760;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .18);
}

@media (max-width: 1080px) {
  .console-main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .table-head {
    display: none;
  }

  .link-card {
    grid-template-columns: 1fr;
  }

  .link-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .filter-bar,
  .new-link-grid,
  .new-link-grid.is-wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .site-header {
    height: auto;
    grid-template-columns: 1fr;
    gap: .65rem;
    padding: .85rem;
  }

  .top-nav {
    overflow-x: auto;
  }

  .workspace {
    padding: .7rem;
  }

  .page-head {
    display: grid;
  }

  .page-domain {
    justify-items: start;
  }

  .panel-head,
  .panel-actions,
  .new-link-actions {
    display: grid;
    justify-items: stretch;
  }

  .summary-grid,
  .field-line,
  .taobao-tools {
    grid-template-columns: 1fr;
  }

  .rotation-field {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .upload-row {
    grid-template-columns: 1fr;
  }

  .link-actions button,
  .link-actions a,
  .upload-btn {
    width: 100%;
  }
}
