@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-dark: #0d172a;
    --text: #172033;
    --muted: #6b7485;
    --line: #e5eaf1;
    --primary: #5b5bd6;
    --primary-dark: #4747b8;
    --primary-soft: #ededff;
    --accent: #17a673;
    --accent-soft: #e8f8f1;
    --danger: #dc4f64;
    --danger-soft: #fff0f2;
    --warning: #b97916;
    --warning-soft: #fff7e6;
    --shadow-sm: 0 8px 24px rgba(19, 33, 68, 0.06);
    --shadow-md: 0 18px 50px rgba(19, 33, 68, 0.12);
    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 24px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body.modal-open {
    overflow: hidden;
}

[hidden] {
    display: none !important;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
}

button,
input {
    font: inherit;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: 3px solid rgba(91, 91, 214, 0.25);
    outline-offset: 2px;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 7px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
}

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

.nowrap {
    white-space: nowrap;
}

.align-right {
    text-align: right !important;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.primary-btn {
    color: #fff;
    background: linear-gradient(135deg, #6767e8, var(--primary));
    box-shadow: 0 9px 20px rgba(91, 91, 214, .23);
}

.primary-btn:hover {
    color: #fff;
    background: linear-gradient(135deg, #5d5dde, var(--primary-dark));
    box-shadow: 0 12px 25px rgba(91, 91, 214, .3);
}

.ghost-btn {
    color: #4f596b;
    border-color: var(--line);
    background: #fff;
}

.ghost-btn:hover {
    color: var(--primary);
    border-color: #cfcff7;
    background: var(--primary-soft);
}

.danger-ghost-btn {
    color: var(--danger);
    border-color: #ffd6dc;
    background: var(--danger-soft);
}

.danger-ghost-btn:hover {
    color: #b93248;
    border-color: #ffc2cc;
    background: #ffe5e9;
}

.analytics-btn {
    color: #167454;
    border-color: #ccebdd;
    background: var(--accent-soft);
}

.analytics-btn:hover {
    color: #0e5c41;
    border-color: #a9dcc8;
    background: #dff5eb;
}

.small-btn,
.btn.small {
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 8px;
    font-size: 12px;
}

.wide-btn {
    width: 100%;
    min-height: 48px;
}

.copy-btn,
.icon-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 0;
    color: var(--primary);
    background: var(--primary-soft);
    cursor: pointer;
    font-weight: 700;
}

.copy-btn {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 12px;
}

.icon-copy-btn {
    width: 29px;
    height: 29px;
    border-radius: 7px;
    font-size: 15px;
}

.copy-btn:hover,
.icon-copy-btn:hover {
    background: #ddddff;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 17px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row.two-columns > * {
    width: 50%;
}

.form-group {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    color: #465064;
    font-size: 13px;
    font-weight: 700;
}

.form-group small,
.switch-copy small {
    color: var(--muted);
    font-size: 11px;
}

.form-group input,
.search-box input {
    width: 100%;
    min-height: 45px;
    padding: 11px 13px;
    border: 1px solid #dce2eb;
    border-radius: var(--radius-sm);
    color: var(--text);
    background: #fff;
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.form-group input::placeholder,
.search-box input::placeholder {
    color: #a1a9b7;
}

.form-group input:hover,
.search-box input:hover {
    border-color: #c7cfdb;
}

.form-group input:focus,
.search-box input:focus {
    outline: 0;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(91, 91, 214, .10);
}

.grow-field {
    flex: 1;
}

.input-with-prefix {
    display: flex;
    min-width: 0;
    border: 1px solid #dce2eb;
    border-radius: var(--radius-sm);
    background: #fff;
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input-with-prefix:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(91, 91, 214, .10);
}

.input-with-prefix > span {
    display: flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: 50%;
    padding: 0 12px;
    border-right: 1px solid var(--line);
    color: #737d8f;
    background: var(--surface-soft);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.input-with-prefix input {
    min-width: 100px;
    border: 0;
    border-radius: 0;
    box-shadow: none !important;
}

.target-prefix > span {
    max-width: 55%;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 82px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    transform: translateY(-50%);
    padding: 6px 8px;
    border: 0;
    color: var(--primary);
    background: transparent;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    min-height: 48px;
    margin-bottom: 20px;
    padding: 12px 15px;
    border: 1px solid;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    transition: opacity .4s ease, transform .4s ease;
}

.alert.success {
    color: #146044;
    border-color: #bce8d7;
    background: #eaf8f2;
}

.alert.error {
    color: #9d2e41;
    border-color: #ffcbd3;
    background: #fff0f2;
}

.alert.fade-out {
    opacity: 0;
    transform: translateY(-5px);
    pointer-events: none;
}

/* Authentication */
.auth-page {
    background:
        radial-gradient(circle at 10% 15%, rgba(93, 93, 225, .22), transparent 27%),
        radial-gradient(circle at 88% 82%, rgba(25, 166, 116, .15), transparent 25%),
        #f3f5fb;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr);
    min-height: 100vh;
}

.auth-showcase {
    position: relative;
    display: flex;
    min-height: 100%;
    padding: clamp(35px, 6vw, 80px);
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
    background:
        linear-gradient(145deg, rgba(12, 20, 40, .96), rgba(23, 34, 64, .92)),
        radial-gradient(circle at 65% 30%, #6363dc, transparent 42%);
    overflow: hidden;
}

.auth-showcase::before,
.auth-showcase::after {
    position: absolute;
    content: "";
    border-radius: 50%;
    pointer-events: none;
}

.auth-showcase::before {
    width: 430px;
    height: 430px;
    right: -190px;
    top: -90px;
    border: 1px solid rgba(255,255,255,.11);
    box-shadow: 0 0 0 55px rgba(255,255,255,.025), 0 0 0 110px rgba(255,255,255,.018);
}

.auth-showcase::after {
    width: 180px;
    height: 180px;
    left: -80px;
    bottom: 80px;
    background: rgba(91,91,214,.22);
    filter: blur(2px);
}

.register-showcase {
    background: linear-gradient(145deg, #10293a, #163c45 58%, #174b42);
}

.auth-brand,
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 800;
}

.auth-brand {
    position: relative;
    z-index: 1;
}

.auth-brand-logo,
.mobile-brand img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(0,0,0,.15);
}

.auth-copy {
    position: relative;
    z-index: 1;
    max-width: 580px;
    margin: auto 0;
    padding: 70px 0;
}

.auth-copy .eyebrow {
    color: #aeb4ff;
}

.register-showcase .auth-copy .eyebrow {
    color: #8ee0bd;
}

.auth-copy h1 {
    max-width: 600px;
    margin-bottom: 20px;
    font-size: clamp(35px, 4.6vw, 64px);
    line-height: 1.04;
    letter-spacing: -.045em;
}

.auth-copy p {
    max-width: 580px;
    color: rgba(255,255,255,.68);
    font-size: clamp(14px, 1.4vw, 18px);
}

.feature-pills {
    display: flex;
    margin-top: 30px;
    gap: 9px;
    flex-wrap: wrap;
}

.feature-pills span {
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
    color: rgba(255,255,255,.80);
    background: rgba(255,255,255,.06);
    font-size: 11px;
    font-weight: 700;
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 35px;
    background: rgba(255,255,255,.78);
    backdrop-filter: blur(18px);
}

.auth-form-wrap {
    width: 100%;
    max-width: 500px;
    padding: clamp(27px, 4.5vw, 54px);
    border: 1px solid rgba(228,232,241,.95);
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.95);
    box-shadow: var(--shadow-md);
}

.mobile-brand {
    display: none;
    margin-bottom: 30px;
}

.auth-heading {
    margin-bottom: 27px;
}

.auth-heading h2 {
    margin-bottom: 7px;
    font-size: clamp(25px, 3vw, 34px);
    letter-spacing: -.035em;
}

.auth-heading p,
.form-footer {
    color: var(--muted);
    font-size: 13px;
}

.auth-form {
    gap: 16px;
}

.form-footer {
    margin-top: 23px;
    text-align: center;
}

.form-footer a {
    font-weight: 700;
}

/* Dashboard structure */
.dashboard-container {
    min-height: 100vh;
}

.dashboard-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    min-height: 72px;
    padding: 12px clamp(18px, 4vw, 50px);
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(226,231,239,.9);
    background: rgba(255,255,255,.90);
    backdrop-filter: blur(16px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
}

.brand:hover {
    color: var(--text);
    text-decoration: none;
}

.brand-logo-wrap {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid #e6e8f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.nav-logo {
    width: 31px;
    height: 31px;
    object-fit: contain;
}

.brand > span:last-child,
.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand strong {
    font-size: 15px;
}

.brand small,
.user-meta small {
    color: var(--muted);
    font-size: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.workspace-badge {
    margin-right: 7px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #5757bd;
    background: var(--primary-soft);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
}

.user-avatar {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 11px;
    color: #fff;
    background: linear-gradient(135deg, #7070e9, #4949b6);
    font-size: 13px;
    font-weight: 800;
}

.user-meta strong {
    max-width: 120px;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-content {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: clamp(25px, 4vw, 50px) clamp(14px, 4vw, 42px) 70px;
}

.hero-row,
.traffic-hero {
    display: flex;
    margin-bottom: 28px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.hero-row h1,
.traffic-hero h1 {
    margin-bottom: 5px;
    font-size: clamp(28px, 4vw, 43px);
    line-height: 1.1;
    letter-spacing: -.04em;
}

.hero-row p,
.traffic-hero p,
.section-heading p {
    color: var(--muted);
    font-size: 13px;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 25px;
    gap: 14px;
}

.stat-card {
    display: flex;
    min-height: 112px;
    padding: 20px;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 14px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 13px;
    font-weight: 800;
}

.stat-card:nth-child(3) .stat-icon {
    color: #12704f;
    background: var(--accent-soft);
}

.stat-card:nth-child(4) .stat-icon {
    color: #9c6511;
    background: var(--warning-soft);
}

.stat-card > div:last-child {
    display: flex;
    flex-direction: column;
}

.stat-card span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.stat-card strong {
    margin-top: 3px;
    font-size: 25px;
    line-height: 1.1;
    letter-spacing: -.03em;
}

/* Cards and section headings */
.card,
.link-group-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card {
    padding: clamp(19px, 2.5vw, 28px);
}

.create-group-card {
    margin-bottom: 35px;
}

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

.section-heading h2 {
    margin-bottom: 4px;
    font-size: 20px;
    letter-spacing: -.025em;
}

.inline-create-form {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
}

.inline-create-form > .form-group:first-of-type {
    width: min(300px, 30%);
}

.form-submit-btn {
    flex: 0 0 auto;
}

.groups-section {
    margin-top: 12px;
}

.groups-heading {
    margin-bottom: 17px;
}

.search-box {
    width: min(340px, 100%);
}

.search-box input {
    min-height: 42px;
    padding-left: 38px;
    background-image: radial-gradient(circle, #8e97a6 0 2px, transparent 2.5px), linear-gradient(45deg, transparent 45%, #8e97a6 45% 55%, transparent 55%);
    background-position: 16px 16px, 21px 22px;
    background-size: 10px 10px, 8px 8px;
    background-repeat: no-repeat;
}

.groups-list {
    display: flex;
    flex-direction: column;
    gap: 19px;
}

.link-group-card {
    padding: clamp(18px, 2.6vw, 28px);
    overflow: hidden;
}

.group-header {
    display: flex;
    margin-bottom: 18px;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.group-title-wrap {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 13px;
}

.group-icon {
    display: grid;
    width: 43px;
    height: 43px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient(135deg, #6d6de3, #4c4cb8);
    box-shadow: 0 8px 18px rgba(91,91,214,.20);
    font-size: 20px;
    font-weight: 700;
}

.group-header h3 {
    max-width: 700px;
    font-size: 18px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.group-meta {
    display: flex;
    margin-top: 3px;
    gap: 6px;
    color: var(--muted);
    font-size: 10px;
}

.group-actions,
.action-buttons {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

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

.base-url-bar {
    display: flex;
    min-height: 57px;
    margin-bottom: 16px;
    padding: 9px 12px 9px 15px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #e7e9f7;
    border-radius: 12px;
    background: linear-gradient(90deg, #f7f7ff, #fafbff);
}

.base-url-bar > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.base-url-bar span {
    color: #8088a0;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .12em;
}

.base-url-bar a {
    max-width: 900px;
    color: #3f47a5;
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.collapsible-panel {
    margin: 0 0 16px;
    padding: 16px;
    border: 1px dashed #cfd4e2;
    border-radius: 12px;
    background: #fafbfc;
}

.compact-form {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
}

.create-link-panel {
    margin: 20px 0 23px;
    padding: 20px;
    border: 1px solid #e7e9f2;
    border-radius: 14px;
    background: var(--surface-soft);
}

.panel-title {
    margin-bottom: 16px;
}

.panel-title h4,
.table-heading h4 {
    font-size: 14px;
}

.panel-title p {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.link-form-row {
    align-items: flex-end;
}

.switch-field {
    display: flex;
    min-width: 210px;
    min-height: 45px;
    padding: 7px 9px 7px 12px;
    align-items: center;
    justify-content: space-between;
    gap: 13px;
    border: 1px solid #dce2eb;
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
}

.switch-copy {
    display: flex;
    flex-direction: column;
}

.switch-copy strong {
    color: #465064;
    font-size: 12px;
}

.switch-field input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch-ui {
    position: relative;
    width: 40px;
    height: 23px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #cbd2dc;
    transition: background .18s ease;
}

.switch-ui::after {
    position: absolute;
    width: 17px;
    height: 17px;
    left: 3px;
    top: 3px;
    content: "";
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,.18);
    transition: transform .18s ease;
}

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

.switch-field input:checked + .switch-ui::after {
    transform: translateX(17px);
}

.switch-field:has(input:focus-visible) {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(91, 91, 214, .10);
}

.referral-path-field {
    padding-top: 2px;
}

.form-actions-right {
    display: flex;
    justify-content: flex-end;
}

/* Tables */
.links-table-container {
    margin-top: 2px;
}

.table-heading {
    display: flex;
    margin-bottom: 10px;
    align-items: center;
    justify-content: space-between;
}

.table-heading > span,
.record-count {
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--muted);
    background: #f1f3f7;
    font-size: 10px;
    font-weight: 700;
}

.responsive-table {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.links-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

.links-table th,
.links-table td {
    padding: 14px 13px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
}

.links-table th {
    color: #6f7889;
    background: #f7f9fc;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

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

.links-table tbody tr:hover td {
    background: #fcfcff;
}

.links-table th:nth-child(1) { width: 25%; }
.links-table th:nth-child(2) { width: 31%; }
.links-table th:nth-child(3) { width: 18%; }
.links-table th:nth-child(4) { width: 26%; }

.url-cell,
.destination-cell,
.traffic-cell {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 5px;
}

.url-cell {
    flex-direction: row;
    align-items: center;
}

.url-cell a,
.destination-cell a {
    min-width: 0;
    color: #414a60;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.url-cell a:hover,
.destination-cell a:hover {
    color: var(--primary);
}

.destination-cell {
    align-items: flex-start;
}

.type-badge {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
}

.type-badge.referral {
    color: #79520e;
    background: var(--warning-soft);
}

.type-badge.direct {
    color: #17674c;
    background: var(--accent-soft);
}

.traffic-cell strong {
    font-size: 12px;
}

.traffic-cell span {
    color: var(--muted);
    font-size: 9px;
}

.no-links-message,
.empty-state {
    padding: 25px;
    border: 1px dashed #d7dce5;
    border-radius: 12px;
    color: var(--muted);
    background: #fafbfc;
    text-align: center;
    font-size: 12px;
}

.empty-state {
    padding: 50px 25px;
}

.empty-icon {
    display: grid;
    width: 50px;
    height: 50px;
    margin: 0 auto 13px;
    place-items: center;
    border-radius: 15px;
    color: var(--primary);
    background: var(--primary-soft);
    font-size: 20px;
    font-weight: 800;
}

.empty-state h3 {
    margin-bottom: 4px;
    color: var(--text);
    font-size: 16px;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(13, 20, 37, .65);
    backdrop-filter: blur(6px);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    max-height: calc(100vh - 36px);
    padding: clamp(22px, 4vw, 34px);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 25px 80px rgba(8, 14, 30, .32);
    overflow-y: auto;
    animation: modalIn .18s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 17px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    color: #6f7889;
    background: #f1f3f7;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

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

.modal-heading {
    margin-bottom: 24px;
    padding-right: 35px;
}

.modal-heading h2 {
    margin-bottom: 5px;
    font-size: 25px;
    letter-spacing: -.03em;
}

.modal-heading p {
    color: var(--muted);
    font-size: 12px;
}

.modal-switch {
    width: 100%;
}

.modal-actions {
    display: flex;
    margin-top: 5px;
    justify-content: flex-end;
    gap: 9px;
}

.toast {
    position: fixed;
    z-index: 300;
    right: 22px;
    bottom: 22px;
    padding: 11px 16px;
    border-radius: 11px;
    color: #fff;
    background: #172033;
    box-shadow: var(--shadow-md);
    font-size: 12px;
    font-weight: 700;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Traffic page */
.traffic-page-content {
    width: min(1320px, 100%);
}

.traffic-hero {
    align-items: center;
}

.traffic-url-row {
    display: flex;
    margin: 9px 0 8px;
    align-items: center;
    gap: 9px;
}

.traffic-url-row a {
    max-width: min(750px, 75vw);
    color: #3f47a5;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.target-summary {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.target-summary a {
    max-width: 650px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analytics-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr);
    margin-bottom: 20px;
    gap: 18px;
}

.chart-card,
.top-ip-card {
    min-height: 360px;
}

.bar-chart {
    display: flex;
    height: 250px;
    padding-top: 20px;
    align-items: flex-end;
    justify-content: space-around;
    gap: 10px;
}

.bar-column {
    display: flex;
    height: 100%;
    min-width: 35px;
    flex: 1;
    align-items: center;
    flex-direction: column;
    justify-content: flex-end;
}

.bar-value {
    margin-bottom: 6px;
    color: #535d70;
    font-size: 10px;
    font-weight: 800;
}

.bar-track {
    position: relative;
    width: min(42px, 70%);
    height: 175px;
    border-radius: 10px 10px 4px 4px;
    background: #eef0f6;
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 4px;
    border-radius: 9px 9px 3px 3px;
    background: linear-gradient(180deg, #7979ec, #5555c9);
}

.bar-label {
    display: flex;
    margin-top: 8px;
    align-items: center;
    flex-direction: column;
    color: #545e71;
    font-size: 10px;
    font-weight: 700;
}

.bar-label small {
    color: #9aa2af;
    font-size: 8px;
    font-weight: 500;
}

.ip-list {
    display: flex;
    max-height: 275px;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.ip-item {
    display: flex;
    padding: 10px 11px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafbfc;
}

.ip-item > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.ip-item strong {
    font-family: Consolas, monospace;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ip-item span {
    color: var(--muted);
    font-size: 8px;
}

.ip-item b {
    flex: 0 0 auto;
    color: var(--primary);
    font-size: 10px;
}

.traffic-log-card {
    margin-top: 0;
}

.log-heading {
    margin-bottom: 17px;
}

.traffic-table {
    min-width: 920px;
    table-layout: auto;
}

.traffic-table th:nth-child(1) { width: 155px; }
.traffic-table th:nth-child(2) { width: 145px; }
.traffic-table th:nth-child(3) { width: 28%; }
.traffic-table th:nth-child(4) { width: auto; }

.traffic-table code {
    padding: 4px 6px;
    border-radius: 6px;
    color: #344054;
    background: #f1f3f6;
    font-size: 10px;
}

.truncate-cell,
.user-agent-cell {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-empty {
    padding: 35px 20px;
}

.pagination {
    display: flex;
    margin-top: 17px;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.pagination span {
    color: var(--muted);
    font-size: 11px;
}

/* Error page */
.error-page {
    display: grid;
    min-height: 100vh;
    padding: 20px;
    place-items: center;
    background: radial-gradient(circle at 50% 20%, rgba(91,91,214,.13), transparent 35%), var(--bg);
}

.error-card {
    width: min(520px, 100%);
    padding: 45px 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.error-code {
    color: var(--primary);
    font-size: 74px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.07em;
}

.error-card h1 {
    margin: 15px 0 7px;
    font-size: 24px;
}

.error-card p {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 13px;
}

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

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

    .top-ip-card {
        min-height: auto;
    }

    .links-table {
        min-width: 1050px;
    }
}

@media (max-width: 900px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-showcase {
        display: none;
    }

    .auth-panel {
        min-height: 100vh;
        padding: 20px;
    }

    .mobile-brand {
        display: flex;
    }

    .dashboard-nav {
        padding: 11px 15px;
    }

    .workspace-badge,
    .user-meta {
        display: none;
    }

    .inline-create-form,
    .compact-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-create-form > .form-group:first-of-type {
        width: 100%;
    }
}

@media (max-width: 680px) {
    .dashboard-content {
        padding: 24px 11px 55px;
    }

    .brand small,
    .user-avatar {
        display: none;
    }

    .brand-logo-wrap {
        width: 38px;
        height: 38px;
    }

    .nav-logo {
        width: 28px;
        height: 28px;
    }

    .hero-row,
    .traffic-hero,
    .section-heading,
    .group-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-row > .btn,
    .traffic-hero > .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
    }

    .stat-card {
        min-height: 95px;
        padding: 14px;
        gap: 10px;
    }

    .stat-icon {
        width: 39px;
        height: 39px;
        border-radius: 11px;
        font-size: 10px;
    }

    .stat-card strong {
        font-size: 20px;
    }

    .stat-card span {
        font-size: 9px;
    }

    .card,
    .link-group-card {
        border-radius: 14px;
    }

    .create-group-card,
    .link-group-card {
        padding: 17px;
    }

    .groups-heading .search-box {
        width: 100%;
    }

    .group-actions {
        width: 100%;
    }

    .group-actions .btn,
    .group-actions form {
        flex: 1;
    }

    .group-actions form .btn {
        width: 100%;
    }

    .base-url-bar a {
        max-width: 67vw;
    }

    .create-link-panel {
        margin-right: -5px;
        margin-left: -5px;
        padding: 15px;
    }

    .form-row,
    .form-row.two-columns {
        flex-direction: column;
    }

    .form-row.two-columns > * {
        width: 100%;
    }

    .switch-field {
        width: 100%;
        min-width: 0;
    }

    .input-with-prefix {
        flex-direction: column;
    }

    .input-with-prefix > span,
    .target-prefix > span {
        max-width: 100%;
        min-height: 34px;
        padding: 8px 11px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .form-actions-right .btn {
        width: 100%;
    }

    .auth-form-wrap {
        padding: 26px 20px;
        border-radius: 18px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .traffic-url-row {
        align-items: flex-start;
    }

    .traffic-url-row a {
        max-width: 70vw;
    }

    .bar-chart {
        gap: 4px;
    }

    .bar-track {
        width: 70%;
    }

    .toast {
        right: 12px;
        bottom: 12px;
        left: 12px;
        text-align: center;
    }
}
