/* =========================================================
   BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

html {
    background:
        var(--tg-theme-bg-color, #090a0d);
}

body {
    min-height: 100vh;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        sans-serif;

    background:
        var(--tg-theme-bg-color, #090a0d);

    color:
        var(--tg-theme-text-color, #f4f4f5);

    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font-family: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.app {
    width: min(720px, calc(100% - 28px));

    margin: 0 auto;

    padding:
        calc(18px + var(--tg-content-safe-area-inset-top, 0px)) 0
        calc(70px + var(--tg-content-safe-area-inset-bottom, 0px));
}


/* =========================================================
   HEADER
   ========================================================= */

.header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-bottom: 34px;
}

.logo {
    font-size: 19px;
    font-weight: 750;

    letter-spacing: -0.3px;
}

.subtitle {
    margin-top: 4px;

    color: #8d9099;

    font-size: 13px;
}

.status-dot {
    width: 10px;
    height: 10px;

    flex: 0 0 auto;

    border-radius: 999px;

    background: #59dc8e;

    box-shadow:
        0 0 8px rgba(89, 220, 142, 0.75),
        0 0 20px rgba(89, 220, 142, 0.3);
}


/* =========================================================
   HERO
   ========================================================= */

.hero {
    display: flex;

    align-items: center;

    gap: 18px;

    margin-bottom: 22px;
}

.hero-icon {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 58px;
    height: 58px;

    flex: 0 0 58px;

    border:
        1px solid rgba(255, 255, 255, 0.04);

    border-radius: 18px;

    background:
        rgba(255, 255, 255, 0.07);

    font-size: 24px;
}

.hero h1 {
    margin: 0;

    font-size: 25px;
    font-weight: 750;

    letter-spacing: -0.6px;
}

.hero p {
    margin:
        7px 0 0;

    color: #9b9da5;

    line-height: 1.5;

    font-size: 14px;
}


/* =========================================================
   GENERIC CARD
   ========================================================= */

.card {
    margin-top: 16px;

    padding: 22px;

    border:
        1px solid rgba(255, 255, 255, 0.085);

    border-radius: 22px;

    background:
        rgba(255, 255, 255, 0.045);

    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.12);

    backdrop-filter: blur(14px);
}

.card h2 {
    margin:
        0 0 20px;

    font-size: 18px;
    font-weight: 700;
}


/* =========================================================
   SUMMARY
   ========================================================= */

.summary {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 10px;

    margin-bottom: 16px;
}

.summary-item {
    display: flex;

    align-items: center;
    justify-content: space-between;

    min-height: 66px;

    padding:
        15px 18px;

    border:
        1px solid rgba(255, 255, 255, 0.075);

    border-radius: 17px;

    background:
        rgba(255, 255, 255, 0.04);
}

.summary-item span {
    color: #8d9099;

    font-size: 13px;
}

.summary-item strong {
    color: #f5f5f6;

    font-size: 23px;
    font-weight: 750;
}


/* =========================================================
   FORMS
   ========================================================= */

label {
    display: block;

    margin:
        0 0 8px;

    color: #aaaeb7;

    font-size: 13px;
}

.text-input,
textarea {
    display: block;

    width: 100%;

    padding:
        14px 15px;

    border:
        1px solid rgba(255, 255, 255, 0.1);

    outline: none;

    border-radius: 14px;

    background: #111217;

    color: #f4f4f5;

    font-size: 14px;

    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

.text-input {
    min-height: 48px;

    margin-bottom: 16px;
}

textarea {
    min-height: 104px;

    margin-bottom: 16px;

    resize: vertical;

    line-height: 1.5;
}

.text-input::placeholder,
textarea::placeholder {
    color: #696c75;
}

.text-input:focus,
textarea:focus {
    border-color:
        rgba(255, 255, 255, 0.27);

    background: #131419;

    box-shadow:
        0 0 0 3px rgba(255, 255, 255, 0.025);
}


/* =========================================================
   PRICE INPUT
   ========================================================= */

.price-input-wrapper {
    position: relative;

    margin-bottom: 0;
}

.price-input-wrapper input {
    padding-right: 46px;
}

.price-input-wrapper > span {
    position: absolute;

    top: 50%;
    right: 16px;

    transform: translateY(-50%);

    color: #8d9099;

    pointer-events: none;
}


/* =========================================================
   BUTTONS
   ========================================================= */

button {
    border: 0;

    cursor: pointer;

    transition:
        transform 0.12s ease,
        opacity 0.12s ease,
        background 0.12s ease;
}

#createButton {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 100%;

    min-height: 48px;

    margin-top: 15px;

    padding:
        13px 18px;

    border-radius: 14px;

    background: #f3f3f4;

    color: #111217;

    font-size: 14px;
    font-weight: 750;
}

#createButton:hover {
    background: #ffffff;
}

button:hover {
    opacity: 0.94;
}

button:active {
    transform: scale(0.985);
}

button:disabled {
    opacity: 0.48;

    cursor: default;

    transform: none;
}


/* =========================================================
   LOADING
   ========================================================= */

.loading {
    display: flex;

    align-items: center;

    gap: 10px;

    margin-top: 16px;

    color: #a9acb4;

    font-size: 13px;
}

.spinner {
    width: 16px;
    height: 16px;

    border:
        2px solid #44464f;

    border-top-color: white;

    border-radius: 50%;

    animation:
        spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   MESSAGES
   ========================================================= */

.hidden {
    display: none !important;
}

.error {
    margin-top: 16px;

    padding:
        13px 14px;

    border:
        1px solid rgba(255, 100, 100, 0.1);

    border-radius: 12px;

    background:
        rgba(255, 80, 80, 0.08);

    color: #ff9494;

    font-size: 13px;

    line-height: 1.45;
}

.success-message {
    margin-top: 16px;

    padding:
        13px 14px;

    border:
        1px solid rgba(89, 220, 142, 0.1);

    border-radius: 12px;

    background:
        rgba(89, 220, 142, 0.07);

    color: #61df94;

    font-size: 13px;
}


/* =========================================================
   OBSERVATIONS SECTION
   ========================================================= */

.observations-section {
    margin-top: 31px;
}

.section-heading {
    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-bottom: 13px;
}

.section-heading h2 {
    margin: 0;

    font-size: 20px;

    letter-spacing: -0.3px;
}

.icon-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    margin: 0;
    padding: 0;

    border:
        1px solid rgba(255, 255, 255, 0.08);

    border-radius: 12px;

    background:
        rgba(255, 255, 255, 0.055);

    color: #e6e6e8;

    font-size: 18px;
}

.icon-button:hover {
    background:
        rgba(255, 255, 255, 0.09);
}

.observations {
    display: grid;

    gap: 14px;
}


/* =========================================================
   OBSERVATION CARD
   ========================================================= */

.observation-card {
    padding: 20px;

    overflow: hidden;

    border:
        1px solid rgba(255, 255, 255, 0.08);

    border-radius: 20px;

    background:
        rgba(255, 255, 255, 0.045);

    box-shadow:
        0 10px 32px rgba(0, 0, 0, 0.1);

    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.observation-card:hover {
    border-color:
        rgba(255, 255, 255, 0.12);

    background:
        rgba(255, 255, 255, 0.052);
}

.observation-header {
    display: flex;

    align-items: flex-start;
    justify-content: space-between;

    gap: 14px;
}

.observation-header h3 {
    margin:
        0 0 7px;

    font-size: 18px;
    font-weight: 700;

    word-break: break-word;
}

.observation-status {
    font-size: 12px;
    font-weight: 650;
}

.observation-status.enabled {
    color: #61df94;
}

.observation-status.disabled {
    color: #848791;
}

.more-button {
    display: flex;

    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;

    flex: 0 0 34px;

    margin: 0;
    padding: 0;

    border:
        1px solid rgba(255, 255, 255, 0.04);

    border-radius: 10px;

    background:
        rgba(255, 255, 255, 0.055);

    color: #a7a9af;

    font-size: 20px;
}

.more-button:hover {
    background:
        rgba(255, 90, 90, 0.1);

    color: #ff9999;
}


/* =========================================================
   OBSERVATION STATS
   ========================================================= */

.observation-stats {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 8px;

    margin-top: 18px;
}

.observation-stats > div {
    min-width: 0;

    padding:
        14px 10px;

    border-radius: 13px;

    background:
        rgba(255, 255, 255, 0.043);

    text-align: center;
}

.observation-stats span {
    display: block;

    margin-bottom: 6px;

    color: #848791;

    font-size: 11px;
}

.observation-stats strong {
    display: block;

    overflow: hidden;

    color: #f4f4f5;

    font-size: 16px;
    font-weight: 720;

    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =========================================================
   THRESHOLD
   ========================================================= */

.threshold-row {
    display: flex;

    align-items: center;
    justify-content: space-between;

    margin-top: 12px;

    padding:
        13px 14px;

    border-radius: 13px;

    background:
        rgba(255, 255, 255, 0.027);

    color: #9497a0;

    font-size: 13px;
}

.threshold-row strong {
    color: #f4f4f5;

    font-size: 14px;
}

.last-check {
    margin-top: 11px;

    color: #737680;

    font-size: 11px;
}


/* =========================================================
   DEAL / ERROR
   ========================================================= */

.deal-badge {
    margin-top: 14px;

    padding:
        10px 12px;

    border:
        1px solid rgba(255, 172, 81, 0.09);

    border-radius: 12px;

    background:
        rgba(255, 161, 65, 0.075);

    color: #ffb466;

    font-size: 12px;
    font-weight: 650;
}

.observation-error {
    margin-top: 12px;

    padding:
        10px 12px;

    border:
        1px solid rgba(255, 90, 90, 0.08);

    border-radius: 12px;

    background:
        rgba(255, 80, 80, 0.065);

    color: #ff9292;

    font-size: 12px;

    line-height: 1.4;
}


/* =========================================================
   CARD ACTIONS
   ========================================================= */

.observation-actions {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 8px;

    margin-top: 16px;
}

.secondary-button {
    min-height: 40px;

    margin: 0;

    padding:
        10px 8px;

    border:
        1px solid rgba(255, 255, 255, 0.045);

    border-radius: 11px;

    background:
        rgba(255, 255, 255, 0.065);

    color: #e4e4e7;

    font-size: 12px;
    font-weight: 600;
}

.secondary-button:hover {
    background:
        rgba(255, 255, 255, 0.1);
}

.page-link {
    display: block;

    margin-top: 15px;

    padding-top: 14px;

    border-top:
        1px solid rgba(255, 255, 255, 0.055);

    color: #989ba4;

    font-size: 12px;

    text-align: center;

    text-decoration: none;
}

.page-link:hover {
    color: #f4f4f5;
}


/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty {
    padding:
        38px 20px;

    border:
        1px dashed rgba(255, 255, 255, 0.095);

    border-radius: 18px;

    background:
        rgba(255, 255, 255, 0.018);

    color: #7e818a;

    text-align: center;

    font-size: 13px;

    line-height: 1.65;
}

.error-inline {
    color: #ff9292;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 560px) {

    .app {
        width:
            min(
                100% - 24px,
                720px
            );

        padding-top: 18px;
    }

    .header {
        margin-bottom: 28px;
    }

    .hero {
        gap: 14px;
    }

    .hero-icon {
        width: 52px;
        height: 52px;

        flex-basis: 52px;

        border-radius: 16px;
    }

    .hero h1 {
        font-size: 21px;
    }

    .hero p {
        font-size: 13px;
    }

    .card {
        padding: 18px;

        border-radius: 19px;
    }

    .summary {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .summary-item {
        padding:
            14px 15px;
    }

    .observation-stats {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

    .observation-actions {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .secondary-button {
        padding:
            9px 4px;

        font-size: 11px;
    }
}


/* =========================================================
   VERY SMALL PHONES
   ========================================================= */

@media (max-width: 390px) {

    .observation-stats {
        grid-template-columns: 1fr;
    }

    .observation-stats > div {
        display: flex;

        align-items: center;
        justify-content: space-between;

        text-align: left;
    }

    .observation-stats span {
        margin: 0;
    }

    .observation-actions {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   TELEGRAM LIGHT THEME
   ========================================================= */

html[data-telegram-theme="light"] .hero-icon,
html[data-telegram-theme="light"] .card,
html[data-telegram-theme="light"] .summary-item,
html[data-telegram-theme="light"] .observation-card {
    border-color: rgba(0, 0, 0, 0.08);
    background:
        var(--tg-theme-secondary-bg-color, #f1f1f1);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.06);
}

html[data-telegram-theme="light"] input,
html[data-telegram-theme="light"] textarea,
html[data-telegram-theme="light"] .observation-stats > div,
html[data-telegram-theme="light"] .threshold-row,
html[data-telegram-theme="light"] .secondary-button,
html[data-telegram-theme="light"] .more-button {
    border-color: rgba(0, 0, 0, 0.07);
    background: rgba(0, 0, 0, 0.045);
    color:
        var(--tg-theme-text-color, #1d1d1f);
}

html[data-telegram-theme="light"] .hero p,
html[data-telegram-theme="light"] .subtitle,
html[data-telegram-theme="light"] .summary-item span,
html[data-telegram-theme="light"] .observation-stats span,
html[data-telegram-theme="light"] .threshold-row,
html[data-telegram-theme="light"] .last-check,
html[data-telegram-theme="light"] .page-link {
    color:
        var(--tg-theme-hint-color, #707579);
}

html[data-telegram-theme="light"] .observation-stats strong,
html[data-telegram-theme="light"] .threshold-row strong,
html[data-telegram-theme="light"] .page-link:hover {
    color:
        var(--tg-theme-text-color, #1d1d1f);
}
