:root {
    color-scheme: light;
    --primary: #0f766e;
    --primary-hover: #115e59;
    --primary-active: #134e4a;
    --primary-light: #ccfbf1;
    --primary-soft: #f0fdfa;
    --secondary: #0369a1;
    --secondary-hover: #075985;
    --accent: #b45309;
    --bg-main: #f5f7fb;
    --bg-card: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-muted: #eef2f6;
    --text-main: #0f172a;
    --text-body: #334155;
    --text-dim: #64748b;
    --text-faint: #94a3b8;
    --glass-bg: #f1f5f9;
    --glass-border: #dbe3ec;
    --success: #15803d;
    --success-soft: #ecfdf3;
    --warning: #b45309;
    --warning-soft: #fff7ed;
    --error: #b91c1c;
    --error-soft: #fef2f2;
    --ring: rgba(15, 118, 110, 0.24);
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.16), 0 8px 20px rgba(15, 23, 42, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar-width: 264px;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg-main);
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 90% 0%, rgba(15, 118, 110, 0.07), transparent 30rem),
        var(--bg-main);
    color: var(--text-main);
    font-family: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

button,
a,
select,
.upload-area {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(15, 118, 110, 0.12);
}

button {
    color: inherit;
}

a {
    color: inherit;
}

img {
    max-width: 100%;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    color: var(--text-main);
    letter-spacing: -0.025em;
    line-height: 1.18;
    text-wrap: balance;
}

p {
    margin: 0;
    text-wrap: pretty;
}

code,
.stat-value,
td:nth-child(n + 3):nth-child(-n + 6) {
    font-variant-numeric: tabular-nums;
}

:focus-visible {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2000;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--text-main);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-160%);
    transition-property: transform;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-container {
    display: none;
    min-height: 100vh;
    min-height: 100dvh;
}

.sidebar {
    position: relative;
    z-index: 20;
    display: flex;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
    padding: 24px 18px 18px;
    overflow: hidden;
    background: #0b1f2a;
    color: #dbeafe;
    box-shadow: 12px 0 34px rgba(15, 23, 42, 0.08);
}

.sidebar::before {
    position: absolute;
    inset: 0 0 auto;
    height: 240px;
    background: radial-gradient(circle at 30% 0%, rgba(45, 212, 191, 0.18), transparent 70%);
    content: "";
    pointer-events: none;
}

.logo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    margin-bottom: 34px;
    padding: 0 8px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 13px;
    object-fit: cover;
}

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

.logo span {
    display: block;
    color: #ffffff;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.logo small {
    display: block;
    margin-top: 1px;
    color: #8ba5b5;
    font-size: 0.69rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar nav {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 5px;
}

.nav-section-label {
    margin: 0 12px 8px;
    color: #6f8b9d;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.sidebar nav a,
.sidebar nav .nav-link {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: #9fb3c2;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition-property: background-color, color, transform;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar nav a.active {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(14, 116, 144, 0.22));
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.16);
}

.sidebar nav .nav-link.is-disabled {
    color: #5f7888;
    cursor: default;
}

.nav-icon {
    display: inline-flex;
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    color: #7fa0b2;
    font-size: 0.95rem;
}

.sidebar nav a.active .nav-icon,
.sidebar nav a:hover .nav-icon {
    color: #5eead4;
}

.sidebar-footer {
    position: relative;
    padding-top: 18px;
}

.user-profile {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.avatar {
    display: flex;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #14b8a6, #0369a1);
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(8, 145, 178, 0.22);
}

.user-info {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.user-info strong,
.user-info span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info strong {
    color: #f8fafc;
    font-size: 0.84rem;
    font-weight: 600;
}

.user-info span {
    color: #7f99aa;
    font-size: 0.7rem;
}

.logout-btn,
.icon-button {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition-property: background-color, color, transform, box-shadow;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.logout-btn {
    margin-left: auto;
    background: rgba(248, 113, 113, 0.08);
    color: #fca5a5;
}

.logout-btn:hover {
    background: rgba(248, 113, 113, 0.16);
    color: #fecaca;
}

.logout-btn:active,
.icon-button:active,
.btn-primary:active,
.btn-refresh:active,
.copy-btn:active,
.view-btn:active,
.edit-btn:active,
.danger-btn:active {
    transform: scale(0.96);
}

.main-content {
    min-width: 0;
    flex: 1;
    overflow-y: auto;
    padding: 0 32px 40px;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 -32px 28px;
    padding: 16px 32px;
    border-bottom: 1px solid rgba(203, 213, 225, 0.78);
    background: rgba(245, 247, 251, 0.88);
    backdrop-filter: blur(18px);
}

.header-title {
    min-width: 0;
}

.header-title .eyebrow {
    display: block;
    margin-bottom: 3px;
    color: var(--primary);
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.header-title h1 {
    font-size: clamp(1.3rem, 2vw, 1.65rem);
    font-weight: 700;
}

.header-left-group {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 16px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-bar {
    position: relative;
    width: min(100%, 360px);
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-faint);
    font-size: 0.9rem;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-bar input,
.form-group input,
.form-group select,
.form-group textarea,
textarea,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: var(--shadow-xs);
    transition-property: border-color, box-shadow, background-color;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.search-bar input {
    padding: 10px 14px 10px 40px;
}

.search-bar input::placeholder,
.form-group input::placeholder,
textarea::placeholder {
    color: var(--text-faint);
}

.search-bar input:hover,
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: #bdcad8;
}

.search-bar input:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px var(--ring), var(--shadow-xs);
}

.icon-button {
    border: 1px solid var(--glass-border);
    background: var(--bg-card);
    color: var(--text-dim);
    box-shadow: var(--shadow-xs);
}

.icon-button:hover {
    border-color: #bdcad8;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.dashboard-grid {
    width: min(100%, 1500px);
    margin: 0 auto;
}

.stats-row {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px !important;
    width: 100% !important;
    margin-bottom: 20px !important;
}

.stat-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 20px;
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    transition-property: transform, box-shadow;
    transition-duration: 200ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.stat-card::after {
    position: absolute;
    right: -32px;
    bottom: -38px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(15, 118, 110, 0.05);
    content: "";
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

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

.stat-label {
    display: block;
    color: var(--text-dim);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stat-value {
    position: relative;
    z-index: 1;
    margin-top: 8px;
    color: var(--text-main);
    font-size: clamp(1.7rem, 2.4vw, 2.15rem);
    font-weight: 700;
    letter-spacing: -0.04em;
}

.stat-helper {
    position: relative;
    z-index: 1;
    display: block;
    margin-top: 4px;
    color: var(--text-faint);
    font-size: 0.72rem;
}

.stat-icon {
    display: inline-flex;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.08);
}

.links-container {
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
    border-bottom: 1px solid #e9eef4;
}

.table-header-copy {
    min-width: 0;
}

.table-header h2 {
    font-size: 1.08rem;
    font-weight: 700;
}

.table-header p {
    margin-top: 4px;
    color: var(--text-dim);
    font-size: 0.79rem;
}

.table-wrapper,
.table-container {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior: contain;
}

table {
    width: 100%;
    min-width: 940px;
    border-collapse: collapse;
}

th {
    padding: 12px 16px;
    border-bottom: 1px solid #e9eef4;
    background: var(--bg-subtle);
    color: var(--text-dim);
    font-size: 0.69rem;
    font-weight: 800;
    letter-spacing: 0.065em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: 16px;
    border-bottom: 1px solid #edf1f5;
    color: var(--text-body);
    font-size: 0.84rem;
    vertical-align: middle;
}

tbody tr {
    transition-property: background-color;
    transition-duration: 160ms;
}

tbody tr:hover {
    background: #fbfdfd;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.link-name {
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 700;
}

.link-id {
    margin-top: 2px;
    color: var(--text-faint);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.68rem;
}

.link-inline-actions,
.row-actions,
.target-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.link-inline-actions {
    margin-top: 8px;
}

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

.target-link {
    display: block;
    max-width: 190px;
    overflow: hidden;
    color: var(--text-dim);
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.target-link:hover {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tracking-link {
    color: var(--secondary);
    font-size: 0.76rem;
    font-weight: 600;
    text-decoration: none;
}

.tracking-link:hover {
    color: var(--secondary-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.metric-cell {
    color: var(--text-main);
    font-weight: 650;
    text-align: center;
}

.dropoff-cell {
    color: var(--warning);
}

.copy-btn,
.view-btn,
.edit-btn,
.danger-btn,
.btn-refresh,
.btn-primary,
.btn-secondary {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    transition-property: background-color, border-color, color, transform, box-shadow;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.btn-primary {
    padding: 10px 17px;
    border: 1px solid var(--primary);
    background: linear-gradient(135deg, #0f766e, #0e7490);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.17);
}

.btn-primary:hover {
    border-color: var(--primary-hover);
    background: linear-gradient(135deg, #115e59, #075985);
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.23);
    transform: translateY(-1px);
}

.btn-primary:disabled,
.btn-refresh:disabled,
.copy-btn:disabled,
.danger-btn:disabled {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
    box-shadow: none;
}

.btn-refresh,
.btn-secondary {
    padding: 9px 13px;
    border: 1px solid var(--glass-border);
    background: var(--bg-card);
    color: var(--text-body);
    box-shadow: var(--shadow-xs);
}

.btn-refresh:hover,
.btn-secondary:hover {
    border-color: #b8c7d5;
    background: var(--bg-subtle);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.refresh-icon {
    width: 16px;
    height: 16px;
    transition-property: transform;
    transition-duration: 420ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.btn-refresh:hover .refresh-icon {
    transform: rotate(180deg);
}

.copy-btn,
.view-btn,
.edit-btn,
.danger-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid transparent;
    background: transparent;
}

.copy-btn {
    border-color: var(--glass-border);
    background: var(--bg-card);
    color: var(--text-dim);
    font-size: 0.73rem;
}

.copy-btn:hover {
    border-color: #b8c7d5;
    background: var(--bg-subtle);
    color: var(--primary);
}

.view-btn {
    color: var(--secondary);
}

.view-btn:hover {
    background: #eff6ff;
    color: var(--secondary-hover);
}

.edit-btn {
    color: var(--accent);
}

.edit-btn:hover {
    background: var(--warning-soft);
    color: #92400e;
}

.danger-btn {
    color: var(--error);
}

.danger-btn:hover {
    background: var(--error-soft);
    color: #991b1b;
}

.badge-success,
.status-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-success,
.status-badge.success {
    background: var(--success-soft);
    color: var(--success);
    box-shadow: inset 0 0 0 1px rgba(21, 128, 61, 0.12);
}

.status-badge.neutral {
    background: var(--bg-muted);
    color: var(--text-dim);
}

.subtext {
    color: var(--text-dim);
    font-size: 0.79rem;
    overflow-wrap: anywhere;
}

.empty-state,
.loading-state,
.error-state {
    padding: 44px 24px;
    color: var(--text-dim);
    text-align: center;
}

.empty-state-icon {
    display: flex;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    border-radius: 15px;
    background: var(--primary-soft);
    color: var(--primary);
}

.empty-state strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-main);
}

.error-state {
    color: var(--error);
}

.apps-intro {
    padding: 0 22px 18px;
    color: var(--text-dim);
    font-size: 0.84rem;
}

.apps-list {
    display: grid;
    gap: 12px;
    padding: 0 22px 22px;
}

.app-list-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    box-shadow: inset 0 0 0 1px #e4eaf0;
}

.app-list-main {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.app-list-icon {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
}

.app-list-copy {
    min-width: 0;
}

.app-list-name {
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 700;
}

.app-list-meta {
    margin-top: 4px;
    color: var(--text-dim);
    font-size: 0.73rem;
    overflow-wrap: anywhere;
}

.app-list-meta code {
    color: var(--primary);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(2, 15, 24, 0.62);
    backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    display: none;
    width: min(100%, 540px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    border-radius: 24px;
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

.modal-content.active {
    display: flex !important;
    flex-direction: column;
    animation: modal-enter 200ms cubic-bezier(0.2, 0, 0, 1);
}

.modal-content.large {
    width: min(100%, 980px);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    min-height: 74px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid #e9eef4;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
}

.modal-header h3 {
    padding-right: 44px;
    font-size: 1.12rem;
}

.modal-heading-icon {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    margin-right: 9px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    vertical-align: middle;
}

.modal-body {
    padding: 24px;
}

.close {
    position: absolute;
    top: 16px;
    right: 18px;
    z-index: 3;
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-dim);
    cursor: pointer;
    transition-property: background-color, border-color, color, transform;
    transition-duration: 180ms;
}

.close:hover {
    border-color: #bdcad8;
    background: var(--bg-subtle);
    color: var(--text-main);
}

.close:active {
    transform: scale(0.96);
}

.modal-intro {
    margin-bottom: 20px;
    color: var(--text-dim);
    font-size: 0.86rem;
    line-height: 1.65;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-body);
    font-size: 0.8rem;
    font-weight: 700;
}

.field-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-row input {
    flex: 1;
}

.form-group input,
.form-group select,
.form-group textarea,
textarea,
select {
    padding: 10px 12px;
}

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

.field-help {
    margin-top: 6px;
    color: var(--text-dim);
    font-size: 0.72rem;
    line-height: 1.5;
}

.required {
    color: var(--error);
}

.upload-area {
    position: relative;
    min-height: 150px;
    padding: 24px;
    border: 1.5px dashed #b8c6d4;
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    color: var(--text-body);
    text-align: center;
    cursor: pointer;
    transition-property: border-color, background-color, box-shadow, transform;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 3px var(--ring);
}

.upload-area:active {
    transform: scale(0.99);
}

.upload-icon {
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: 14px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1rem;
}

.upload-title {
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 700;
}

.upload-caption {
    margin-top: 4px;
    color: var(--text-dim);
    font-size: 0.75rem;
}

.file-name-display {
    margin-top: 10px;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    box-shadow: inset 0 0 0 1px #e4eaf0;
}

.toggle-info {
    display: flex;
    flex-direction: column;
}

.toggle-label {
    color: var(--text-main);
    font-size: 0.84rem;
    font-weight: 700;
}

.toggle-desc {
    margin-top: 2px;
    color: var(--text-dim);
    font-size: 0.72rem;
}

.switch {
    position: relative;
    display: inline-flex;
    width: 48px;
    height: 28px;
    flex: 0 0 auto;
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    cursor: pointer;
    transition-property: background-color, box-shadow;
    transition-duration: 180ms;
}

.slider::before {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.22);
    content: "";
    transition-property: transform;
    transition-duration: 180ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.switch input:focus-visible + .slider {
    box-shadow: 0 0 0 3px var(--ring);
}

.info-box {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    background: #eff6ff;
    color: #1e3a8a;
    box-shadow: inset 0 0 0 1px #dbeafe;
    font-size: 0.8rem;
    line-height: 1.6;
}

.preview-box {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    box-shadow: inset 0 0 0 1px #e4eaf0;
}

.preview-label {
    margin-bottom: 10px;
    color: var(--text-faint);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.share-preview {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
}

.share-preview-logo {
    display: flex;
    width: 52px;
    height: 52px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--bg-muted);
    color: var(--primary);
}

.share-preview-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    outline: 1px solid rgba(0, 0, 0, 0.1);
}

.share-preview-copy {
    min-width: 0;
}

.share-preview-title {
    color: var(--text-main);
    font-size: 0.88rem;
    font-weight: 700;
}

.share-preview-description {
    margin-top: 3px;
    overflow: hidden;
    color: var(--text-dim);
    font-size: 0.74rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.branding-preview {
    position: relative;
    display: none;
    width: fit-content;
    margin: 0 auto 8px;
}

.branding-preview img {
    display: block;
    max-height: 110px;
    border-radius: var(--radius-md);
    outline: 1px solid rgba(0, 0, 0, 0.1);
}

.remove-preview-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--error);
    color: #ffffff;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition-property: background-color, transform;
    transition-duration: 180ms;
}

.remove-preview-btn:hover {
    background: #991b1b;
}

.remove-preview-btn:active {
    transform: scale(0.96);
}

.modal-body .btn-primary {
    width: 100%;
    margin-top: 4px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #c5d0dc;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
    background-clip: padding-box;
}

@media (max-width: 1180px) {
    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .top-header {
        align-items: flex-start;
    }

    .header-left-group {
        align-items: stretch;
        flex-direction: column;
    }

    .search-bar {
        width: 100%;
        max-width: none;
    }
}

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

    .sidebar {
        position: sticky;
        top: 0;
        width: 100%;
        min-width: 0;
        min-height: auto;
        padding: 10px 14px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    }

    .sidebar::before,
    .sidebar-footer,
    .nav-section-label,
    .logo small {
        display: none;
    }

    .logo {
        min-height: 42px;
        margin: 0 0 8px;
        padding: 0 4px;
    }

    .logo-icon {
        width: 34px;
        height: 34px;
        border-radius: 10px;
    }

    .logo span {
        font-size: 0.98rem;
    }

    .sidebar nav {
        flex-direction: row;
        gap: 6px;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }

    .sidebar nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar nav a,
    .sidebar nav .nav-link {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 8px 11px;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .sidebar nav a:hover {
        transform: none;
    }

    .main-content {
        overflow: visible;
        padding: 0 18px 32px;
    }

    .top-header {
        position: relative;
        min-height: 0;
        margin: 0 -18px 22px;
        padding: 18px;
        background: rgba(245, 247, 251, 0.94);
    }
}

@media (max-width: 640px) {
    .main-content {
        padding-inline: 14px;
    }

    .top-header {
        margin-inline: -14px;
        padding: 16px 14px;
        flex-direction: column;
        align-items: stretch;
    }

    .header-left-group {
        width: 100%;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn-primary,
    .header-left-group > .btn-primary {
        width: 100%;
    }

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

    .stat-card {
        padding: 17px;
    }

    .table-header {
        align-items: stretch;
        flex-direction: column;
        padding: 17px;
    }

    .table-header .btn-primary,
    .table-header .btn-refresh {
        width: 100%;
    }

    .apps-intro,
    .apps-list {
        padding-right: 17px;
        padding-left: 17px;
    }

    .app-list-card {
        align-items: stretch;
        flex-direction: column;
    }

    .app-list-card .danger-btn {
        width: 100%;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-content,
    .modal-content.large {
        width: 100%;
        max-height: 94dvh;
        border-radius: 22px 22px 0 0;
    }

    .modal-header,
    .modal-body {
        padding-right: 18px;
        padding-left: 18px;
    }

    .field-row {
        align-items: stretch;
        flex-direction: column;
    }

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

    .toggle-group {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Scroll only table-wrapper inside dashboard page on desktop */
@media (min-width: 901px) {
    .dashboard-page .main-content {
        overflow-y: hidden !important;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
    }
    .dashboard-page .dashboard-grid {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    .dashboard-page .links-container {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
        margin-bottom: 20px;
    }
    .dashboard-page .table-wrapper {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }
    .dashboard-page th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--bg-subtle);
    }
}
