:root {
  --bg: #f7efe4;
  --bg-accent: #f0dcc5;
  --panel: rgba(255, 250, 244, 0.88);
  --panel-strong: #fff9f1;
  --text: #2d241d;
  --muted: #736458;
  --line: rgba(79, 57, 41, 0.14);
  --primary: #21493d;
  --warning: #cf3f32;
  --warning-soft: rgba(207, 63, 50, 0.12);
  --expired: #8f2018;
  --shadow: 0 22px 60px rgba(61, 37, 20, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 28%),
    linear-gradient(135deg, var(--bg) 0%, #f4e4d3 48%, var(--bg-accent) 100%);
}

body.modal-open {
  overflow: hidden;
}

body.login-page {
  display: grid;
  place-items: center;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.topbar,
.panel {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 24px;
}

.topbar-copy {
  min-width: 0;
}

.topbar-side {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-user {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  color: var(--primary);
  font-size: 0.9rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1.08;
  margin-bottom: 8px;
}

.hero-copy {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.96rem;
}

.sync-status {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}

.sync-status[data-state="pending"] {
  color: #9a6a24;
}

.sync-status[data-state="success"] {
  color: var(--primary);
}

.sync-status[data-state="error"] {
  color: var(--warning);
}

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

.stat-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.stat-card span {
  display: block;
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.5rem;
}

.stat-card.warning {
  background: linear-gradient(135deg, rgba(255, 237, 232, 0.96), rgba(255, 245, 236, 0.96));
}

.stat-card.danger {
  background: linear-gradient(135deg, rgba(255, 226, 221, 0.96), rgba(255, 240, 235, 0.96));
}

.content-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
}

.panel {
  padding: 24px;
}

.form-panel,
.list-panel {
  font-size: 0.94rem;
}

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

.section-heading h2 {
  font-size: 1.05rem;
}

.section-heading p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.92rem;
}

.server-form {
  display: grid;
  gap: 16px;
}

.server-form label {
  display: grid;
  gap: 8px;
}

.server-form span {
  font-weight: 700;
  font-size: 0.92rem;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(33, 73, 61, 0.44);
  background: #fffdf8;
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
  min-height: 112px;
}

.primary-button,
.ghost-button,
.row-button {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.92rem;
  transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.primary-button:hover,
.ghost-button:hover,
.row-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled,
.row-button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary) 0%, #346452 100%);
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: var(--primary);
  border: 1px solid rgba(33, 73, 61, 0.18);
}

.table-wrap {
  overflow-x: auto;
}

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

.col-url {
  width: 26%;
}

.col-note {
  width: 30%;
}

.col-expiry {
  width: 14%;
}

.col-countdown {
  width: 14%;
}

.col-actions {
  width: 16%;
}

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

th {
  text-align: left;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.48);
}

.url-link {
  display: block;
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.url-link:hover {
  text-decoration: underline;
}

.note-cell {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.expiry-cell,
.countdown-cell,
.actions-cell {
  font-size: 0.92rem;
}

.countdown-pill {
  display: inline-flex;
  align-items: center;
  min-width: 92px;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(33, 73, 61, 0.09);
  color: var(--primary);
}

tr.expiring-soon {
  background: var(--warning-soft);
}

tr.expiring-soon .countdown-pill,
tr.expiring-soon .expiry-cell {
  color: var(--warning);
}

tr.expiring-soon .countdown-pill {
  background: rgba(207, 63, 50, 0.14);
}

tr.expired {
  background: rgba(143, 32, 24, 0.1);
}

tr.expired .countdown-pill,
tr.expired .expiry-cell {
  color: var(--expired);
}

tr.expired .countdown-pill {
  background: rgba(143, 32, 24, 0.16);
}

.actions-cell {
  white-space: nowrap;
}

.row-button {
  padding: 7px 11px;
  font-size: 0.88rem;
}

.edit-button {
  background: rgba(33, 73, 61, 0.12);
  color: var(--primary);
  margin-right: 8px;
}

.delete-button {
  background: rgba(143, 32, 24, 0.1);
  color: var(--expired);
}

.empty-state {
  display: none;
  padding: 48px 20px;
  border: 1px dashed rgba(79, 57, 41, 0.18);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.38);
  text-align: center;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-state.show {
  display: block;
}

.login-shell {
  width: min(100%, 480px);
  padding: 24px;
}

.login-card {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card h1 {
  margin-bottom: 10px;
}

.login-form {
  margin-top: 20px;
}

.login-status,
.setup-hint {
  font-size: 0.9rem;
  line-height: 1.55;
}

.login-status {
  color: var(--muted);
}

.login-status[data-state="pending"] {
  color: #9a6a24;
}

.login-status[data-state="error"] {
  color: var(--warning);
}

.setup-hint {
  color: var(--muted);
}

.setup-hint code {
  font-family: ui-monospace, "SFMono-Regular", monospace;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 36, 29, 0.28);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  width: min(100%, 440px);
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-heading {
  margin-bottom: 16px;
}

.compact-form {
  gap: 14px;
}

.password-status {
  font-size: 0.9rem;
  color: var(--muted);
}

.password-status[data-state="pending"] {
  color: #9a6a24;
}

.password-status[data-state="success"] {
  color: var(--primary);
}

.password-status[data-state="error"] {
  color: var(--warning);
}

@media (max-width: 960px) {
  .topbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-side {
    width: 100%;
    justify-items: stretch;
  }

  .auth-bar {
    justify-content: space-between;
    width: 100%;
  }

  .topbar-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 100%);
    padding-top: 20px;
  }

  .topbar,
  .panel {
    padding: 20px;
  }

  .topbar-stats {
    grid-template-columns: 1fr;
  }

  .auth-bar {
    flex-wrap: wrap;
  }

  table,
  colgroup,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.72);
  }

  td {
    border-bottom: 1px solid rgba(79, 57, 41, 0.08);
    padding: 14px;
  }

  td:last-child {
    border-bottom: none;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
  }
}
