/* ==========================================================================
   分发中台 · Distribution Console
   Ops-console theme: deep-ink sidebar + light content + green accent.
   Self-contained: no external fonts/icons/CDNs.
   ========================================================================== */

:root {
    --ink: #14161b;
    --ink-2: #1c1f26;
    --ink-border: #2a2e37;
    --sidebar-text: #c7ccd4;
    --sidebar-text-dim: #838a97;
    --sidebar-text-active: #ffffff;

    --bg: #f6f7f9;
    --surface: #ffffff;
    --border: #e6e8ec;

    --text: #1a1d23;
    --muted: #6b7280;

    --accent: #18904f;
    --accent-ink: #ffffff;
    --accent-hover: #147a41;

    --ok: #2f9e6b;
    --ok-bg: #e7f5ee;
    --danger: #d94b3f;
    --danger-bg: #fbeae8;
    --warn: #d99a2b;
    --warn-bg: #fbf1de;
    --unknown: #9aa1ab;
    --unknown-bg: #eef0f2;

    --radius: 10px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(20, 22, 27, 0.05), 0 1px 1px rgba(20, 22, 27, 0.03);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

    --sidebar-width: 240px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    line-height: 1.55;
    color: var(--text);
    background-color: var(--bg);
}

a {
    color: inherit;
}

/* ==========================================================================
   Shell layout: fixed sidebar + main column
   ========================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--ink);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.main-col {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.35rem 1.25rem 1.1rem;
    text-decoration: none;
    color: var(--sidebar-text-active);
    border-bottom: 1px solid var(--ink-border);
    margin-bottom: 0.5rem;
}

.brand-mark {
    color: var(--accent);
    flex-shrink: 0;
}

.brand-text {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.98rem;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

/* Nav */
.side-nav {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
    padding: 0.5rem 0.75rem 1.5rem;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text-dim);
    padding: 0.35rem 0.6rem 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.6rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 0.88rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-icon {
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-link:hover {
    background-color: var(--ink-2);
    color: var(--sidebar-text-active);
}

.nav-link.active {
    background-color: var(--ink-2);
    color: var(--sidebar-text-active);
    border-left-color: var(--accent);
    font-weight: 600;
}

.nav-link.active .nav-icon {
    color: var(--accent);
    opacity: 1;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.95rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.language-switch {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.language-switch a {
    text-decoration: none;
    color: var(--muted);
    padding: 0.2rem 0.35rem;
    border-radius: 5px;
    font-weight: 500;
}

.language-switch a:hover {
    color: var(--text);
}

.language-switch a.lang-active {
    color: var(--text);
    font-weight: 700;
}

.lang-sep {
    color: var(--border);
}

/* Content */
.content {
    flex: 1 1 auto;
    padding: 2rem 2rem 1rem;
}

.content-inner {
    max-width: 1100px;
    margin: 0 auto;
    animation: fade-in 0.25s ease both;
}

/* Opacity-only fade: intentionally no transform. A transform (even the
   identity translateY(0) left by animation-fill-mode: both) would make
   .content-inner the containing block for position:fixed descendants,
   trapping the modal overlay inside the content area instead of the
   viewport (clipping its header, not dimming the sidebar). */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

section {
    margin-bottom: 2rem;
}

h2 {
    margin-bottom: 1rem;
    color: var(--text);
    font-size: 1.3rem;
}

h3 {
    margin-bottom: 0.8rem;
    color: var(--text);
    font-size: 1.05rem;
}

/* ==========================================================================
   Hero (home)
   ========================================================================== */

.hero {
    text-align: center;
    padding: 1.5rem 0 2rem;
    animation: fade-in 0.3s ease both;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 0.6rem;
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

.hero p {
    font-size: 1.05rem;
    color: var(--muted);
    max-width: 600px;
    margin: 0 auto;
}

/* ==========================================================================
   Cards: every "panel-like" container across the pages shares this look
   ========================================================================== */

.url-form,
.domain-form,
.url-list,
.result-card,
.error-container {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 1.5rem 1.6rem;
    animation: fade-in 0.3s ease both;
}

.url-form {
    max-width: 800px;
    margin: 0 auto;
}

.result-card {
    max-width: 800px;
    margin: 0 auto 2rem;
}

.domain-form {
    margin-bottom: 2rem;
}

.domain-form h3 {
    margin-bottom: 1.1rem;
}

/* Delete action tucked right under a repeated landing-template card (separate
   <form> since a <form> cannot nest inside another <form>). */
.lt-delete-form {
    margin: -1.3rem 0 2rem;
}

/* Stagger content sections slightly for a subtle, non-flashy entrance */
section:nth-of-type(2) { animation-delay: 0.03s; }
section:nth-of-type(3) { animation-delay: 0.06s; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-group {
    margin-bottom: 1.35rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Grid layout for multi-field admin forms: replaces long single-column stacks */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.1rem;
    margin-bottom: 1.1rem;
    align-items: start;
}

.form-grid .form-group {
    margin-bottom: 0;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.option-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.option-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0;
    font-weight: 400;
    font-size: 0.9rem;
    color: var(--text);
}

/* Row of checkboxes, e.g. use_ssl / enabled / in_sync_set / is_default */
.check-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.9rem 1.4rem;
    margin-bottom: 1.1rem;
    font-size: 0.88rem;
}

.check-row label,
.up-backend-choice {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 400;
    font-size: 0.88rem;
    color: var(--text);
    margin-bottom: 0;
}

.up-backend-choice {
    display: flex;
    padding: 0.15rem 0;
}

.hidden {
    display: none;
}

/* "+ Add new ..." toggle button that reveals a create-form below it */
.add-toggle-btn {
    margin-bottom: 1.5rem;
}

input[type="url"],
input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: var(--font-sans);
    background-color: var(--surface);
    color: var(--text);
    height: 38px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    height: auto;
    min-height: 160px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: var(--accent);
}

input[type="url"]:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(24, 144, 79, 0.22);
}

/* Technical values (URLs, codes, hashes, endpoints, keys) read in mono */
input[type="url"],
input[readonly],
.mono,
code {
    font-family: var(--font-mono);
    font-size: 0.86rem;
}

/* Row that keeps two selects (e.g. Role + Landing template) from being
   squeezed down to nothing by a flex parent. */
.select-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.select-row select {
    flex: 1 1 130px;
    min-width: 130px;
    width: auto;
}

/* Read-only fields should look inert, not editable */
input[readonly] {
    background-color: var(--bg);
    color: var(--muted);
    cursor: not-allowed;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background-color: var(--accent);
    color: var(--accent-ink);
    padding: 0 1.2rem;
    height: 38px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 3px 10px rgba(24, 144, 79, 0.3);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-secondary {
    background-color: var(--ink);
    color: #fff;
}

.btn-secondary:hover {
    background-color: var(--ink-2);
    box-shadow: 0 3px 10px rgba(20, 22, 27, 0.25);
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background-color: #c23f34;
    box-shadow: 0 3px 10px rgba(217, 75, 63, 0.3);
}

/* Neutral outline button for secondary actions */
.btn-outline {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: none;
}

.btn-outline:hover {
    background-color: var(--bg);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: none;
    transform: translateY(-1px);
}

.btn-ghost {
    background-color: transparent;
    color: var(--muted);
    border: 1px solid transparent;
    box-shadow: none;
}

.btn-ghost:hover {
    background-color: var(--bg);
    color: var(--text);
    box-shadow: none;
    transform: none;
}

.btn-small {
    height: 32px;
    padding: 0 0.85rem;
    font-size: 0.82rem;
    border-radius: 7px;
}

/* Drag-and-drop file upload zone (publish page) */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 110px;
    padding: 1.1rem 1rem;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.dropzone:hover {
    border-color: var(--accent);
    color: var(--text);
}

.dropzone.dragover {
    border-color: var(--accent);
    background-color: var(--bg);
    color: var(--accent);
}

.dropzone.has-file {
    border-style: solid;
    border-color: var(--accent);
    color: var(--text);
}

.dropzone .dropzone-icon {
    color: var(--accent);
}

.dropzone .dropzone-text {
    font-size: 0.88rem;
    word-break: break-all;
}

/* Native file input covers the zone so a click anywhere opens the picker,
   but stays invisible — the styled label content shows through. */
.dropzone .dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Domain page: add-button row + inline help affordance */
.page-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.help-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.7rem;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.help-chip:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.help-chip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

/* Modal (self-contained, used by the domains help guide) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 22, 27, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
}

/* Higher specificity than the bare .modal-overlay so the shared .hidden
   toggle actually hides the overlay (a single-class .hidden would otherwise
   lose to .modal-overlay's display:flex). */
.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 640px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

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

.modal-head h3 {
    margin: 0;
    font-size: 1.05rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-body p {
    margin: 0 0 0.85rem;
    line-height: 1.6;
}

.modal-foot {
    padding: 0.9rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.help-list {
    margin: 0 0 0.85rem;
    padding-left: 1.2rem;
}

.help-list li {
    margin-bottom: 0.5rem;
    line-height: 1.55;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Compact inline redirect editor in the domains table */
.redirect-form {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}

.redirect-form input[type="url"] {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    height: 34px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.redirect-none {
    color: var(--muted);
}

/* Stack the two domain edit-row forms (redirect / role+landing) with breathing
   room between them instead of the flex forms butting up against each other */
.edit-row .redirect-form + .redirect-form {
    margin-top: 0.75rem;
}

/* Compact inline editor row in download-sources / storage-backends tables */
.ds-row-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem 0.7rem;
    align-items: center;
    margin: 0 0 0.6rem;
}

.ds-row-form input[type="url"],
.ds-row-form input[type="text"],
.ds-row-form input[type="number"],
.ds-row-form input[type="password"],
.ds-row-form select {
    width: 100%;
    height: 34px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.ds-row-form .check-row,
.ds-row-form label {
    margin-bottom: 0;
}

.ds-row-form > .btn {
    justify-self: start;
}

.ds-actions-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background-color: #e3f5ec;
    color: #16794a;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background-color: currentColor;
    flex-shrink: 0;
}

.badge-ok {
    background-color: var(--ok-bg);
    color: var(--ok);
}

/* Inline notice banner (e.g. settings "saved") */
.alert {
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-ok {
    background-color: var(--ok-bg);
    color: var(--ok);
}

.alert-error {
    background-color: var(--danger-bg);
    color: var(--danger);
}

/* Login page (standalone, no sidebar) */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.05rem;
}

.login-title {
    margin: 0.25rem 0 0.5rem;
    font-size: 1.15rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.login-field input {
    width: 100%;
}

.login-submit {
    width: 100%;
    margin-top: 0.35rem;
}

.login-lang {
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
}

.login-lang a {
    color: var(--muted);
    text-decoration: none;
}

.login-lang a:hover {
    color: var(--accent);
}

/* Topbar user + logout */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.badge-down {
    background-color: var(--danger-bg);
    color: var(--danger);
}

.badge-unknown {
    background-color: var(--unknown-bg);
    color: var(--unknown);
}

.badge-muted {
    background-color: var(--unknown-bg);
    color: var(--muted);
}

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

/* Simple key: value list (publish run detail) */
.kv-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    font-size: 0.9rem;
}

.kv-list li {
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--border);
    word-break: break-all;
}

.kv-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.muted, p.muted {
    font-size: 0.88rem;
}

/* ==========================================================================
   Features (home page)
   ========================================================================== */

.features {
    padding: 1.5rem 0;
}

.features h3 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.25rem;
}

.feature {
    background-color: var(--surface);
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    text-align: center;
}

.feature h4 {
    color: var(--text);
    margin-bottom: 0.6rem;
    font-size: 0.98rem;
}

.feature p {
    color: var(--muted);
    font-size: 0.88rem;
}

/* ==========================================================================
   Result page
   ========================================================================== */

.result {
    text-align: center;
}

.result h2 {
    margin-bottom: 1.5rem;
}

.result-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.result-item h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.6rem;
}

.result-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.short-url-container {
    display: flex;
    margin-top: 0.5rem;
    gap: 0.5rem;
}

.short-url-container input {
    flex: 1;
    font-weight: 600;
}

.copy-btn {
    min-width: 84px;
}

.long-url {
    word-break: break-all;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.qr-code {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-code img {
    width: 180px;
    height: 180px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    background: #fff;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: 2.5rem 0;
}

.empty-state p {
    margin-bottom: 1.25rem;
    color: var(--muted);
}

.url-table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.url-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.url-table th,
.url-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.url-table tbody tr:last-child td {
    border-bottom: none;
}

.url-table tbody tr:hover td {
    background-color: var(--bg);
}

.url-table th {
    background-color: var(--bg);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    white-space: nowrap;
}

.url-table td.long-url {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Fixed column-width modifier for download-sources / storage-backends:
   pins every column to a set share of the table so it never grows wider
   than the content area, truncates any long cell text to a single
   ellipsized line (title attribute carries the full value as a tooltip),
   and keeps the actions column a guaranteed width so its buttons are
   never clipped or pushed into a horizontal scrollbar. The collapsed
   inline edit row (colspan, its own .form-grid layout) is excluded so its
   multi-line form fields are unaffected. */
.url-table-fixed {
    table-layout: fixed;
}

.url-table-fixed tbody tr:not(.edit-row) td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.url-table-fixed tbody tr:not(.edit-row) td.actions {
    overflow: visible;
    text-overflow: clip;
}

/* Header cells must truncate too — with fixed column widths a long header
   label (e.g. "SECRET KEY", "IN SYNC (FAN-OUT) SET") would otherwise
   overflow its <th> box and visually overlap the next header. */
.url-table-fixed th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.url-table td a:not(.btn) {
    color: var(--text);
    font-weight: 600;
}

.url-table td a[target="_blank"]:not(.btn) {
    color: var(--accent-hover);
}

.url-table td.actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
    white-space: nowrap;
    gap: 0.5rem;
}

/* ==========================================================================
   Stats
   ========================================================================== */

.stats-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.tab-btn {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    height: 36px;
    padding: 0 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--font-sans);
}

.tab-btn.active,
.tab-btn:hover {
    background-color: var(--ink);
    color: #fff;
    border-color: var(--ink);
}

/* Download stats (cumulative) */
.dl-stats {
    margin-bottom: 2rem;
}

.dl-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dl-card {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 1.1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.dl-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}

.dl-card-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    font-family: var(--font-mono);
    letter-spacing: -0.01em;
}

.dl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    align-items: start;
}

.dl-stats h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.6rem;
}

@media (max-width: 720px) {
    .dl-grid {
        grid-template-columns: 1fr;
    }
}

/* Separates the cumulative download block from the per-day redirect block. */
.stats-subhead {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Right-align numeric columns in the download stat tables so figures line up
   on their ones digit. The download tables carry .dl-num on numeric th/td. */
.url-table th.dl-num,
.url-table td.dl-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.worldmap {
    position: relative;
    width: 100%;
    aspect-ratio: 1280 / 644;
    background: url('/static/world.jpg') center / 100% 100% no-repeat;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.geo-dot {
    position: absolute;
    display: block;
    background-color: rgba(24, 144, 79, 0.75);
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 999px;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(24, 144, 79, 0.55);
}

.geo-dot.sm {
    width: 10px;
    height: 10px;
}

.geo-dot.md {
    width: 16px;
    height: 16px;
}

.geo-dot.lg {
    width: 24px;
    height: 24px;
}

/* ==========================================================================
   Error page
   ========================================================================== */

.error {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40vh;
}

.error-container {
    text-align: center;
    max-width: 480px;
}

.error-container h2 {
    color: var(--danger);
    margin-bottom: 1rem;
}

.error-container p {
    margin-bottom: 1.5rem;
    color: var(--muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
    padding: 1.25rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
}

.app-footer p {
    color: var(--muted);
    font-size: 0.82rem;
}

/* ==========================================================================
   Responsive: collapse sidebar to a top bar under 900px
   ========================================================================== */

@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow-y: visible;
    }

    .main-col {
        margin-left: 0;
    }

    .brand {
        padding: 1rem 1.25rem;
        margin-bottom: 0;
        border-bottom: none;
    }

    .side-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0 0.25rem;
        padding: 0.25rem 0.75rem 0.9rem;
        border-top: 1px solid var(--ink-border);
    }

    .nav-group {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.15rem;
    }

    .nav-group-title {
        display: none;
    }

    .nav-link {
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 6px;
        padding: 0.45rem 0.55rem;
    }

    .nav-link.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }

    .topbar {
        padding: 0.85rem 1.25rem;
    }

    .content {
        padding: 1.25rem 1.25rem 0.5rem;
    }

    .app-footer {
        padding: 1rem 1.25rem;
    }

    .feature-grid {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .short-url-container {
        flex-direction: column;
    }

    .copy-btn {
        width: 100%;
    }
}

/* ==========================================================================
   Landing templates: list (cards) + block editor
   ========================================================================== */

.section-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.template-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.template-card-head h3 {
    font-size: 1.02rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.template-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.template-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

/* Block editor */
.block-list-title {
    margin-top: 1.5rem;
}

#block-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.75rem;
}

.block-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    cursor: default;
}

.block-card.dragging,
.dl-button-row.dragging {
    opacity: 0.4;
}

.block-card-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.drag-handle {
    cursor: grab;
    color: var(--muted);
    display: inline-flex;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

.block-type-label {
    font-weight: 600;
    font-size: 0.9rem;
}

.block-enabled-toggle {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.block-card-body {
    padding: 0.9rem;
}

.block-raw-html {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    resize: vertical;
}

.dl-button-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dl-button-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg);
    flex-wrap: wrap;
}

.dl-btn-platform {
    font-size: 0.78rem;
    color: var(--muted);
    min-width: 5.5em;
}

.dl-btn-label {
    flex: 1 1 160px;
    min-width: 120px;
}

.dl-btn-enabled-label {
    font-size: 0.8rem;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.dl-btn-url {
    font-size: 0.78rem;
    color: var(--accent-hover);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dl-btn-url-missing {
    color: var(--danger);
}

.dl-button-add,
.block-add-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Structured block edit panels (hero/features/text/qr/footer) */
.block-form-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem 1rem;
}

.block-form-fields .form-group {
    margin-bottom: 0;
}

.block-hint {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
}

.block-text {
    width: 100%;
    font-size: 0.9rem;
    resize: vertical;
}

.feature-item-list,
.footer-link-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.feature-item-row,
.footer-link-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--bg);
    flex-wrap: wrap;
}

.feature-icon {
    flex: 0 1 90px;
    min-width: 70px;
}

.feature-title {
    flex: 1 1 140px;
    min-width: 120px;
}

.feature-desc {
    flex: 2 1 220px;
    min-width: 160px;
}

.footer-link-label {
    flex: 1 1 140px;
    min-width: 120px;
}

.footer-link-url {
    flex: 2 1 220px;
    min-width: 160px;
}

.feature-item-add,
.footer-link-add {
    display: flex;
    margin-top: 0.75rem;
}

.block-add-row {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}
