/* ============================================================
   KAINŲ MONITORIUS - STYLES (mobile-first)
   ============================================================ */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e4e7eb;
    --text: #141c24;
    --muted: #66717e;
    --primary: #0f766e;
    --primary-text: #ffffff;
    --red: #c2262e;
    --red-bg: #fdeeee;
    --green: #157a3c;
    --green-bg: #e8f6ed;
    --amber: #9a5a06;
    --amber-bg: #fdf3e2;
    --grey-bg: #eef0f3;
    --ours: #0f766e;
    --best: #ea7a12;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141a;
        --surface: #171e26;
        --border: #27313c;
        --text: #e8edf2;
        --muted: #95a1ae;
        --primary: #14b8a6;
        --primary-text: #062a26;
        --red: #f87171;
        --red-bg: #3a1a1c;
        --green: #4ade80;
        --green-bg: #12301f;
        --amber: #fbbf24;
        --amber-bg: #3a2a0d;
        --grey-bg: #222b35;
        --ours: #2dd4bf;
        --best: #fb923c;
        --shadow: none;
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

body {
    padding-bottom: env(safe-area-inset-bottom);
}

h1 {
    font-size: 22px;
    margin: 4px 0 14px;
}

h2 {
    font-size: 17px;
    margin: 0 0 10px;
}

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

code {
    font-size: 0.9em;
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--grey-bg);
}

.hidden {
    display: none !important;
}

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

.small {
    font-size: 13px;
}

.center {
    text-align: center;
}

.pad {
    padding: 16px;
}

.text-red {
    color: var(--red);
}

.error {
    color: var(--red);
    margin: 10px 0 0;
}

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

.between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* ---------- header + menu (viršuje) ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 760px;
    margin: 0 auto;
    padding: 10px 16px 6px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.tabs {
    display: flex;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 8px;
    overflow-x: auto;
}

.tabs a {
    flex: 1;
    padding: 10px 8px 11px;
    text-align: center;
    white-space: nowrap;
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    border-bottom: 3px solid transparent;
}

.tabs a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.container {
    max-width: 760px;
    margin: 0 auto;
    padding: 16px;
}

/* ---------- overview hero ---------- */

.hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius);
    font-size: 19px;
    line-height: 1.3;
}

.hero-sub {
    font-size: 15px;
    font-weight: 400;
}

.hero-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 20px;
    color: #fff;
}

.hero-red {
    background: var(--red-bg);
    color: var(--red);
}

.hero-red .hero-icon {
    background: var(--red);
}

.hero-green,
.hero-ok {
    background: var(--green-bg);
    color: var(--green);
}

.hero-green .hero-icon,
.hero-ok .hero-icon {
    background: var(--green);
}

.updated {
    color: var(--muted);
    font-size: 14px;
    margin: 8px 2px 4px;
}

.section-title {
    margin: 22px 2px 8px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

/* ---------- overview items ---------- */

.items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
}

.item:active {
    background: var(--grey-bg);
}

.item.item-action {
    border-left-color: var(--red);
}

.item.item-opportunity {
    border-left-color: var(--green);
}

.item.item-problem {
    border-left-color: var(--amber);
}

.item-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.item-title {
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-status {
    font-size: 18px;
    font-weight: 700;
}

.item.item-action .item-status {
    color: var(--red);
}

.item.item-opportunity .item-status {
    color: var(--green);
}

.item.item-problem .item-status {
    color: var(--amber);
}

/* veiksmo eilutė kortelėje (span, ne pati kortelė) */
span.item-action {
    font-size: 15px;
    font-weight: 600;
}

.item-meta {
    font-size: 13px;
    color: var(--muted);
}

.chevron {
    font-size: 24px;
    color: var(--muted);
    flex-shrink: 0;
}

.ok-group {
    margin-top: 22px;
}

.ok-group summary {
    padding: 12px 2px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

/* ---------- product summary ---------- */

.summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    margin-bottom: 14px;
    border-radius: var(--radius);
    background: var(--grey-bg);
}

.summary.summary-action {
    background: var(--red-bg);
    color: var(--red);
}

.summary.summary-opportunity,
.summary.summary-ok {
    background: var(--green-bg);
    color: var(--green);
}

.summary.summary-problem {
    background: var(--amber-bg);
    color: var(--amber);
}

.summary-title {
    font-size: 20px;
    font-weight: 700;
}

span.summary-action {
    font-size: 16px;
    font-weight: 600;
}

.summary-meta {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

/* ---------- cards & lists ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}

.card p {
    margin: 6px 0 0;
}

.auth-card {
    max-width: 420px;
    margin: 32px auto;
}

.source-card summary {
    cursor: pointer;
    list-style: none;
}

.source-card summary::-webkit-details-marker {
    display: none;
}

.source-card[open] summary {
    margin-bottom: 10px;
}

.list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.row:last-child {
    border-bottom: 0;
}

a.row:active {
    background: var(--grey-bg);
}

.row-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.row-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.row-sub {
    font-size: 13px;
    color: var(--muted);
}

.row-side {
    text-align: right;
    flex-shrink: 0;
}

/* ---------- pills ---------- */

.pill {
    display: inline-block;
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    background: var(--grey-bg);
    color: var(--muted);
}

.pill-small {
    padding: 1px 7px;
    font-size: 11px;
    vertical-align: middle;
}

.pill-red {
    background: var(--red-bg);
    color: var(--red);
}

.pill-green,
.pill-ok {
    background: var(--green-bg);
    color: var(--green);
}

.pill-amber {
    background: var(--amber-bg);
    color: var(--amber);
}

.pill-grey {
    background: var(--grey-bg);
    color: var(--muted);
}

/* ---------- forms ---------- */

form label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--muted);
}

form h2 {
    margin-top: 6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    font: inherit;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: 0;
    border-color: transparent;
}

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

.switch-row {
    flex-direction: row !important;
    align-items: center;
    gap: 10px !important;
    color: var(--text) !important;
    font-size: 15px !important;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

.more {
    margin: 4px 0 14px;
}

.more summary {
    padding: 8px 0;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
}

.more[open] summary {
    margin-bottom: 8px;
}

.search {
    margin-bottom: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.6;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    padding: 6px 8px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
    margin-top: 4px;
}

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
}

.chip {
    flex-shrink: 0;
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.chip-active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}

.back {
    display: inline-block;
    margin-bottom: 8px;
    text-decoration: none;
    font-weight: 600;
}

/* ---------- rules ---------- */

.rule-row {
    align-items: flex-start;
}

.toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    margin: 0;
    color: var(--text);
}

/* ---------- tables & chart ---------- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border);
}

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

.table .pos {
    width: 28px;
    color: var(--muted);
}

.table .num {
    text-align: right;
    white-space: nowrap;
    font-weight: 600;
}

.row-ours td {
    font-weight: 700;
    color: var(--primary);
    background: var(--green-bg);
}

.chart {
    margin-top: 14px;
}

.chart svg {
    width: 100%;
    height: auto;
    display: block;
}

.chart .grid {
    stroke: var(--border);
    stroke-width: 1;
}

.chart .axis {
    fill: var(--muted);
    font-size: 11px;
}

.chart polyline {
    fill: none;
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

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

.chart .line-best {
    stroke: var(--best);
    stroke-dasharray: 5 4;
}

.legend {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    color: var(--muted);
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}

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

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

/* ---------- schedule (apžvalgos viršuje) ---------- */

.schedule {
    margin: 12px 0 4px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
}

.schedule-row {
    display: flex;
    gap: 12px;
    padding: 3px 0;
}

.schedule-label {
    flex: 0 0 74px;
    color: var(--muted);
    font-size: 13px;
    padding-top: 2px;
}

/* ---------- history / analysis ---------- */

.wrap {
    flex-wrap: wrap;
}

.chips-tight {
    padding-bottom: 6px;
}

.chips-tight .chip {
    padding: 5px 11px;
    font-size: 13px;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 8px 0 12px;
}

@media (min-width: 640px) {
    .tiles {
        grid-template-columns: repeat(4, 1fr);
    }
}

.tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
}

.tile-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
}

.tile-text {
    font-size: 16px;
    overflow-wrap: anywhere;
}

.tile-label {
    font-size: 12px;
    color: var(--muted);
}

.forecast {
    margin: 12px 0 0;
    font-size: 15px;
}

.chart .line-trend {
    stroke: var(--muted);
    stroke-width: 1.5;
    stroke-dasharray: 2 4;
}

.chart .hit {
    fill: transparent;
    cursor: help;
}

.dot-trend {
    background: var(--muted);
}

.events {
    margin: 0;
    padding-left: 18px;
}

.events li {
    margin-bottom: 8px;
}

.analysis-row .row-main {
    flex: 1;
}

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

meter {
    width: 110px;
    height: 10px;
}

.trend {
    font-size: 24px;
    font-weight: 800;
    flex-shrink: 0;
    color: var(--muted);
}

.text-green {
    color: var(--green);
}

/* ---------- other sites ---------- */

.list-flat {
    box-shadow: none;
    margin-bottom: 12px;
}

.link-url {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.link-form {
    margin-top: 4px;
}

/* ---------- toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 20;
    max-width: calc(100% - 32px);
    padding: 11px 16px;
    border-radius: 10px;
    background: var(--text);
    color: var(--bg);
    font-size: 15px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.toast-error {
    background: var(--red);
    color: #fff;
}

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

    .tabs a {
        font-size: 14px;
        padding-left: 4px;
        padding-right: 4px;
    }
}
