:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #152235;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #166534;
  --brand-hover: #14532d;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(22, 101, 52, 0.09), transparent 28rem),
    var(--bg);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 64px; }

.auth-card {
  width: min(430px, 100%);
  margin: 10vh auto 0;
  padding: 38px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 26px;
  border-radius: 14px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.03em; }
h2 { margin-bottom: 0; font-size: 23px; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: 0.12em; }

label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12); }
.auth-card input { margin-bottom: 14px; }

.primary, .secondary, .ghost {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  font-weight: 750;
  transition: 0.15s ease;
}
.primary { color: white; background: var(--brand); border: 1px solid var(--brand); }
.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.secondary { color: var(--text); background: white; border: 1px solid #cbd5e1; }
.secondary:hover, .ghost:hover { border-color: #94a3b8; background: #f8fafc; }
.ghost { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.full { width: 100%; }
.compact { min-height: 36px; padding: 0 12px; font-size: 13px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.panel { margin-bottom: 24px; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.create-grid { display: grid; grid-template-columns: minmax(300px, 2fr) minmax(200px, 1fr) auto; gap: 14px; align-items: end; }
.create-button { height: 46px; }

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  padding: 17px 18px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  background: #f0fdf4;
}
.result-label { display: block; margin-bottom: 5px; color: var(--brand); font-size: 12px; font-weight: 800; }
.result-card a { color: #14532d; overflow-wrap: anywhere; font-weight: 700; }

.history-heading { margin-bottom: 18px; }
.count-pill { display: inline-block; margin-left: 5px; padding: 2px 8px; color: var(--brand); background: #dcfce7; border-radius: 999px; font-size: 13px; vertical-align: middle; }
.export-wrap { position: relative; }
.export-menu {
  position: absolute;
  z-index: 10;
  right: 0;
  top: calc(100% + 8px);
  width: 190px;
  padding: 6px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.16);
}
.export-menu button { width: 100%; padding: 10px; text-align: left; color: var(--text); background: transparent; border: 0; border-radius: 7px; }
.export-menu button:hover { background: var(--surface-soft); }

.table-wrap { min-height: 220px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 1100px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #475569; background: var(--surface-soft); font-size: 12px; letter-spacing: 0.02em; white-space: nowrap; }
td { max-width: 320px; font-size: 13px; }
td a { color: #166534; overflow-wrap: anywhere; }
.cell-text { display: block; max-height: 4.8em; overflow: hidden; overflow-wrap: anywhere; line-height: 1.6; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.empty-state, .loading-state { padding: 72px 20px; text-align: center; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 18px; }
.pagination p { margin: 0; }

.message { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.error { color: var(--danger); background: #fef3f2; border: 1px solid #fecdca; }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 12px 16px; color: white; background: #0f172a; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; }

[hidden] { display: none !important; }

@media (max-width: 900px) {
  .create-grid { grid-template-columns: 1fr; }
  .create-button { width: 100%; }
}

@media (max-width: 600px) {
  .shell { width: min(100% - 24px, 1440px); padding-top: 20px; }
  .panel, .auth-card { padding: 20px; border-radius: 15px; }
  .topbar { align-items: flex-start; }
  .history-heading, .result-card { align-items: stretch; flex-direction: column; }
  .export-wrap, #export-toggle { width: 100%; }
  .export-menu { left: 0; right: auto; width: 100%; }
}

