:root {
    --forest: #124f35;
    --forest-2: #1f754b;
    --leaf: #31a267;
    --mint: #e9f6ef;
    --mint-2: #f5faf7;
    --ink: #17231d;
    --muted: #68786f;
    --line: #dbe7e0;
    --danger: #c53b35;
    --warning: #b46b13;
    --white: #fff;
    --shadow: 0 18px 50px rgba(21, 69, 48, .12);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
    background: #f3f7f5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f3f7f5; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 1.1fr) minmax(360px, .9fr);
    background: var(--white);
}
.login-brand {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(40px, 7vw, 110px);
    color: white;
    background:
        radial-gradient(circle at 75% 18%, rgba(71, 196, 126, .5), transparent 25%),
        linear-gradient(145deg, #0d3d2a, #17643e 58%, #238653);
    position: relative;
    overflow: hidden;
}
.login-brand::after {
    content: "";
    position: absolute;
    width: 440px;
    height: 440px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
    top: -120px;
    right: -150px;
    box-shadow: 0 0 0 80px rgba(255,255,255,.03), 0 0 0 160px rgba(255,255,255,.02);
}
.login-brand p { margin: 22px 0 0; font-size: clamp(22px, 3vw, 38px); max-width: 420px; font-weight: 650; }
.brand-mark {
    width: 106px;
    height: 106px;
    display: grid;
    place-items: center;
    background: white;
    color: var(--forest);
    border-radius: 28px;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -2px;
    box-shadow: 0 20px 45px rgba(0,0,0,.18);
}
.brand-mark.small { width: 46px; height: 46px; border-radius: 13px; font-size: 15px; box-shadow: none; }
.login-card { width: min(430px, calc(100% - 48px)); margin: auto; }
.login-card h1 { font-size: 44px; margin: 8px 0 10px; letter-spacing: -1.5px; }
.muted { color: var(--muted); }
.eyebrow { color: var(--forest-2); font-size: 12px; font-weight: 800; letter-spacing: 1.7px; margin: 0; }
.login-card label { display: grid; gap: 8px; margin-top: 22px; font-size: 14px; font-weight: 700; }
input {
    border: 1px solid #cddbd3;
    border-radius: 12px;
    min-height: 48px;
    padding: 0 14px;
    color: var(--ink);
    background: white;
    outline: none;
}
input:focus { border-color: var(--leaf); box-shadow: 0 0 0 4px rgba(49,162,103,.13); }
.form-error { min-height: 22px; color: var(--danger); font-size: 14px; margin: 14px 0 0; }
.button { min-height: 44px; border: 0; border-radius: 11px; padding: 0 18px; font-weight: 750; }
.button.primary { width: 100%; min-height: 52px; color: white; background: var(--forest-2); }
.button.primary:hover { background: var(--forest); }
.button.secondary { color: var(--forest); background: var(--mint); border: 1px solid #c7e5d4; }
.button.ghost { color: var(--forest); background: transparent; border: 1px solid var(--line); }
.security-note { margin-top: 22px; padding: 14px; border-radius: 12px; background: var(--mint-2); color: var(--muted); font-size: 13px; }
.security-note span { color: var(--leaf); margin-right: 8px; }

.app-view { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { min-height: 100vh; padding: 26px 18px; background: var(--forest); color: white; display: flex; flex-direction: column; }
.brand-lockup { display: flex; align-items: center; gap: 12px; padding: 0 8px 34px; }
.brand-lockup strong, .brand-lockup span { display: block; }
.brand-lockup strong { font-size: 19px; }
.brand-lockup span { color: #a7d8bb; font-size: 13px; }
.sidebar nav { display: grid; gap: 8px; }
.nav-item { border: 0; border-radius: 12px; background: transparent; color: #d8eee1; padding: 13px 14px; text-align: left; display: flex; gap: 12px; align-items: center; font-weight: 700; }
.nav-item.active { background: rgba(255,255,255,.13); color: white; }
.nav-item:disabled { cursor: default; opacity: .6; }
.nav-item small { margin-left: auto; font-weight: 500; }
.readonly-badge { margin-top: auto; color: #c5e3d2; font-size: 12px; padding: 13px; border: 1px solid rgba(255,255,255,.15); border-radius: 12px; }
.readonly-badge span { display: inline-block; width: 8px; height: 8px; background: #62d293; border-radius: 50%; margin-right: 6px; }
.main-content { padding: 30px clamp(22px, 4vw, 58px) 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.topbar h1 { font-size: 32px; letter-spacing: -1px; margin: 5px 0 0; }
.user-menu { display: flex; align-items: center; gap: 14px; }
.user-menu strong, .user-menu span { display: block; text-align: right; }
.user-menu span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.summary-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 19px; box-shadow: 0 8px 25px rgba(34,73,53,.04); }
.summary-card .label { color: var(--muted); font-size: 13px; }
.summary-card strong { display: block; margin-top: 10px; font-size: 27px; letter-spacing: -.6px; }
.summary-card.warning strong { color: var(--warning); }
.summary-card.waiting strong { color: #8a6410; }
.summary-card.danger strong { color: var(--danger); }
.summary-card.historical strong { color: var(--muted); }
.panel { background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.panel-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 6px 0 0; font-size: 23px; }
.panel-actions { display: flex; gap: 10px; }
.search-field { width: min(340px, 38vw); display: flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; padding-left: 13px; background: #fbfdfc; }
.search-field span { color: var(--muted); font-size: 20px; }
.search-field input { width: 100%; min-height: 42px; border: 0; box-shadow: none; background: transparent; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1120px; }
th { padding: 13px 16px; text-align: left; color: var(--muted); background: #f7faf8; font-size: 12px; font-weight: 750; }
td { padding: 15px 16px; border-top: 1px solid #edf2ef; font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: #f8fcfa; }
.store-name strong, .store-name span { display: block; }
.store-name strong { font-size: 14px; }
.store-name span { color: var(--muted); margin-top: 4px; font-size: 12px; }
.status { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 9px; font-size: 11px; font-weight: 800; background: var(--mint); color: var(--forest-2); }
.status::before { content: ""; width: 7px; height: 7px; background: var(--leaf); border-radius: 50%; }
.status.blocked, .status.inactive { color: var(--danger); background: #fff0ee; }
.status.blocked::before, .status.inactive::before { background: var(--danger); }
.status.warning { color: #7b5b12; background: #fff6d8; }
.status.warning::before { background: #d89a14; }
.status.expired { color: var(--danger); background: #fff0ee; }
.status.expired::before { background: var(--danger); }
.status.missing, .status.unknown { color: #66716b; background: #eef2f0; }
.status.missing::before, .status.unknown::before { background: #8a9690; }
.status.waiting_telegram { color: #7b5b12; background: #fff6d8; }
.status.waiting_telegram::before { background: #d89a14; }
.status.processing, .status.pending { color: #225f85; background: #eaf5fb; }
.status.processing::before, .status.pending::before { background: #3d91c5; }
.status.failed { color: var(--danger); background: #fff0ee; }
.status.failed::before { background: var(--danger); }
.status.historical { color: #66716b; background: #eef2f0; }
.status.historical::before { background: #8a9690; }
.version-stack span { display: block; white-space: nowrap; }
.version-stack span + span { color: var(--muted); margin-top: 3px; }
.session-expiry { color: var(--muted); font-size: 12px; margin-top: 3px; }
.version-line { display: grid; gap: 3px; margin: 3px 0; }
.version-line > span { color: inherit; margin: 0; }
.version-badge { border-radius: 999px; display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; width: fit-content; }
.version-badge.success { background: #e4f4e9; color: #176b35; }
.version-badge.warning { background: #fff2cf; color: #8a5a00; }
.version-badge.danger { background: #fde4e1; color: #a92b21; }
.version-badge.neutral { background: #edf0f2; color: #59636b; }
.activity-cell { display: grid; gap: 5px; min-width: 145px; }
.subscription-cell { display: grid; gap: 5px; min-width: 155px; }
.subscription-cell small { color: var(--muted); white-space: nowrap; }
.row-action { border: 0; background: var(--mint); color: var(--forest); width: 34px; height: 34px; border-radius: 9px; font-weight: 900; }
.loading-state, .empty-state { color: var(--muted); text-align: center; padding: 52px 20px; }

.store-dialog { width: min(1100px, calc(100% - 32px)); max-height: calc(100vh - 32px); border: 0; padding: 0; border-radius: 20px; box-shadow: 0 30px 90px rgba(8,40,26,.3); }
.store-dialog::backdrop { background: rgba(8, 30, 21, .58); backdrop-filter: blur(3px); }
.dialog-shell { padding: 24px; min-height: 350px; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 5px 0 3px; font-size: 28px; }
.dialog-header .muted { margin: 0; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 10px; width: 42px; height: 42px; font-size: 27px; color: var(--muted); }
.detail-totals { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; margin: 20px 0; }
.detail-card { border: 1px solid var(--line); border-radius: 13px; padding: 15px; background: var(--mint-2); }
.detail-card span { color: var(--muted); font-size: 12px; }
.detail-card strong { display: block; margin-top: 7px; font-size: 19px; }
.detail-card.waiting strong { color: #8a6410; }
.detail-card.danger strong { color: var(--danger); }
.detail-card.historical strong { color: var(--muted); }
.detail-section { margin-top: 24px; }
.detail-section h3 { font-size: 16px; margin: 0 0 10px; }
.list-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.list-card, .data-row { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; }
.list-card strong, .list-card span { display: block; }
.list-card span { color: var(--muted); margin-top: 5px; font-size: 12px; }
.data-list { display: grid; gap: 7px; }
.data-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 12px; align-items: center; font-size: 13px; }
.data-row span { color: var(--muted); }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 14px 18px; color: white; background: #263b31; border-radius: 12px; box-shadow: var(--shadow); z-index: 10; }

@media (max-width: 1100px) {
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-totals { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 780px) {
    .login-view { display: block; padding: 28px 0; background: linear-gradient(160deg, var(--forest), #e8f5ed 46%); }
    .login-brand { min-height: 210px; padding: 28px; background: transparent; }
    .login-brand p { font-size: 24px; }
    .brand-mark { width: 70px; height: 70px; border-radius: 20px; font-size: 21px; }
    .login-card { background: white; border-radius: 20px; padding: 28px 22px; box-shadow: var(--shadow); }
    .login-card h1 { font-size: 34px; }
    .app-view { display: block; }
    .sidebar { min-height: auto; padding: 14px 18px; flex-direction: row; align-items: center; }
    .brand-lockup { padding: 0; }
    .sidebar nav { display: none; }
    .readonly-badge { margin: 0 0 0 auto; }
    .main-content { padding: 22px 14px 40px; }
    .topbar { align-items: flex-start; }
    .topbar h1 { font-size: 27px; }
    .user-menu div { display: none; }
    .panel-header { align-items: stretch; flex-direction: column; }
    .panel-actions { width: 100%; }
    .search-field { width: 100%; }
    .store-dialog { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
    .dialog-shell { padding: 18px; }
    .list-grid { grid-template-columns: 1fr; }
    .data-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .summary-grid, .detail-totals { grid-template-columns: 1fr; }
    .readonly-badge { display: none; }
    .panel-actions { flex-direction: column; }
    .button.secondary { width: 100%; }
}
