:root {
  color-scheme: light;
  --ink: #21312f;
  --muted: #6f817e;
  --line: #dce6e3;
  --paper: #fff;
  --canvas: #f4f8f6;
  --teal: #087e78;
  --teal-dark: #066a65;
  --teal-soft: #e5f3f0;
  --green: #3c9567;
  --amber: #c47a25;
  --red: #b94b46;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1160px) / 2));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand, .login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
}

.brand img, .login-brand img { width: 34px; height: 34px; }
.quiet-link { color: var(--muted); text-decoration: none; }
.quiet-link:hover { color: var(--teal); }

.public-main, .admin-main { width: min(1160px, calc(100% - 48px)); margin: 0 auto; }
.public-main { padding-top: 66px; }

.intro { padding: 4px 0 38px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.1px;
}

.intro h1, .page-title-row h1, .login-view h1 {
  margin: 0;
  color: var(--ink);
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
}

.intro > p, .muted { color: var(--muted); }
.intro > p { margin: 12px 0 0; font-size: 15px; }

.contact-section {
  padding: 24px 26px 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-heading, .manager-head, .page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.section-heading h2, .manager-head h2 { margin: 0; font-size: 18px; }
.section-heading p, .manager-head p { margin: 6px 0 0; color: var(--muted); }
.live-label { color: var(--muted); display: inline-flex; gap: 7px; align-items: center; font-size: 12px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--green); }

.contact-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
.contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 17px 18px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.contact-card:hover { background: #f6fbf9; border-color: #8ac9bb; transform: translateY(-1px); }
.contact-card:focus-visible, .button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #9bd8cc; outline-offset: 2px; }
.platform-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 800;
}
.platform-mark.telegram { color: #32799a; background: #e8f3f7; }
.contact-copy { min-width: 0; flex: 1; }
.contact-copy strong { display: block; font-size: 15px; overflow-wrap: anywhere; }
.contact-copy span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.contact-arrow { color: #8ba19c; font-size: 20px; }

.loading-state, .empty-state { padding: 42px 16px; text-align: center; color: var(--muted); }
.empty-mark { width: 38px; height: 38px; margin: 0 auto 11px; display: grid; place-items: center; border-radius: 50%; color: var(--teal); background: var(--teal-soft); font-size: 22px; }
.empty-state h3 { margin: 0; color: var(--ink); font-size: 15px; }
.empty-state p { margin: 7px 0 0; font-size: 13px; }
.inline-error, .form-error { color: var(--red); font-size: 13px; }
.public-footer { display: flex; justify-content: space-between; gap: 16px; padding: 22px 2px 32px; color: var(--muted); font-size: 12px; }

.admin-main { padding: 40px 0 56px; }
.page-title-row { align-items: flex-end; margin-bottom: 26px; }
.page-title-row .eyebrow { margin-bottom: 8px; }
.page-title-row h1 { font-size: 28px; }
.page-title-row .muted { margin: 7px 0 0; }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.button-primary { color: #fff; background: var(--teal); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button-secondary:hover, .button-quiet:hover { background: #f2f7f5; }
.button-quiet { color: var(--muted); background: transparent; border-color: var(--line); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button-wide { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { min-height: 116px; padding: 17px 19px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 8px; color: var(--ink); font-size: 29px; line-height: 1; font-weight: 700; }
.metric-green { color: var(--green); }
.metric-teal { color: var(--teal); }
.metric-foot { margin-top: 9px; color: #879894; font-size: 11px; }

.selection-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.selection-bar .field { width: min(380px, 100%); }
.selection-bar .button { flex: 0 0 auto; }
.selection-bar select { height: 40px; padding: 0 11px; color: var(--ink); background: #fff; border: 1px solid #d3dfdc; border-radius: 5px; }
.selection-bar select:disabled { color: var(--muted); background: #f5f8f7; cursor: not-allowed; }
.selection-bar .button:disabled { opacity: .55; cursor: not-allowed; }
.counter-note { margin: -10px 2px 17px; color: var(--muted); font-size: 12px; }

.manager-section { background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }
.growth-section { margin-top: 18px; }
.growth-table { min-width: 760px; }
.device-section { margin-top: 18px; }
.device-table { min-width: 680px; }
.device-event-sequence { color: var(--muted); font-size: 11px; white-space: nowrap; }
.plan-label-cell { min-width: 170px; }
.plan-label-cell strong, .plan-label-cell span, .plan-time-cell span { display: block; }
.plan-label-cell strong { color: var(--ink); font-size: 12px; }
.plan-label-cell span, .plan-time-cell span + span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.plan-time-cell { min-width: 148px; white-space: nowrap; }
.state-planned { color: #825d1c; background: #fbf2dc; }
.growth-form {
  margin-top: 18px;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.growth-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; padding: 20px 22px; }
.growth-form .manager-head p { line-height: 1.5; }
.growth-form-actions { background: #fff; }
.growth-form .form-error { margin: 0 22px 16px; }
.workspace-manager { margin-bottom: 22px; }
.manager-head { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.manager-head p { font-size: 12px; }
.table-tools { display: flex; gap: 9px; padding: 15px 20px; }
.search-box { flex: 1; min-width: 0; }
.search-box input, .table-tools select { width: 100%; height: 38px; padding: 0 11px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 5px; }
.table-tools select { width: 160px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { color: var(--muted); background: #f8fbfa; font-size: 11px; }
th { height: 43px; font-weight: 600; }
th, td { padding: 10px 14px; border-bottom: 1px solid #edf2f0; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 21px; }
th:last-child, td:last-child { padding-right: 21px; }
tbody { font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.account-cell { min-width: 150px; }
.workspace-table { min-width: 650px; }
.workspace-name-cell { min-width: 160px; font-weight: 600; }
.workspace-actions { min-width: 205px; }
.workspace-actions button:disabled { color: #a3aeab; cursor: not-allowed; text-decoration: none; }
.workspace-cell { min-width: 110px; color: #526763; }
.account-main { display: flex; gap: 9px; align-items: center; }
.account-main .platform-mark { width: 30px; height: 30px; flex-basis: 30px; border-radius: 8px; font-size: 9px; }
.account-main strong { display: block; color: var(--ink); font-size: 12px; }
.account-main span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.destination-cell { min-width: 170px; max-width: 230px; overflow-wrap: anywhere; color: #526763; }
.short-url-cell { min-width: 190px; }
.short-url { display: block; max-width: 235px; overflow: hidden; color: var(--teal); text-overflow: ellipsis; white-space: nowrap; }
.copy-button, .row-action { padding: 3px 0; border: 0; color: var(--teal); background: transparent; font-size: 11px; }
.copy-button { margin-top: 4px; }
.row-actions { display: flex; gap: 11px; justify-content: flex-end; white-space: nowrap; }
.row-action { color: #60736f; }
.row-action.danger { color: var(--red); }
.row-action:hover, .copy-button:hover { text-decoration: underline; }
.state-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 99px; font-size: 10px; white-space: nowrap; }
.state-pill::before { width: 6px; height: 6px; content: ""; border-radius: 50%; background: currentColor; }
.state-on { color: #29784f; background: #e9f5ed; }
.state-off { color: #7a8582; background: #eef1f0; }
.table-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 42px 15px; color: var(--muted); font-size: 12px; }
.table-empty strong { color: var(--ink); font-size: 14px; }
.manager-foot { display: flex; justify-content: space-between; padding: 11px 21px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.privacy-note { margin: 12px 2px; color: #82918e; font-size: 11px; }

.login-view { width: min(400px, 100%); margin: 45px auto 0; padding: 30px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }
.login-brand { margin-bottom: 27px; font-size: 16px; }
.login-brand img { width: 30px; height: 30px; }
.login-view h1 { font-size: 24px; }
.login-view > .muted { margin: 7px 0 23px; font-size: 13px; }
.login-form { display: grid; gap: 9px; }
.login-form label, .field { color: var(--ink); font-size: 12px; font-weight: 600; }
.login-form input, .field input, .field select { width: 100%; min-width: 0; height: 40px; padding: 0 11px; color: var(--ink); background: #fff; border: 1px solid #d3dfdc; border-radius: 5px; }
.login-form input { margin-bottom: 5px; }
.login-form .form-error { margin: 0 0 4px; }

.dialog { width: min(660px, calc(100% - 28px)); max-width: none; padding: 0; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 20px 70px #172b2733; }
.dialog::backdrop { background: #14252266; }
.dialog form { margin: 0; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 19px 23px; border-bottom: 1px solid var(--line); }
.dialog-head .eyebrow { margin-bottom: 5px; font-size: 9px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 24px; line-height: 1; }
.icon-button:hover { background: #f1f6f4; }
.dialog-body { padding: 22px 23px 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 17px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-full { grid-column: 1 / -1; }
.field-hint { color: var(--muted); font-size: 11px; font-weight: 400; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 13px 23px; background: #fafcfb; border-top: 1px solid var(--line); }
.dialog-body .form-error { margin: 14px 0 0; }
.compact-dialog { width: min(500px, calc(100% - 28px)); }
.access-note { margin: 0 0 18px; font-size: 12px; line-height: 1.6; }
.access-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 17px; }
.access-actions a { text-decoration: none; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; padding: 11px 15px; color: #fff; background: #203b37; border-radius: 5px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .topbar { height: 60px; padding: 0 18px; }
  .public-main, .admin-main { width: calc(100% - 32px); }
  .public-main { padding-top: 42px; }
  .intro { padding-bottom: 26px; }
  .intro h1 { font-size: 29px; }
  .contact-section { padding: 19px 16px; }
  .contact-list { grid-template-columns: 1fr; }
  .admin-main { padding-top: 27px; }
  .page-title-row { align-items: flex-start; }
  .page-title-row h1 { font-size: 24px; }
  .selection-bar { align-items: stretch; flex-wrap: wrap; padding: 12px; }
  .selection-bar .field { flex: 1 1 100%; width: auto; }
  .selection-bar .button { flex: 1 1 auto; }
  .counter-note { margin-top: -8px; line-height: 1.5; }
  .metric-grid { gap: 8px; }
  .metric { min-height: 104px; padding: 13px 11px; }
  .metric-value { font-size: 24px; }
  .metric-foot { font-size: 10px; }
  .manager-head { align-items: flex-start; padding: 17px 15px; }
  .manager-head p { max-width: 360px; line-height: 1.5; }
  .manager-head .button { padding: 0 10px; }
  .table-tools { padding: 12px; flex-wrap: wrap; }
  .table-tools .search-box { flex: 1 0 100%; }
  .table-tools select { width: auto; flex: 1; }
  table { min-width: 820px; }
  .growth-table { min-width: 760px; }
  .growth-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; padding: 17px 15px; }
  .growth-form .form-error { margin: 0 15px 14px; }
  .privacy-note { line-height: 1.6; }
}

@media (max-width: 460px) {
  .brand { font-size: 16px; }
  .brand img { width: 30px; height: 30px; }
  .public-footer { flex-direction: column; gap: 5px; }
  .page-title-row { gap: 10px; }
  .page-title-row .button { min-height: 36px; padding: 0 9px; font-size: 11px; }
  .page-title-row .muted { max-width: 220px; font-size: 12px; line-height: 1.5; }
  .metric-label { font-size: 11px; }
  .metric-foot { line-height: 1.4; }
  .manager-head { flex-direction: column; }
  .manager-head .button { align-self: flex-end; }
  .table-tools { flex-direction: column; }
  .table-tools select { width: 100%; flex: auto; }
  .form-grid { grid-template-columns: 1fr; gap: 15px; }
  .growth-form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .dialog-head, .dialog-body { padding-left: 17px; padding-right: 17px; }
  .dialog-foot { padding-left: 17px; padding-right: 17px; }
}
