* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: #f3f4f6; color: #111827; }
a { color: #2563eb; text-decoration: none; }
.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1rem; }
.row { display: flex; justify-content: space-between; align-items: center; }
.card { background: #fff; border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1rem; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.form label { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; font-size: .9rem; }
.form label.check { flex-direction: row; align-items: center; gap: .5rem; }
.form { max-width: 480px; }
.form.inline-form { max-width: none; display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.form.inline-form label { margin: 0; }
.form.wide-form { max-width: 1000px; width: 100%; margin: 0 auto 1rem; display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: .75rem 1rem; align-items: center; }
.form.wide-form > label { margin: 0; display: block; }
.form.wide-form > fieldset, .form.wide-form > .form-actions { grid-column: 1 / -1; }
.form.wide-form fieldset { border: 1px solid #d1d5db; border-radius: 6px; margin: 0 0 1rem; padding: .75rem 1rem; }
@media (max-width: 700px) { .form.wide-form { grid-template-columns: 1fr; } }
.component-row { display: flex; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.component-row select { flex: 1; }
.component-row input { width: 8rem; }
input, select { padding: .5rem; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; }
.btn { background: #2563eb; color: #fff; border: 0; border-radius: 6px; padding: .55rem 1rem; cursor: pointer; font: inherit; display: inline-block; }
.btn.small { padding: .25rem .6rem; font-size: .8rem; }
.inline { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid #e5e7eb; }
.num { text-align: right; }
.muted { color: #6b7280; }
.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }
.badge { padding: .15rem .5rem; border-radius: 999px; font-size: .75rem; background: #e5e7eb; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.expired, .badge.disabled { background: #fee2e2; color: #991b1b; }
.badge.upcoming { background: #fef3c7; color: #92400e; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.kpi span { color: #6b7280; font-size: .85rem; display: block; }
.kpi strong { font-size: 1.6rem; display: block; }
.kpi small { color: #6b7280; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1rem; }
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 2rem; background: #eef2f8; }
.auth-shell { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 980px); min-height: 540px; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 24px 60px rgba(20,39,90,.16); }
.auth-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 3rem; background: #14275a; color: #fff; }
.auth-brand-name, .auth-mobile-brand { display: flex; align-items: center; gap: .75rem; font-size: 1.5rem; font-weight: 700; letter-spacing: -.03em; }
.auth-brand-message { margin: auto 0; }
.auth-eyebrow { color: #a7f3d0; font-size: .75rem; font-weight: 700; letter-spacing: .12em; }
.auth-brand-message h1 { margin: 1rem 0; font-size: clamp(2rem, 3.5vw, 2.8rem); line-height: 1.2; letter-spacing: -.035em; }
.auth-brand-message > p:last-child { max-width: 22rem; color: #dbeafe; line-height: 1.6; }
.auth-panel { display: flex; align-items: center; padding: 3rem; }
.auth-panel-content { width: 100%; max-width: 360px; margin: auto; }
.auth-panel h2 { margin: 0; color: #14275a; font-size: 1.9rem; letter-spacing: -.03em; }
.auth-intro { margin: .5rem 0 2rem; color: #6b7280; }
.auth-mobile-brand { display: none; }
.login { display: flex; flex-direction: column; }
.login label { margin-bottom: .4rem; color: #374151; font-size: .9rem; font-weight: 600; }
.login input { width: 100%; margin-bottom: 1.25rem; padding: .8rem; border-radius: 8px; }
.login input:focus-visible, .login button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.login button { width: 100%; margin-top: .5rem; padding: .8rem; border-radius: 8px; font-weight: 600; }
.login button:hover { background: #1d4ed8; }
@media (max-width: 700px) {
    body.auth { padding: 1rem; }
    .auth-shell { grid-template-columns: 1fr; min-height: 0; }
    .auth-brand { padding: 1.5rem; }
    .auth-brand-name { display: none; }
    .auth-brand-message h1 { font-size: 1.6rem; }
    .auth-brand-message > p:last-child { margin-bottom: 0; }
    .auth-panel { padding: 2rem 1.5rem; }
    .auth-mobile-brand { display: flex; margin-bottom: 1.5rem; color: #14275a; }
}
.sales-filters { margin-bottom: 1rem; }
.sales-net-summary { display: flex; align-items: flex-start; justify-content: flex-end; gap: 1rem; margin: .75rem 0; text-align: right; color: #26413e; }
.sales-net-values { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem 1rem; }
.sales-pagination { display: grid; gap: .75rem; margin-top: 1rem; }
.telegram-chat { max-width: 900px; margin: 1rem auto; border: 1px solid #d1d5db; border-radius: 8px; overflow: visible; background: #fff; }
.telegram-chat-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1rem; background: #0f766e; color: #fff; border-radius: 7px 7px 0 0; }
.telegram-chat-header h2 { margin: 0; font-size: 1.1rem; }
.telegram-chat-header span { color: #d1fae5; font-size: .85rem; }
.telegram-settings { position: relative; }
.telegram-settings summary { cursor: pointer; padding: .45rem .7rem; border: 1px solid #99f6e4; border-radius: 6px; }
.telegram-settings-fields { position: absolute; z-index: 2; right: 0; top: 2.4rem; display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; width: min(440px, calc(100vw - 2rem)); padding: 1rem; background: #fff; color: #111827; border: 1px solid #d1d5db; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.14); }
.telegram-settings-fields label, .telegram-composer label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; }
.telegram-messages { display: flex; flex-direction: column; gap: .65rem; height: min(56vh, 500px); min-height: 280px; overflow-y: auto; padding: 1rem; background: #edf3ef; }
.telegram-bubble { max-width: min(78%, 620px); padding: .6rem .8rem; border-radius: 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.telegram-bubble.incoming { align-self: flex-start; background: #fff; }
.telegram-bubble.outgoing { align-self: flex-end; background: #d9fdd3; }
.telegram-composer { display: grid; grid-template-columns: minmax(180px, 240px) minmax(180px, 1fr) auto; align-items: end; gap: .75rem; padding: .9rem 1rem; border-top: 1px solid #e5e7eb; }
.telegram-composer textarea { width: 100%; resize: vertical; padding: .55rem; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; }
.telegram-status { min-height: 1.25rem; padding: 0 1rem; font-size: .85rem; }
@media (max-width: 640px) {
	.telegram-composer { grid-template-columns: 1fr; }
	.telegram-composer .btn { justify-self: end; }
	.telegram-settings-fields { grid-template-columns: 1fr; max-height: 70vh; overflow-y: auto; }
}

.component-row input.unit-price, .component-row input.line-total { width: 8rem; background: #f3f4f6; text-align: right; }
.component-head { font-size: .8rem; font-weight: 600; color: #6b7280; }
.component-head span { flex: 1; }
.component-head span:nth-child(n+2) { flex: 0 0 8rem; }
.component-head span:last-child { flex: 0 0 5rem; }
.bundle-summary { margin: 1rem 0 0 auto; width: auto; min-width: 320px; }

.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: 0 0 236px; background: #14275a; color: #e5e7eb; display: flex; flex-direction: column; padding: 1.25rem 0; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: .65rem; font-size: 1.25rem; font-weight: 700; color: #fff; padding: 0 1.25rem 1.5rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.sidebar nav a, .sidebar .logout button { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; color: #e5e7eb; background: none; border: 0; width: 100%; font: inherit; text-align: left; cursor: pointer; }
.sidebar nav a:hover, .sidebar .logout button:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active { background: #2563eb; color: #fff; border-radius: 8px 0 0 8px; margin-left: .5rem; padding-left: .75rem; }
.sidebar .ico { width: 1.25rem; text-align: center; }
.sidebar .logout { margin: 0; border-top: 1px solid rgba(255,255,255,.15); padding-top: .5rem; }
.main-col { flex: 1; min-width: 0; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 1.25rem; padding: .9rem 1.5rem; }
.topbar .user { display: inline-flex; align-items: center; gap: .6rem; font-weight: 500; }
.account-menu { position: relative; }
.account-menu summary { cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:focus-visible, .account-menu a:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.account-menu-items { position: absolute; z-index: 10; right: 0; top: calc(100% + .5rem); min-width: 180px; padding: .35rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.account-menu-items a { display: block; padding: .65rem .75rem; border-radius: 5px; color: #14275a; }
.account-menu-items a:hover { background: #eff6ff; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; background: #93c5fd; color: #1e3a8a; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.container { max-width: none; margin: 0; padding: 0 1.5rem 1.5rem; }
@media (max-width: 800px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; padding: .75rem 0; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 0 .5rem; }
    .sidebar nav a.active { margin-left: 0; border-radius: 8px; padding-left: 1.25rem; }
}
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.dash-head h1 { margin: 0; font-size: 1.9rem; }
.dash-head p { margin: .25rem 0 0; font-size: 1.05rem; }
.dash-filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { display: flex; align-items: center; gap: 1rem; margin: 0; }
.stat small { color: #4b5563; display: block; }
.stat strong { display: block; font-size: 2rem; line-height: 1.2; }
.stat em, .overview-total em { font-style: normal; font-size: .85rem; display: block; }
em.up { color: #16a34a; } em.down { color: #dc2626; } em.flat { color: #6b7280; }
.stat-icon { width: 3.5rem; height: 3.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex: none; }
.stat-icon.blue { background: #dbeafe; } .stat-icon.green { background: #dcfce7; } .stat-icon.purple { background: #ede9fe; } .stat-icon.orange { background: #ffedd5; }
.dash-row { display: grid; gap: 1rem; margin-bottom: 1rem; }
.dash-row.two-one { grid-template-columns: 3fr 2fr; }
.dash-row .card { margin: 0; }
.dash-row h3 { margin: 0 0 .75rem; }
.overview { display: grid; grid-template-columns: 1fr 180px; gap: 1rem; align-items: center; }
.overview-total { border-left: 1px solid #e5e7eb; padding-left: 1rem; }
.overview-total strong { display: block; font-size: 1.5rem; margin-top: .25rem; }
.chart-box { position: relative; height: 240px; }
.donut-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; align-items: center; }
.chart-box.donut { height: 220px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.legend li { display: grid; grid-template-columns: auto 1fr auto; column-gap: .5rem; align-items: center; }
.legend i { width: .6rem; height: .6rem; border-radius: 50%; }
.legend small { grid-column: 2 / 4; color: #6b7280; }
.pill { padding: .1rem .6rem; border-radius: 999px; font-size: .8rem; }
.pill.bundle { background: #ede9fe; color: #6d28d9; } .pill.item { background: #dcfce7; color: #15803d; }
.sub-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.sub-dates small { color: #4b5563; display: block; } .sub-dates strong { font-size: 1.3rem; }
.progress { height: .6rem; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: #16a34a; }
.right { text-align: right; }
.sub-note { background: #eff6ff; border-radius: 6px; padding: .75rem 1rem; font-size: .9rem; }
@media (max-width: 1000px) { .dash-row.two-one, .overview, .donut-wrap { grid-template-columns: 1fr; } .overview-total { border-left: 0; padding-left: 0; } }

.sub-inline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; margin: .5rem 0 0; }
.sub-inline small { color: #4b5563; margin-right: .25rem; }
.chart-box.tall { height: 260px; }

.nav-group summary { list-style: none; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.25rem; cursor: pointer; color: #e5e7eb; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary:hover { background: rgba(255,255,255,.08); }
.nav-group summary.active-parent { color: #fff; font-weight: 600; }
.nav-group .caret { margin-left: auto; transition: transform .15s; }
.nav-group:not([open]) .caret { transform: rotate(-90deg); }
.sidebar nav a.sub { padding-left: 3.5rem; font-size: .92rem; }
.sidebar nav a.sub.active { padding-left: 3rem; }

.promo-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.promo-card { margin: 0; }
.promo-card h3 { margin: 0; }
.promo-card p { margin: .5rem 0; }
.promo-uses { margin-right: .6rem; font-size: .9rem; }
.promo-actions { display: flex; gap: 1rem; align-items: center; border-top: 1px solid #e5e7eb; padding-top: .6rem; margin-top: .6rem; }
.link-btn { background: none; border: 0; padding: 0; color: #2563eb; cursor: pointer; font: inherit; }
.placeholder { color: #9ca3af; }
.more { position: relative; }
.more summary { cursor: pointer; color: #2563eb; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more-menu { position: absolute; right: 0; bottom: 1.6rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: .5rem .75rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); min-width: 7rem; z-index: 5; }
.more-menu form { margin: 0; }

.form.wide-form .check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .25rem 1rem; max-height: 220px; overflow-y: auto; margin-top: .5rem; }
.form.wide-form fieldset .check { margin-bottom: .25rem; }
[hidden] { display: none !important; }
