:root {
    --bg: #050505;
    --panel: rgba(26, 26, 26, 0.9);
    --panel-solid: #1a1a1a;
    --panel-soft: rgba(37, 37, 37, 0.92);
    --text: rgba(255, 255, 255, 0.9);
    --muted: rgba(255, 255, 255, 0.68);
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(231, 90, 34, 0.42);
    --primary: #d70916;
    --primary-dark: #aa0711;
    --accent: #e75a22;
    --accent-warm: #e7b012;
    --success: #43d07a;
    --danger: #d70916;
    --danger-dark: #a80712;
    --warning-bg: rgba(231, 176, 18, 0.14);
    --warning-text: #ffd56a;
    --error-bg: rgba(215, 9, 22, 0.16);
    --error-text: #ff8a8f;
    --success-bg: rgba(67, 208, 122, 0.14);
    --success-text: #7ee2a4;
    --shadow: 0 24px 65px rgba(0, 0, 0, 0.42), 0 0 32px rgba(231, 90, 34, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 0%, rgba(231, 90, 34, 0.18), rgba(0, 0, 0, 0) 34rem),
        linear-gradient(rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.9)),
        url('/assets/eboshi-fon3.png') center top / 560px auto fixed,
        var(--bg);
    color: var(--text);
    font-family: Rubik, Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

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

a:hover {
    text-decoration: underline;
}

.site-header {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.site-header__inner,
.main {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header__inner {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}

.nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-link {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    padding: 6px 9px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.nav-link:hover {
    background: #eef3f9;
    text-decoration: none;
}

.nav-link--active {
    color: #fff;
    background: var(--primary);
}

.nav-link--active:hover {
    color: #fff;
    background: var(--primary-dark);
}

.main {
    padding: 32px 0 56px;
}

.page-title {
    margin: 0 0 18px;
    font-size: 30px;
    line-height: 1.15;
}

.page-subtitle {
    margin: -10px 0 0;
}

.section-title {
    margin: 0;
    font-size: 20px;
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.panel--narrow {
    max-width: 480px;
    margin: 0 auto;
}

.form-grid {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label,
.checkbox {
    color: var(--text);
    font-weight: 700;
}

.field input[type='text'],
.field input[type='url'],
.field input[type='password'],
.field select,
.result-url {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

.field select {
    appearance: none;
}

.result-url {
    min-height: 126px;
    resize: vertical;
    overflow-wrap: anywhere;
}

.field input:focus,
.field select:focus,
.result-url:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(29, 111, 214, 0.16);
}

.help {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.field-error {
    color: var(--error-text);
    font-size: 14px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

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

.button,
button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 9px 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--primary);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}

.button:hover,
button:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.button--secondary {
    color: var(--text);
    background: #fff;
    border-color: var(--line-strong);
}

.button--secondary:hover {
    color: var(--text);
    background: #eef3f9;
}

.button--danger {
    background: var(--danger);
}

.button--danger:hover {
    background: var(--danger-dark);
}

.button--small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 14px;
}

.button--link {
    min-height: auto;
    padding: 0;
    color: var(--primary);
    background: transparent;
    border: 0;
}

.button--link:hover {
    color: var(--primary-dark);
    background: transparent;
    text-decoration: underline;
}

.flash {
    margin: 0 0 18px;
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid transparent;
}

.flash--success {
    color: var(--success-text);
    background: var(--success-bg);
    border-color: #b8e4c9;
}

.flash--error {
    color: var(--error-text);
    background: var(--error-bg);
    border-color: #f5b9b9;
}

.flash--warning {
    color: var(--warning-text);
    background: var(--warning-bg);
    border-color: #efd27a;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.table-wrap--plain {
    box-shadow: none;
}

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

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

th {
    color: var(--muted);
    background: #f9fbfe;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

.url-cell {
    max-width: 330px;
    overflow-wrap: anywhere;
}

.short-link {
    display: inline-block;
    max-width: 240px;
    overflow-wrap: anywhere;
    font-weight: 700;
}

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

.status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 13px;
    font-weight: 700;
}

.status--active {
    color: var(--success-text);
    background: var(--success-bg);
}

.status--inactive {
    color: var(--muted);
    background: #eef1f6;
}

.inline-form {
    display: inline;
}

.copy-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.target-preview {
    display: block;
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.empty {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.chart-panel {
    margin-bottom: 18px;
    transition: opacity 160ms ease, transform 160ms ease;
}

.chart-panel--loading {
    opacity: 0.62;
    transform: translateY(2px);
    pointer-events: none;
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.chart-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
}

.chart-header p {
    margin: 0;
}

.chart-total {
    min-width: 116px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: right;
    background: #f9fbfe;
}

.chart-total strong,
.chart-total span {
    display: block;
}

.chart-total strong {
    font-size: 28px;
    line-height: 1;
}

.chart-total span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.chart-range-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.chart-range-form label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.chart-range-select,
.range-tab {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 6px 34px 6px 10px;
    color: var(--text);
    background: #fff;
    font-size: 14px;
    font-weight: 700;
}

.chart-range-select {
    appearance: none;
    min-width: 170px;
    background:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 17px) 14px / 6px 6px no-repeat,
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 14px / 6px 6px no-repeat,
        #fff;
    cursor: pointer;
}

.chart-range-select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(29, 111, 214, 0.16);
}

.range-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.range-tab {
    padding: 6px 10px;
}

.range-tab:hover {
    background: #eef3f9;
    text-decoration: none;
}

.range-tab--active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.range-tab--active:hover {
    background: var(--primary-dark);
}

.chart-empty {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    color: var(--muted);
    background: #fbfcff;
    cursor: ns-resize;
    text-align: center;
}

.chart-svg-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcff;
    cursor: ns-resize;
    transition: opacity 160ms ease, transform 160ms ease;
}

.chart-svg {
    display: block;
    width: 100%;
    min-width: 720px;
    height: auto;
}

.chart-grid {
    stroke: #dfe6f0;
    stroke-width: 1;
}

.chart-axis {
    stroke: var(--line-strong);
    stroke-width: 1.5;
}

.chart-area {
    fill: rgba(29, 111, 214, 0.12);
}

.chart-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-point {
    fill: #fff;
    stroke: var(--primary);
    stroke-width: 2;
    cursor: pointer;
    transition: fill 120ms ease, stroke-width 120ms ease;
}

.chart-point:hover,
.chart-point:focus {
    fill: var(--primary);
    stroke-width: 3;
    outline: none;
}

.chart-tooltip {
    position: fixed;
    z-index: 50;
    min-width: 86px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    border: 1px solid rgba(24, 32, 47, 0.12);
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
    background: rgba(24, 32, 47, 0.94);
    box-shadow: 0 12px 28px rgba(24, 32, 47, 0.2);
    transition: opacity 120ms ease, transform 120ms ease;
}

.chart-tooltip--visible {
    opacity: 1;
    transform: translateY(0);
}

.chart-tooltip strong,
.chart-tooltip span,
.chart-tooltip small {
    display: block;
}

.chart-tooltip strong {
    font-size: 22px;
    line-height: 1;
}

.chart-tooltip span {
    margin-top: 2px;
    font-size: 13px;
    font-weight: 700;
}

.chart-tooltip small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.74);
    font-size: 12px;
}

.chart-x-label,
.chart-y-label {
    fill: var(--muted);
    font-size: 12px;
}

.recent-clicks {
    margin-top: 18px;
}

.recent-clicks h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

.recent-clicks ul {
    margin: 0;
    padding-left: 20px;
}

.recent-clicks li + li {
    margin-top: 6px;
}

.utm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
    gap: 18px;
}

.utm-layout .result-panel {
    grid-column: 1 / -1;
}

.utm-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.utm-fields .field:nth-child(3) {
    grid-column: 1 / -1;
}

.settings-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.metric-tile {
    min-height: 98px;
    display: grid;
    align-content: center;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    box-shadow: var(--shadow);
}

.metric-tile span,
.metric-tile small {
    color: var(--muted);
    font-size: 13px;
}

.metric-tile strong {
    font-size: 26px;
    line-height: 1;
}

.metric-value--good {
    color: var(--success);
}

.metric-value--bad {
    color: var(--danger);
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.analytics-panel h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

.mini-table {
    min-width: 0;
    width: 100%;
}

.mini-table th,
.mini-table td {
    padding: 10px 0;
}

.mini-table td:last-child,
.mini-table th:last-child {
    text-align: right;
    font-weight: 700;
}

.mini-table small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.link-summary {
    display: grid;
    grid-template-columns: 1fr 1.4fr auto;
    gap: 18px;
    margin-bottom: 18px;
}

.link-summary > div {
    min-width: 0;
}

.recent-table {
    min-width: 760px;
}

/* Eboshi brand theme */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(231, 90, 34, 0.36);
    background:
        linear-gradient(rgba(0, 0, 0, 0.76), rgba(0, 0, 0, 0.88)),
        url('/assets/eboshi-fon3.png') center 18% / 460px auto;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38), 0 0 22px rgba(231, 90, 34, 0.22);
    backdrop-filter: blur(10px);
}

.brand {
    display: grid;
    gap: 0;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1;
    text-transform: uppercase;
}

.brand:hover {
    color: #fff;
    text-decoration: none;
}

.brand span {
    color: var(--accent);
    font-size: 12px;
    letter-spacing: 0.08em;
}

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

.brand small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: none;
}

.nav-link {
    color: rgba(255, 255, 255, 0.86);
    border: 1px solid transparent;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(231, 90, 34, 0.32);
}

.nav-link--active,
.nav-link--active:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 20px rgba(215, 9, 22, 0.28);
}

a {
    color: var(--accent);
}

a:hover {
    color: var(--accent-warm);
}

.page-title {
    color: #fff;
    font-weight: 800;
    text-transform: uppercase;
}

.page-title::after {
    content: '';
    display: block;
    width: 74px;
    height: 3px;
    margin-top: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--accent), rgba(231, 176, 18, 0.95));
    box-shadow: 0 0 18px rgba(231, 90, 34, 0.42);
}

.panel,
.table-wrap,
.metric-tile {
    background:
        linear-gradient(rgba(37, 37, 37, 0.9), rgba(26, 26, 26, 0.92)),
        url('/assets/eboshi-fon3.png') center / 620px auto;
    background-blend-mode: normal, multiply;
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: var(--shadow);
}

.panel {
    backdrop-filter: blur(7px);
}

.panel h1,
.panel h2,
.panel h3,
.section-title,
.analytics-panel h2,
.chart-header h2 {
    color: #fff;
}

.toolbar {
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.34);
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.26);
}

.button,
button {
    border-radius: 5px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #e61c27);
    box-shadow: 0 10px 22px rgba(215, 9, 22, 0.24);
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover,
button:hover {
    color: #fff;
    background: linear-gradient(135deg, #f02d38, var(--accent));
    box-shadow: 0 12px 28px rgba(231, 90, 34, 0.3);
    transform: translateY(-1px);
}

.button--secondary {
    color: rgba(255, 255, 255, 0.88);
    background: rgba(65, 65, 65, 0.86);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: none;
}

.button--secondary:hover {
    color: #fff;
    background: rgba(92, 92, 92, 0.92);
    border-color: rgba(231, 90, 34, 0.56);
}

.button--danger {
    background: linear-gradient(135deg, #b50712, var(--primary));
}

.button--link {
    color: var(--accent);
    box-shadow: none;
}

.button--link:hover {
    color: var(--accent-warm);
    transform: none;
}

.field input[type='text'],
.field input[type='url'],
.field input[type='password'],
.field select,
.result-url,
.chart-range-select,
.range-tab {
    color: #fff;
    background-color: rgba(12, 12, 12, 0.82);
    border-color: rgba(255, 255, 255, 0.18);
}

.field input::placeholder,
.result-url::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

.field input:focus,
.field select:focus,
.result-url:focus,
.chart-range-select:focus {
    border-color: var(--accent);
    outline-color: rgba(231, 90, 34, 0.22);
    box-shadow: 0 0 0 1px rgba(231, 90, 34, 0.18);
}

.chart-range-select {
    background:
        linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.72) 50%) calc(100% - 17px) 14px / 6px 6px no-repeat,
        linear-gradient(135deg, rgba(255, 255, 255, 0.72) 50%, transparent 50%) calc(100% - 12px) 14px / 6px 6px no-repeat,
        rgba(12, 12, 12, 0.82);
}

th {
    color: rgba(255, 255, 255, 0.68);
    background: rgba(0, 0, 0, 0.42);
}

td,
th {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

tbody tr {
    transition: background-color 120ms ease;
}

tbody tr:hover {
    background: rgba(231, 90, 34, 0.06);
}

.short-link {
    color: #fff;
}

.target-preview,
.url-cell a {
    color: rgba(255, 255, 255, 0.78);
}

.chart-total {
    border-color: rgba(231, 90, 34, 0.36);
    background: rgba(0, 0, 0, 0.36);
}

.chart-total strong,
.metric-tile strong {
    color: #fff;
}

.metric-tile {
    border-color: rgba(231, 90, 34, 0.24);
}

.metric-tile strong,
.chart-total strong {
    color: #fff;
}

.metric-value--good {
    color: #72f0a3;
}

.metric-value--bad {
    color: #ff777e;
}

.chart-empty,
.chart-svg-wrap {
    border-color: rgba(255, 255, 255, 0.12);
    background:
        linear-gradient(rgba(0, 0, 0, 0.5), rgba(17, 17, 17, 0.64)),
        url('/assets/eboshi-fon3.png') center / 620px auto;
    background-blend-mode: normal, multiply;
}

.chart-grid {
    stroke: rgba(255, 255, 255, 0.12);
}

.chart-axis {
    stroke: rgba(255, 255, 255, 0.24);
}

.chart-area {
    fill: rgba(231, 90, 34, 0.18);
}

.chart-line {
    stroke: var(--accent);
}

.chart-point {
    fill: #161616;
    stroke: #ff6a2a;
}

.chart-point:hover,
.chart-point:focus {
    fill: var(--primary);
}

.chart-x-label,
.chart-y-label {
    fill: rgba(255, 255, 255, 0.7);
}

.status--active {
    color: #0f2f1c;
    background: #7ee2a4;
}

.status--inactive {
    color: rgba(255, 255, 255, 0.68);
    background: rgba(255, 255, 255, 0.12);
}

.flash {
    background: rgba(0, 0, 0, 0.5);
}

.flash--success {
    color: var(--success-text);
    border-color: rgba(67, 208, 122, 0.34);
}

.flash--error {
    color: var(--error-text);
    border-color: rgba(215, 9, 22, 0.42);
}

.flash--warning {
    color: var(--warning-text);
    border-color: rgba(231, 176, 18, 0.42);
}

.chart-tooltip {
    border-color: rgba(231, 90, 34, 0.56);
    background: rgba(9, 9, 9, 0.96);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42), 0 0 24px rgba(231, 90, 34, 0.2);
}

@media (max-width: 700px) {
    .site-header__inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 0;
    }

    .toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-title {
        font-size: 25px;
    }

    .chart-header {
        flex-direction: column;
    }

    .chart-total {
        width: 100%;
        text-align: left;
    }

    .panel {
        padding: 18px;
    }

    .utm-layout,
    .analytics-grid,
    .link-summary {
        grid-template-columns: 1fr;
    }

    .utm-fields,
    .metric-strip {
        grid-template-columns: 1fr;
    }

    .utm-fields .field:nth-child(3) {
        grid-column: auto;
    }
}
