:root {
    color-scheme: light;
    --surface: #fff;
    --background: #f6f7fb;
    --ink: #131a30;
    --muted: #515c70;
    --border: #dce1eb;
    --accent: #4339b6;
    --accent-dark: #332993;
    --accent-light: #eeedff;
    --radius: 12px;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.5; }
button, input { font: inherit; }
a { color: var(--accent); }
h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.12; letter-spacing: -.04em; }
h2 { font-size: 1.125rem; letter-spacing: -.015em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.sign-in { display: grid; place-items: center; padding: 1.25rem; }
.login-card {
    width: min(100%, 27rem);
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 14px 38px #1620410a;
}
.login-card h1 { font-size: 1.6rem; margin: 1.75rem 0 1.25rem; }
.login-card .primary { width: 100%; margin-top: 1.25rem; }
.login-card > p { color: var(--muted); }
.setup-card { width: min(100%, 33rem); }
.setup-card > .field-error { margin-bottom: 1rem; color: #9b1734; }
.setup-card > p + label { margin-top: 1rem; }
.setup-fields { display: grid; gap: .85rem; }
.setup-options { margin-top: 1rem; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: 8px; }
.setup-options > summary { color: var(--accent-dark); font-size: .875rem; font-weight: 650; cursor: pointer; }
.setup-address { display: grid; grid-template-columns: minmax(0, 1fr) 7rem; gap: .75rem; margin-block: .85rem; }
.setup-secret { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.setup-secret input { flex: 1 1 15rem; min-width: 0; font-family: ui-monospace, monospace; }

.dashboard { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); }
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2.1rem;
    min-height: 100vh;
    padding: 1.75rem 1.2rem;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font-size: 1.25rem; font-weight: 750; letter-spacing: -.04em; text-decoration: none; }
.sidebar .brand { align-self: flex-start; margin-left: .35rem; }
.brand-mark {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: end;
    justify-content: center;
    gap: 3px;
    padding-bottom: 10px;
    background: var(--accent);
    border-radius: 10px;
}
.brand-mark i { width: 4px; height: 7px; background: #c0bcff; border-radius: 1px; }
.brand-mark i:nth-child(2) { height: 12px; background: #dfdcff; }
.brand-mark i:nth-child(3) { height: 17px; background: #fff; }
.nav-item {
    display: block;
    padding: .65rem .85rem;
    border-radius: 8px;
    background: var(--accent-light);
    color: var(--accent-dark);
    font-size: .9375rem;
    font-weight: 650;
    text-decoration: none;
}
.logout { margin-top: auto; }
.logout button { color: var(--muted); }
.workspace { padding: 3rem clamp(1.25rem, 4.5vw, 4.5rem); }
.content { max-width: 76rem; margin-inline: auto; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.65rem; }

.button {
    display: inline-flex;
    min-height: 2.5rem;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .48rem .85rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 650;
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.primary span { font-size: 1.125rem; line-height: 1; }
.secondary { color: var(--ink); background: var(--surface); border-color: var(--border); }
.secondary:hover { background: var(--background); }
.quiet { color: var(--accent); background: transparent; }
.quiet:hover { background: var(--accent-light); }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric, .panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.metric { min-height: 8.5rem; padding: 1rem 1.2rem; }
.emphasis { border-color: #dad6ff; background: var(--accent-light); }
.metric dt { color: var(--muted); font-size: .875rem; font-weight: 650; }
.emphasis dt { color: var(--accent-dark); }
.metric dd { margin-top: .35rem; font-size: clamp(1.65rem, 3vw, 2.5rem); font-weight: 720; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.04em; overflow-wrap: anywhere; }
.metric-note { display: block; margin-top: .45rem; color: var(--muted); font-size: .8125rem; font-weight: 500; line-height: 1.5; letter-spacing: 0; }

.notice { margin-bottom: 1rem; padding: .65rem .9rem; border: 1px solid #dad6ff; border-radius: 8px; color: var(--accent-dark); background: var(--accent-light); font-size: .9375rem; }
.editor { margin-bottom: 1rem; padding: 1.15rem 1.25rem; }
.form-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1rem; margin-top: .9rem; }
label { display: block; margin-bottom: .4rem; font-size: .875rem; font-weight: 650; }
input:not([type="hidden"]) { width: 100%; min-height: 2.75rem; padding: .5rem .65rem; border: 1px solid #aeb8cb; border-radius: 7px; color: var(--ink); background: var(--surface); }
input::placeholder { color: var(--muted); }
input[aria-invalid="true"] { border-color: #ad2540; }
.field-error { margin-top: .4rem; color: #9b1734; font-size: .875rem; }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; }

.panel-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1rem; padding: 1.15rem 1.25rem; }
.panel-header p { color: var(--muted); font-size: .875rem; }
.empty { display: grid; min-height: 12rem; place-content: center; gap: .3rem; padding: 1.25rem; text-align: center; border-top: 1px solid var(--border); }
.empty p + p { color: var(--muted); font-size: .875rem; }
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; min-width: 42rem; border-collapse: collapse; table-layout: fixed; }
thead { color: var(--muted); background: #f8f9fd; }
thead th { font-size: .875rem; font-weight: 650; }
thead th:first-child { width: 27%; }
thead th:nth-child(3), thead th:nth-child(4) { width: 5.5rem; }
thead th:last-child { width: 10.5rem; }
th, td { padding: .8rem 1rem; border-top: 1px solid var(--border); text-align: left; }
th:first-child, td:first-child { padding-left: 1.25rem; }
tbody th { font-weight: 650; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.campaign-name { display: block; overflow-wrap: anywhere; }
.tracking-link, .destination { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 500; }
.tracking-link { margin-top: .2rem; font-size: .8125rem; }
.destination { color: var(--muted); }
.row-actions { display: flex; gap: .2rem; }
.row-actions .button { min-height: 2.25rem; padding-inline: .55rem; }
.mobile-label { display: none; }

.visually-hidden, .clipboard-fallback { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.clipboard-fallback { position: fixed; top: 0; left: 0; }

@media (max-width: 62rem) {
    .dashboard { display: block; }
    .sidebar { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .65rem 1.1rem; padding: .85rem 1.25rem; border-right: 0; border-bottom: 1px solid var(--border); }
    .sidebar .brand { margin-left: 0; }
    .logout { margin: 0 0 0 auto; }
    .workspace { padding-top: 1.75rem; }
}

@media (max-width: 48rem) {
    table, tbody { display: block; min-width: 0; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, minmax(2.75rem, .32fr)); gap: .65rem; padding: .8rem .9rem; border-top: 1px solid var(--border); }
    tbody th:first-child, tbody td { min-width: 0; padding: 0; border: 0; }
    tbody td:nth-child(2) { grid-area: 2 / 1 / auto / -1; }
    tbody td:nth-child(3) { grid-area: 1 / 2; }
    tbody td:nth-child(4) { grid-area: 1 / 3; }
    tbody td:last-child { grid-column: 1 / -1; }
    .mobile-label { display: block; color: var(--muted); font-size: .875rem; }
}

@media (max-width: 35rem) {
    .sidebar nav { display: none; }
    .metrics { gap: .4rem; }
    .metric { min-height: 7rem; padding: .65rem .5rem; }
    .metric-note { font-size: .75rem; }
    .form-fields { grid-template-columns: minmax(0, 1fr); }
    .panel-header, .editor { padding-inline: .9rem; }
}
