/* Личный кабинет. Использует common.css как базу.
   Светлый минимализм — единый язык с лендингом. */

body { background: var(--bg); }

/* ── Auth (login/register) ─────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background:
    radial-gradient(800px 500px at 50% -10%, rgba(165, 200, 255, 0.35), transparent 60%),
    radial-gradient(600px 400px at 80% 90%, rgba(180, 220, 200, 0.25), transparent 60%),
    var(--bg);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 1.6rem;
}

.auth-card h1 { font-size: 1.5rem; margin-bottom: 0.5rem; letter-spacing: -0.025em; }
.auth-card .sub {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 1.6rem;
  line-height: 1.55;
}
.auth-card label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mid);
  margin: 0.9rem 0 0.4rem;
}
.auth-card .submit {
  width: 100%;
  padding: 0.7rem;
  font-size: 14px;
  margin-top: 1.4rem;
  justify-content: center;
}
.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--ink-soft);
  font-size: 13px;
}
.auth-error {
  margin-top: 1rem;
  padding: 0.7rem 0.95rem;
  background: var(--danger-bg);
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ── App layout ────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.4rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { margin-bottom: 2rem; padding: 0 0.4rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.8rem;
  color: var(--ink-mid);
  border-radius: var(--radius-sm);
  margin-bottom: 0.15rem;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none !important;
  transition: all 0.15s;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  justify-content: flex-start;
  text-transform: none;
}
.nav-item:hover {
  background: var(--bg-pill);
  color: var(--ink);
  border-color: transparent;
}
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-hi);
}
.nav-item svg { width: 16px; height: 16px; stroke-width: 1.8; flex-shrink: 0; }

.sidebar-bottom {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.user-chip {
  padding: 0.7rem 0.85rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}
.user-chip .email {
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
  font-weight: 500;
}
.user-chip .bal {
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}

.main {
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    padding: 0.7rem;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar-bottom { display: none; }
  .nav-item { white-space: nowrap; margin-bottom: 0; }
  .main { padding: 1.4rem 1rem; }
}

/* ── Page header ───────────────────────────────────── */
.page-head { margin-bottom: 1.8rem; }
.page-head h1 { font-size: 1.6rem; margin-bottom: 0.4rem; letter-spacing: -0.025em; }
.page-head .desc { color: var(--ink-soft); font-size: 14px; }

/* ── Dashboard tiles ───────────────────────────────── */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (max-width: 720px) { .tiles { grid-template-columns: 1fr; } }

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem;
}
.tile .label {
  color: var(--ink-mute);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin-bottom: 0.6rem;
}
.tile .value {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.tile .value.accent { color: var(--accent); }
.tile .note {
  color: var(--ink-mute);
  font-size: 13px;
  margin-top: 0.4rem;
}

/* ── Tables ────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.table tr:last-child td { border-bottom: 0; }
.table th {
  background: var(--bg-soft);
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.table tr:hover td { background: var(--bg-soft); }
.table .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table-empty {
  padding: 2.5rem;
  text-align: center;
  color: var(--ink-mute);
  font-size: 14px;
}

/* ── Modals ────────────────────────────────────────── */
.modal-host {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}
.modal-host.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.modal .desc { color: var(--ink-soft); font-size: 14px; margin-bottom: 1.2rem; line-height: 1.55; }
.modal .actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Key plaintext display */
.key-display {
  background: var(--bg-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  word-break: break-all;
  margin: 1rem 0;
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  font-size: 11px;
  padding: 0.3rem 0.65rem;
}

/* Topup */
.topup-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}
.topup-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  padding: 0.85rem 0.5rem;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  box-shadow: none;
  text-transform: none;
}
.topup-preset:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: none;
  box-shadow: var(--shadow-sm);
}
.topup-preset.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-hi);
}

/* History prompt preview */
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 0.55rem;
  transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--border-strong); }
.history-meta {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  font-size: 12px;
  color: var(--ink-mute);
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}
.history-meta .model {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}
.history-prompt {
  font-size: 13px;
  color: var(--ink);
  max-height: 4.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
