:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #15202b;
    --muted: #66717d;
    --line: #dfe5ea;
    --soft: #eef2f5;
    --accent: #0a64c9;
    --accent-dark: #084e9d;
    --good: #16794b;
    --good-bg: #e8f6ef;
    --bad: #a53931;
    --bad-bg: #fdeeed;
    --warn: #8a6200;
    --warn-bg: #fff6d8;
    --error: #a12828;
    --shadow: 0 8px 30px rgba(19, 37, 56, .07);
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

code,
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.page-shell {
    width: min(1500px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 50px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

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

.add-watcher-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: var(--accent);
    font-size: 29px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.add-watcher-button:hover {
    background: var(--accent-dark);
}

.add-watcher-button[aria-expanded="true"] {
    transform: rotate(45deg);
}

.eyebrow {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    color: var(--accent);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -.035em;
}

h2 {
    margin-bottom: 6px;
    font-size: 22px;
    letter-spacing: -.02em;
}

h3 {
    margin-bottom: 5px;
    font-size: 18px;
}

.subtitle,
.section-heading p,
.page-footer,
.stat-card small,
.field small,
.compact-heading p {
    color: var(--muted);
}

.subtitle {
    margin-bottom: 0;
}

.header-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .8);
    font-size: 13px;
    color: var(--muted);
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #8a939d;
}

.dot-good {
    background: var(--good);
}

.dot-bad {
    background: var(--bad);
}

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

.form-panel,
.watcher-panel,
.empty-state,
.danger-panel,
.warning-panel {
    padding: 22px;
}

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

.form-panel[hidden] {
    display: none;
}

.warning-panel,
.danger-panel {
    margin-bottom: 18px;
}

.warning-panel {
    background: var(--warn-bg);
    border-color: #ead69a;
}

.danger-panel {
    background: var(--bad-bg);
    border-color: #efc3bf;
}

.section-heading,
.watcher-title-row,
.title-inline,
.watcher-subline,
.danger-zone {
    display: flex;
    align-items: center;
}

.section-heading,
.watcher-title-row {
    justify-content: space-between;
    gap: 18px;
}

.section-heading p,
.compact-heading p {
    margin-bottom: 0;
    font-size: 14px;
}

.watcher-form {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(340px, 1.7fr) 180px 220px auto;
    gap: 14px;
    align-items: end;
    margin-top: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field > span {
    font-size: 13px;
    font-weight: 700;
}

.field small {
    font-size: 11px;
    line-height: 1.35;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #cbd4dc;
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10, 100, 201, .12);
}

.readonly-input {
    background: #f5f7f9;
    color: #687480;
}

.form-actions {
    display: flex;
    align-items: flex-end;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.button-primary {
    color: #fff;
    background: var(--accent);
}

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

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

.button-secondary:hover {
    background: var(--soft);
}

.button-danger {
    color: var(--bad);
    background: #fff;
    border-color: #e0aaa6;
}

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

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    text-decoration: none;
    background: #fff;
}

.icon-button:hover {
    background: var(--soft);
}

.flash {
    margin-bottom: 18px;
    padding: 12px 15px;
    border-radius: 9px;
    border: 1px solid var(--line);
}

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

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

.watcher-tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0 2px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.watcher-tab {
    flex: 0 0 auto;
    min-width: 190px;
    max-width: 300px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px 10px 4px 4px;
    background: #e9eef2;
    overflow: hidden;
}

.watcher-tab.active {
    background: #fff;
    border-bottom-color: #fff;
    box-shadow: 0 -4px 16px rgba(19, 37, 56, .04);
}

.watcher-tab-main {
    display: block;
    padding: 11px 14px 5px;
    text-decoration: none;
}

.tab-offer-link,
.tab-price {
    display: inline-block;
    margin: 0 14px 10px;
    font-size: 12px;
    font-weight: 800;
}

.tab-offer-link {
    color: var(--good);
    text-decoration: none;
    border-bottom: 1px solid currentColor;
}

.tab-offer-link:hover {
    color: #0f603a;
}

.tab-price {
    color: var(--good);
}

.tab-title,
.tab-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-title {
    font-weight: 750;
}

.tab-meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.watcher-panel {
    border-radius: 4px var(--radius) var(--radius) var(--radius);
}

.title-inline {
    gap: 9px;
}

.title-inline h2 {
    margin: 0;
}

.watcher-subline {
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 9px;
}

.verified-price-link {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 4px 9px;
    border-radius: 999px;
    color: var(--good);
    background: var(--good-bg);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    border: 1px solid #b8dfcc;
}

.verified-price-link:hover {
    background: #dff2e8;
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-good {
    color: var(--good);
    background: var(--good-bg);
}

.status-bad,
.status-error {
    color: var(--bad);
    background: var(--bad-bg);
}

.status-warn {
    color: var(--warn);
    background: var(--warn-bg);
}

.status-neutral {
    color: #58636e;
    background: #edf0f2;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 11px;
    margin-top: 22px;
}

.stat-card {
    min-width: 0;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fbfcfd;
}

.stat-card > span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-bottom: 7px;
    font-size: 20px;
    line-height: 1.15;
}

.stat-card small {
    display: block;
    line-height: 1.35;
}

.inline-error {
    margin-top: 14px;
    padding: 11px 13px;
    border-radius: 9px;
    color: var(--bad);
    background: var(--bad-bg);
}

.chart-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.compact-heading {
    align-items: flex-start;
}

.chart-wrap {
    position: relative;
    height: 330px;
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

#price-chart {
    display: block;
    width: 100%;
    height: 100%;
}

#price-chart[hidden],
.chart-empty[hidden] {
    display: none !important;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: #fafbfc;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.details-grid > div {
    min-width: 0;
    padding: 12px 0;
}

.detail-label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--muted);
}

.detail-value {
    overflow-wrap: anywhere;
    font-weight: 650;
}

.danger-zone {
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    padding-top: 17px;
    border-top: 1px solid var(--line);
}

.empty-state {
    text-align: center;
    padding: 42px 20px;
}

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

.page-footer {
    margin-top: 20px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.55;
}

@media (max-width: 1250px) {
    .watcher-form {
        grid-template-columns: 1fr 1.4fr 160px 200px;
    }

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

    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 850px) {
    .page-shell {
        width: min(100% - 20px, 1500px);
        padding-top: 16px;
    }

    .page-header,
    .section-heading,
    .watcher-title-row,
    .danger-zone {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions {
        align-self: stretch;
        justify-content: space-between;
    }

    .header-state {
        align-self: flex-start;
    }

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

    .form-actions {
        grid-column: auto;
    }

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

    .watcher-actions .button,
    .danger-zone .button {
        width: 100%;
    }

    .danger-zone form {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .form-panel,
    .watcher-panel,
    .empty-state,
    .danger-panel,
    .warning-panel {
        padding: 16px;
    }

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

    .chart-wrap {
        height: 270px;
    }
}

/* v3: Header tools, inline tab price/trend and CallMeBot test */
.header-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.callmebot-test-form {
    margin: 0;
}

.callmebot-test-button {
    padding: 5px 8px;
    border: 1px solid #cbd4dc;
    border-radius: 7px;
    color: var(--muted);
    background: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
    cursor: pointer;
}

.callmebot-test-button:hover {
    color: var(--text);
    background: var(--soft);
}

.watcher-tab-main {
    padding-bottom: 4px;
}

.tab-status-row {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 27px;
    padding: 0 14px 10px;
    white-space: nowrap;
    overflow: hidden;
}

.tab-status-row .tab-meta,
.tab-status-row .tab-offer-link,
.tab-status-row .tab-price {
    display: inline;
    margin: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
}

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

.trend-arrow {
    flex: 0 0 auto;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}

.trend-down {
    color: var(--good) !important;
}

.trend-up {
    color: var(--bad) !important;
}

.trend-flat {
    color: var(--warn) !important;
}

.tab-offer-link.trend-down:hover {
    color: #0f603a !important;
}

.tab-offer-link.trend-up:hover {
    color: #7f2721 !important;
}

.tab-offer-link.trend-flat:hover {
    color: #6c4c00 !important;
}

@media (max-width: 850px) {
    .header-actions {
        align-self: flex-end;
        flex-direction: row;
        justify-content: flex-end;
    }
}
