:root {
  color-scheme: light;
  --page: #f5f6fa;
  --surface: #fff;
  --ink: #19213a;
  --secondary: #52607a;
  --muted: #66738b;
  --border: #dfe4ee;
  --subtle-border: #e9ecf3;
  --sidebar: #1b2038;
  --accent: #5044d9;
  --accent-hover: #4439c2;
  --accent-bg: #eeecff;
  --focus: #7066ed;
  --radius: 14px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); min-width: 300px; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
svg { display: block; }
.icon { width: 19px; height: 19px; flex: 0 0 19px; }
small { font-size: .8125rem; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.loading { min-height: 100svh; display: grid; place-content: center; color: var(--secondary); padding: 24px; }

.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-align: left; }
.brand strong { display: block; font-size: 1.0625rem; letter-spacing: -.025em; line-height: 1.22; }
.brand small { display: block; margin-top: 5px; color: #c1c5dc; font-size: .75rem; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  position: relative;
  background: linear-gradient(145deg, #8a7cff, #5142df);
  border-radius: 11px;
  box-shadow: inset 0 1px 0 #ffffff35;
}
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 14px;
  transform: skewY(-16deg);
  left: 8px;
  top: 14px;
  border: 1.5px solid #fff;
  border-radius: 2.5px;
}
.brand-mark::after { left: 17px; top: 9px; background: #fff; }

.auth-layout { display: grid; grid-template-columns: minmax(330px, 46%) 1fr; min-height: 100svh; background: var(--surface); }
.auth-visual {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 80% 70%, #463ca1, transparent 60%), linear-gradient(150deg, #22213f, #2e2663);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 630px;
  padding: clamp(24px, 5.4vw, 76px);
}
.auth-visual::after {
  content: "";
  position: absolute;
  inset: 33% 0 0 0;
  z-index: -2;
  background-image: linear-gradient(#ffffff13 1px, transparent 1px), linear-gradient(90deg, #ffffff13 1px, transparent 1px);
  background-size: 33px 33px;
  mask-image: radial-gradient(ellipse at 62% 68%, #000, transparent 78%);
}
.auth-visual .brand { align-self: flex-start; }
.auth-visual h1 { margin: 38px 0 0; font-size: clamp(2.25rem, 4.3vw, 4.5rem); line-height: 1.02; letter-spacing: -.06em; max-width: 10ch; }
.auth-footer { color: #e0dffc; font-size: .875rem; }
.auth-shapes { position: relative; height: 240px; margin: 5px auto 18px; width: min(100%, 390px); }
.shape {
  width: 130px;
  height: 102px;
  border: 1px solid #a59bfd9c;
  background: linear-gradient(150deg, #ffffff30, #9d8fff14);
  position: absolute;
  border-radius: 19px;
  transform: skewY(-13deg);
  box-shadow: 0 19px 33px #14113266, inset 0 1px 0 #ffffff36;
  display: grid;
  place-items: center;
  color: #eeeaff;
}
.shape .icon { width: 33px; height: 33px; transform: skewY(13deg); }
.shape.one { left: 5%; bottom: 18px; }
.shape.two { left: 33%; bottom: 72px; background-color: #7a68ee64; }
.shape.three { left: 62%; bottom: 125px; }
.auth-main { display: grid; place-content: center; padding: 42px 28px; }
.auth-card { width: min(100%, 410px); }
.auth-card h2 { font-size: clamp(1.75rem, 3.2vw, 2.3125rem); letter-spacing: -.045em; line-height: 1.16; }
.auth-card > p { margin: 10px 0 24px; }
.auth-card .fields { margin-top: 26px; }
.auth-card .button.primary { width: 100%; }
.auth-card .button.quiet { width: 100%; margin-top: 8px; }

.layout { display: grid; grid-template-columns: 235px minmax(0, 1fr); min-height: 100svh; }
.sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #d5d8ed;
  padding: 24px 15px 20px;
}
.sidebar .brand { padding: 0 8px 27px; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-separator { height: 1px; margin: 12px 6px; background: #42465a; }
.nav-button {
  color: #d2d7ec;
  background: none;
  text-align: left;
  width: 100%;
  border: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 45px;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: .9375rem;
  font-weight: 550;
  white-space: nowrap;
}
.nav-button:hover { background: #ffffff12; color: #fff; }
.nav-button[aria-current="page"] { background: #403a76; color: #fff; box-shadow: inset 2px 0 0 #a79aff; }
.nav-button[aria-current="page"] .icon { color: #cdc5ff; }
.side-bottom { margin-top: auto; padding: 30px 8px 3px; }
.side-bottom button { color: #cbd0e7; }
.main-layout { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: flex-end; min-height: 68px; border-bottom: 1px solid var(--border); padding: 10px clamp(17px, 3vw, 43px); background: #fff; gap: 12px; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; background: var(--accent-bg); color: #463bb4; font-size: .875rem; font-weight: 750; }
.account-info { min-width: 0; }
.account strong { display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; line-height: 1.3; }
.account small { display: block; color: var(--muted); line-height: 1.3; }
.account-button { border: 0; border-radius: 10px; background: transparent; text-align: left; padding: 3px 5px; color: var(--ink); }
.account-button:hover { background: var(--page); }
.mobile-logout { display: none !important; }

.content { max-width: 1550px; margin: 0 auto; padding: 29px clamp(17px, 3vw, 43px) 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(1.875rem, 3.5vw, 2.375rem); line-height: 1.15; letter-spacing: -.045em; overflow-wrap: anywhere; }
.page-head p { margin-top: 7px; color: var(--secondary); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head .actions { justify-content: flex-end; }
.button {
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 8px 13px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  font-size: .875rem;
  line-height: 1.3;
  font-weight: 650;
  white-space: nowrap;
}
.primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 1px 2px #302ebc27; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { border-color: #d8deeb; }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: #f0f1f8; }
.quiet { color: var(--accent); background: transparent; }
.danger { color: #9d2a37; border-color: #ebc2c7; }
.danger:hover:not(:disabled) { background: #fdf0f1; }
.icon-button { padding: 8px; min-width: 37px; min-height: 37px; border: 1px solid transparent; }
.icon-button:hover { background: #eff0f8; }
.sidebar .icon-button:hover { background: #ffffff16; }

.hero {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  isolation: isolate;
  gap: 20px;
  background: #edebff;
  border: 1px solid #e2ddfc;
  color: #23204b;
  border-radius: var(--radius);
  margin: 0 0 19px;
  padding: 20px 24px;
  min-height: 113px;
}
.hero h2 { font-size: 1.25rem; line-height: 1.23; letter-spacing: -.025em; }
.hero p { margin-top: 5px; color: #544f78; font-size: .9375rem; }
.hero .button { margin-left: auto; }
.hero > div:first-child, .hero .button { z-index: 1; }
.hero-art, .hero-art::before, .hero-art::after { position: absolute; pointer-events: none; }
.hero-art {
  width: 36%;
  height: 240px;
  right: 11%;
  top: -62px;
  opacity: .6;
  background: repeating-linear-gradient(90deg, transparent 0 19px, #bdb2f347 19px 20px),
    repeating-linear-gradient(0deg, transparent 0 19px, #bdb2f347 19px 20px);
  mask-image: radial-gradient(ellipse, #000, transparent 72%);
  transform: skewY(-12deg);
}
.hero-art::before, .hero-art::after { content: ""; width: 76px; height: 56px; background: #b9abff85; border: 1px solid #a99af6; border-radius: 10px; left: 51%; top: 37%; box-shadow: 0 12px 22px #8e7ce542; }
.hero-art::after { left: 40%; top: 51%; background: #d0c7ff; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 23px; }
.stat { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 15px 15px 16px; }
.stat-icon, .empty-icon, .catalog-icon { width: 39px; height: 39px; border-radius: 10px; display: grid; place-items: center; background: #eeecff; color: #5144bd; }
.stat-icon.green { background: #e5f6ee; color: #217455; }
.stat-icon.amber { background: #fbf0dd; color: #815418; }
.stat-icon.blue { background: #e7efff; color: #3659a4; }
.stat-title { display: block; color: var(--secondary); margin: 9px 0 3px; font-size: .875rem; }
.stat-value { display: block; font-size: clamp(1.35rem, 2.55vw, 2rem); font-weight: 720; letter-spacing: -.045em; line-height: 1.12; overflow-wrap: anywhere; }

.panel { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px; }
.panel-head h2 { font-size: 1.0625rem; letter-spacing: -.015em; }
.panel-head p { color: var(--secondary); font-size: .875rem; margin-top: 3px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 2.22fr) minmax(235px, 1fr); align-items: start; gap: 16px; }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
table { border-collapse: collapse; width: 100%; text-align: left; font-size: .875rem; }
thead { background: #f7f8fc; color: var(--secondary); }
th, td { padding: 11px 14px; vertical-align: middle; }
thead th { font-weight: 640; border-block: 1px solid var(--subtle-border); white-space: nowrap; }
td { border-bottom: 1px solid var(--subtle-border); }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 17px; }
th:last-child, td:last-child { padding-right: 17px; }
td .compact-label { min-width: 120px; max-width: 260px; overflow-wrap: anywhere; }
.cell-title { color: var(--ink); font-weight: 650; display: block; }
.cell-detail { display: block; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; font-size: .8125rem; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.no-wrap { white-space: nowrap; }
.tag { display: inline-flex; align-items: center; border-radius: 7px; padding: 3px 8px; background: #eef0f5; color: #515e76; font-size: .8125rem; font-weight: 650; white-space: nowrap; }
.tag.trial, .tag.issued { background: #fff1d7; color: #78501a; }
.tag.active, .tag.paid { background: #e4f5eb; color: #1d6145; }
.tag.expired { background: #ffebed; color: #9d3643; }

.empty { text-align: center; padding: 29px 18px; display: flex; flex-direction: column; align-items: center; }
.empty h3 { margin-top: 11px; font-size: 1rem; }
.empty p { margin: 5px auto 0; color: var(--secondary); max-width: 38ch; font-size: .875rem; }
.empty .button { margin-top: 11px; }
.trial-list { list-style: none; margin: 0; padding: 0 16px 5px; }
.trial-list li { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--subtle-border); }
.trial-date { text-align: center; padding: 4px; background: #f0effc; color: #4c40a6; border-radius: 8px; font-size: .75rem; font-weight: 650; line-height: 1.08; }
.trial-date strong { display: block; font-size: 1.0625rem; line-height: 1.15; }
.trial-date.expired { background: #ffebed; color: #9d3643; }
.trial-text strong, .trial-text small { display: block; overflow-wrap: anywhere; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 13px 16px; }
.filters .search { flex: 1 1 215px; max-width: 390px; }
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; }
.filters select { width: auto; max-width: 100%; font-size: .875rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 17px; }
.tab { background: transparent; border: 0; color: var(--secondary); border-bottom: 2px solid transparent; padding: 8px 13px 11px; font-size: .9375rem; font-weight: 650; }
.tab[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.tab:hover { color: var(--accent); }
.catalog { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.catalog-card { display: flex; flex-direction: column; padding: 16px; gap: 10px; overflow-wrap: anywhere; }
.catalog-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.catalog-card h2 { font-size: 1.125rem; }
.catalog-card p { color: var(--secondary); font-size: .875rem; white-space: pre-wrap; }
.catalog-price { margin-top: auto; color: var(--secondary); font-size: .875rem; }
.catalog-price strong { color: var(--ink); font-size: 1.125rem; }
.client-details { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; padding: 16px; }
.client-details > div { min-width: 150px; overflow-wrap: anywhere; }
.back { margin-bottom: 8px; margin-left: -12px; }
.billing-panel { max-width: 740px; padding: 19px; }
.billing-panel h2 { font-size: 1.15rem; margin-bottom: 12px; }

.fields { display: grid; gap: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 5px; color: var(--ink); font-size: .875rem; font-weight: 620; min-width: 0; }
.field small { font-weight: 400; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #cfd6e6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
  padding: 8px 10px;
}
input::placeholder, textarea::placeholder { color: #697691; opacity: 1; }
input:read-only { background: #f6f7fc; }
select {
  appearance: none;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2352607a' stroke-width='1.6'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  padding-right: 32px;
}
textarea { resize: vertical; min-height: 88px; }
.form-error { background: #fff0f1; color: #8b2530; border: 1px solid #f2cdd1; padding: 8px 11px; border-radius: 8px; font-size: .875rem; margin-top: 3px; overflow-wrap: anywhere; }
.form-error:empty { display: none; }
.form-note { color: var(--secondary); font-size: .875rem; }
.info { background: #f3f1fb; border: 1px solid #e6e0fc; padding: 10px 12px; border-radius: 8px; }
.submit-line { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.submit-line .primary { min-width: 100px; }

dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  width: min(calc(100% - 24px), 500px);
  max-height: calc(100svh - 27px);
  box-shadow: 0 25px 75px #1c254a45;
  overflow: auto;
}
dialog.wide { width: min(calc(100% - 24px), 750px); }
dialog::backdrop { background: #20294264; }
.modal { padding: 20px; }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.375rem; letter-spacing: -.035em; line-height: 1.2; padding-top: 4px; overflow-wrap: anywhere; }
.modal-head .button { margin-top: -4px; margin-right: -5px; }
.modal > p { margin-bottom: 13px; }
.invoice-total-preview { border: 1px solid #e4e0fb; background: #f1efff; border-radius: 9px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.invoice-total-preview strong { font-size: 1.1rem; }
.toast { position: fixed; z-index: 3; right: 19px; bottom: 18px; max-width: calc(100vw - 38px); border-radius: 10px; padding: 12px 15px; background: #262b46; color: #fff; box-shadow: 0 8px 26px #2428483d; overflow-wrap: anywhere; }
.toast.error { background: #8e2836; }

.message-panel { max-width: 920px; }
.message-panel .panel-head > label { max-width: 350px; flex: 1 1 170px; }
.thread { min-height: 160px; max-height: 53vh; overflow-y: auto; padding: 15px; background: #f9f9fd; border-block: 1px solid var(--subtle-border); }
.message { background: white; border: 1px solid var(--border); border-radius: 12px 12px 12px 3px; padding: 8px 11px; margin: 0 auto 10px 0; width: fit-content; max-width: min(82%, 440px); }
.message:last-child { margin-bottom: 0; }
.message.mine { margin-left: auto; margin-right: 0; background: #eeebff; border-color: #e1dbfb; border-radius: 12px 12px 3px 12px; }
.message p { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9375rem; }
.message-meta { font-size: .75rem; color: var(--secondary); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.message-form { display: grid; padding: 14px; gap: 8px; }
.message-form textarea { min-height: 61px; }
.more-messages { margin: 0 auto 13px; display: flex; }

.invoice-paper { padding: 13px; border: 1px solid var(--border); border-radius: 10px; color: #202437; overflow-wrap: anywhere; }
.invoice-paper h3 { margin-bottom: 11px; font-size: 1.25rem; }
.invoice-paper dl { margin: 0 0 14px; display: grid; grid-template-columns: 122px 1fr; gap: 4px 9px; font-size: .875rem; }
.invoice-paper dt { color: var(--secondary); }
.invoice-paper dd { margin: 0; }
.invoice-paper th, .invoice-paper td { padding: 7px; border: 1px solid var(--border); }
.invoice-paper .amount-line { font-size: 1rem; text-align: right; margin-top: 10px; }
.invoice-paper .note { font-size: .875rem; margin-top: 8px; }
.invoice-controls { margin-top: 13px; }
.invoice-controls .tag { margin-right: auto; }

@media (max-width: 1160px) {
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .trial-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .layout { grid-template-columns: 204px minmax(0, 1fr); }
  .stats { gap: 9px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 13px 15px 8px; }
  .sidebar .brand { padding: 0 0 12px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: thin; scrollbar-color: #8583ad transparent; }
  .nav-button { width: auto; flex: 0 0 auto; min-height: 39px; padding: 6px 8px; font-size: .875rem; gap: 6px; }
  .nav-button[aria-current="page"] { box-shadow: inset 0 -2px 0 #a79aff; }
  .nav-button .icon { width: 16px; height: 16px; flex-basis: 16px; }
  .nav-separator, .side-bottom { display: none; }
  .mobile-logout { display: inline-flex !important; }
  .topbar { min-height: auto; padding-block: 5px; }
  .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding-top: 21px; }
}
@media (max-width: 650px) {
  .auth-layout { grid-template-columns: 1fr; min-height: 100svh; grid-template-rows: auto 1fr; }
  .auth-visual { min-height: 0; gap: 0; padding: 20px; }
  .auth-visual h1, .auth-shapes, .auth-footer { display: none; }
  .auth-main { display: flex; justify-content: center; align-items: flex-start; padding: 36px 21px; }
  .page-head { flex-direction: column; margin-bottom: 16px; gap: 10px; }
  .page-head .actions { justify-content: flex-start; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
  .hero { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .hero .button { margin-left: 0; }
  .hero-art { right: 0; width: 72%; }
  .panel-head { padding-inline: 12px; }
  .trial-list { grid-template-columns: minmax(0, 1fr); }
  .catalog { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 400px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 15px; }
  .invoice-paper dl { grid-template-columns: minmax(0, 1fr); }
  .invoice-paper dd { margin-bottom: 4px; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  #app, #toast, .modal-head, .invoice-controls, .form-error { display: none !important; }
  dialog[open] { position: static; width: 100%; max-width: none; max-height: none; margin: 0; box-shadow: none; border: 0; overflow: visible; }
  dialog::backdrop { display: none; background: transparent; }
  .modal, .invoice-paper { border: 0; padding: 0; }
  .invoice-paper { font-size: 11pt; }
  .invoice-paper table { break-inside: avoid; }
}
