:root {
  color-scheme: light;
  --bg: #f4f4f3;
  --surface: #ffffff;
  --soft: #f7f7f6;
  --soft-2: #efefed;
  --ink: #171717;
  --muted: #7b7b78;
  --line: #e8e8e5;
  --green: #18b66a;
  --red: #df3b3b;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  padding: 10px 13px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button.secondary,
.icon-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
  font-size: 13px;
}

input:focus,
select:focus {
  border-color: #bdbdb9;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

h4 {
  margin: 18px 0 8px;
  font-size: 13px;
}

p {
  color: var(--muted);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lead {
  max-width: 520px;
  font-size: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}

.auth-shell {
  display: grid;
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  grid-template-columns: minmax(0, 0.85fr) minmax(360px, 1fr);
  gap: 34px;
  align-items: center;
  padding: 44px 0;
}

.auth-copy .brand {
  margin-bottom: 34px;
}

.auth-copy h1 {
  max-width: 620px;
  font-size: clamp(38px, 6vw, 68px);
}

.auth-grid {
  display: grid;
  gap: 14px;
}

.auth-card {
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.05);
}

.auth-card form,
.auth-card {
  display: grid;
  gap: 13px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--surface);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: #fbfbfa;
  padding: 22px 14px;
}

.sidebar-brand {
  padding: 0 4px 8px;
}

.side-search {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  padding: 10px 12px;
  font-size: 13px;
}

.side-search::before {
  content: "⌕";
  margin-right: 8px;
  color: #a5a5a0;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav a,
.sidebar-footer span {
  display: block;
  border-radius: var(--radius);
  color: var(--muted);
  padding: 10px 11px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.side-nav a.active,
.side-nav a:hover {
  background: var(--soft-2);
  color: var(--ink);
}

.sidebar-footer {
  display: grid;
  gap: 4px;
  margin-top: auto;
}

.content-shell {
  min-width: 0;
  background: var(--surface);
  padding: 28px 28px 34px;
}

.content-topbar,
.section-head,
.actions-row,
.inline-form,
.topbar-actions,
.company-strip,
.topup-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content-topbar,
.section-head {
  justify-content: space-between;
}

.content-topbar {
  min-height: 54px;
  margin-bottom: 26px;
}

.content-topbar h1 {
  margin-bottom: 0;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 800;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  padding: 16px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 9px 0 8px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.metric-card small::before {
  content: "▲";
  margin-right: 5px;
  color: var(--green);
  font-size: 9px;
}

.workspace-panel {
  margin-bottom: 18px;
}

.company-switch {
  min-width: min(280px, 100%);
}

.company-strip {
  align-items: stretch;
  margin-top: 16px;
}

.avatar {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 999px;
  background: var(--soft-2);
  font-weight: 900;
}

.company-card {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.company-card strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.company-card p {
  margin: 2px 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.create-company-card,
.wallet-card,
.number-card,
.calls-card {
  display: grid;
  gap: 14px;
}

.wallet-card,
.calls-card {
  grid-column: span 1;
}

.number-card {
  grid-row: span 2;
}

.compact-head p {
  margin-bottom: 0;
  font-size: 13px;
}

.inline-form {
  align-items: flex-end;
}

.inline-form input:first-child {
  max-width: 78px;
}

.topup-row {
  flex-wrap: wrap;
}

.topup-row button {
  flex: 1;
  min-width: 96px;
}

.list {
  display: grid;
  gap: 0;
}

.table-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.item {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 12px 14px;
}

.item:last-child {
  border-bottom: 0;
}

.item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 13px;
}

.item p {
  margin-bottom: 2px;
  font-size: 12px;
}

.item .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.item .row button {
  flex: 0 0 auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  padding: 13px 15px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.16);
}

.toast.error,
.error {
  border-color: var(--red);
  color: #fff;
}

@media (max-width: 1040px) {
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    grid-template-columns: repeat(5, minmax(max-content, 1fr));
    overflow-x: auto;
  }

  .sidebar-footer,
  .side-search {
    display: none;
  }

  .content-shell {
    padding: 22px 16px 30px;
  }

  .content-topbar,
  .section-head,
  .company-strip,
  .actions-row,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .metrics-row {
    grid-template-columns: 1fr;
  }

  .company-card {
    width: 100%;
  }
}
