*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  :root {
    --red-rgb: 224, 32, 32;
    --red: #E02020;
    --red-dim: #a01818;
    --highlight: rgba(var(--red-rgb), 0.18);
    --bg:            #1C1C1C;
    --bg-deep:       #181513;
    --surface:       #222220;
    --surface-hover: #292927;
    --border:        #2E2E2C;
    --border-light:  #3A3A38;
    --text:          #E8E8E6;
    --text-muted:    #888884;
    --text-faint:    #555552;
    --ok:            #60b060;
    --font-ui:       'Inter', system-ui, sans-serif;
    --font-mono:     'JetBrains Mono', monospace;
    --radius:        6px;
    --radius-lg:     12px;
    --transition:    160ms ease;
    --screen-transition: 420ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  html, body {
    width: 100%;
    height: 100%;
  }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    overflow: hidden;
  }

  #app-frame {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }

  #login-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    z-index: 2;
    animation: fadeUp 500ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 80ms;
    transition: opacity var(--screen-transition), transform var(--screen-transition);
  }

  #login-screen.leaving {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
    pointer-events: none;
  }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  #logo {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1;
    text-align: center;
  }

  #logo .dot {
    color: var(--red);
  }

  .login-sub {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
  }

  #login-form {
    width: 100%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #token-field {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
  }

  #token-field.focused {
    border-color: var(--border-light);
  }

  #token-field.invalid-shake {
    animation: shake 320ms ease;
  }

  @keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
  }

  #token-icon {
    color: var(--text-faint);
    font-size: 12px;
    padding: 0 11px 0 13px;
    pointer-events: none;
    flex-shrink: 0;
    transition: color var(--transition);
  }

  #token-field.focused #token-icon {
    color: var(--text-muted);
  }

  #token-input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 11px 13px 11px 0;
    caret-color: var(--red);
    direction: ltr;
    unicode-bidi: plaintext;
    white-space: nowrap;
    transition: opacity var(--transition);
  }

  #token-input::placeholder {
    color: var(--text-faint);
    font-family: var(--font-ui);
  }

  #token-input:disabled {
    opacity: 0.5;
  }

  #ghost-layer {
    position: absolute;
    left: 39px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    opacity: 0;
    transition: opacity 200ms ease;
  }

  #ghost-layer.visible {
    opacity: 1;
  }

  #token-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--ok);
    height: 15px;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  #token-hint.visible {
    opacity: 1;
    transform: translateY(0);
  }

  #token-hint i {
    font-size: 10px;
  }

  #login-submit {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 10px 0;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: color var(--transition), border-color var(--transition), background var(--transition), transform var(--transition), opacity var(--transition);
  }

  #login-submit.ready:not(:disabled) {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-light);
  }

  #login-submit:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border-light);
    background: var(--surface-hover);
  }

  #login-submit:active:not(:disabled) {
    transform: scale(0.98);
  }

  #login-submit:disabled {
    cursor: default;
    opacity: 0.5;
  }

  #login-submit.checking {
    opacity: 0.85;
  }

  #login-submit i {
    font-size: 12px;
  }

  #error-toast {
    position: absolute;
    bottom: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    max-width: 260px;
    z-index: 700;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  #error-toast.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  #error-toast i {
    color: var(--red);
    font-size: 13px;
    flex-shrink: 0;
  }

  #error-toast span {
    font-size: 12px;
    color: var(--text);
    line-height: 1.4;
  }

  #loading-screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.98);
    transition: opacity var(--screen-transition), transform var(--screen-transition);
  }

  #loading-screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .loader-bars {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 26px;
  }

  .loader-bars span {
    width: 4px;
    height: 8px;
    border-radius: 2px;
    background: var(--border-light);
    animation: bar-bounce 900ms ease-in-out infinite;
  }

  .loader-bars span:nth-child(1) { animation-delay: 0ms;   background: var(--text-faint); }
  .loader-bars span:nth-child(2) { animation-delay: 90ms;  background: var(--text-muted); }
  .loader-bars span:nth-child(3) { animation-delay: 180ms; background: var(--red-dim); }
  .loader-bars span:nth-child(4) { animation-delay: 270ms; background: var(--text-muted); }
  .loader-bars span:nth-child(5) { animation-delay: 360ms; background: var(--text-faint); }

  @keyframes bar-bounce {
    0%, 100% { height: 8px; opacity: 0.65; }
    50%      { height: 26px; opacity: 1; }
  }

  #loading-text {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.01em;
    min-height: 16px;
    text-align: center;
    opacity: 1;
    transition: opacity 200ms ease;
  }

  #loading-text.swap {
    opacity: 0;
  }
/* ---------------------------------------------------------------------
   Расширения для формы логин/пароль (второе поле ввода в том же стиле)
   --------------------------------------------------------------------- */

  .input-field {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
  }

  .input-field.focused {
    border-color: var(--border-light);
  }

  .input-field.invalid-shake {
    animation: shake 320ms ease;
  }

  .input-field i {
    color: var(--text-faint);
    font-size: 12px;
    padding: 0 11px 0 13px;
    pointer-events: none;
    flex-shrink: 0;
    transition: color var(--transition);
  }

  .input-field.focused i {
    color: var(--text-muted);
  }

  .input-field input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 11px 13px 11px 0;
    caret-color: var(--red);
  }

  .input-field input::placeholder {
    color: var(--text-faint);
    font-family: var(--font-ui);
  }

  .input-field input:disabled {
    opacity: 0.5;
  }

  #login-submit {
    margin-top: 4px;
  }

/* ---------------------------------------------------------------------
   Панель токенов (дашборд)
   --------------------------------------------------------------------- */

  #dash-frame {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(10px) scale(0.99);
    animation: fadeUp 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 60ms;
  }

  #topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 26px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  #topbar .brand {
    display: flex;
    align-items: baseline;
    gap: 10px;
  }

  #topbar #logo {
    font-size: 20px;
  }

  #topbar .brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  #topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition), transform var(--transition), opacity var(--transition);
  }

  .btn:hover {
    color: var(--text);
    border-color: var(--border-light);
    background: var(--surface-hover);
  }

  .btn:active {
    transform: scale(0.97);
  }

  .btn.primary {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--border-light);
  }

  .btn.primary:hover {
    border-color: var(--red-dim);
  }

  .btn.danger:hover {
    color: var(--red);
    border-color: var(--red-dim);
  }

  .btn:disabled {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
  }

  #dash-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 22px 26px;
    gap: 18px;
    overflow: hidden;
  }

  #gen-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    flex-shrink: 0;
  }

  .field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .field-group label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .field-group input,
  .field-group select {
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 12.5px;
    padding: 8px 10px;
    outline: none;
    min-width: 120px;
    transition: border-color var(--transition);
  }

  .field-group input:focus,
  .field-group select:focus {
    border-color: var(--border-light);
  }

  .field-group.grow {
    flex: 1;
    min-width: 160px;
  }

  .field-group.grow input {
    width: 100%;
  }

  #custom-toggle {
    font-size: 11.5px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 8px 0;
    transition: color var(--transition);
  }

  #custom-toggle:hover {
    color: var(--text);
  }

  #custom-row {
    display: none;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    width: 100%;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    margin-top: 4px;
  }

  #custom-row.visible {
    display: flex;
  }

  #table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }

  table#token-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
  }

  #token-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface);
    text-align: left;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    z-index: 1;
  }

  #token-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
  }

  #token-table tbody tr:last-child td {
    border-bottom: none;
  }

  #token-table tbody tr:hover {
    background: var(--surface-hover);
  }

  .token-value {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .token-value i {
    color: var(--text-faint);
    font-size: 10.5px;
  }

  .token-value:hover i {
    color: var(--text-muted);
  }

  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 20px;
  }

  .status-pill.active {
    color: var(--ok);
    background: rgba(96, 176, 96, 0.12);
  }

  .status-pill.expired {
    color: var(--text-muted);
    background: rgba(136, 136, 132, 0.14);
  }

  .status-pill.banned {
    color: var(--red);
    background: var(--highlight);
  }

  .row-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
  }

  .icon-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: color var(--transition), border-color var(--transition);
  }

  .icon-btn:hover {
    color: var(--text);
    border-color: var(--border-light);
  }

  .icon-btn.ban-active {
    color: var(--red);
    border-color: var(--red-dim);
  }

  #empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 60px 20px;
    color: var(--text-faint);
    text-align: center;
  }

  #empty-state.visible {
    display: flex;
  }

  #empty-state i {
    font-size: 22px;
    color: var(--text-faint);
  }

  #toast-ok {
    position: absolute;
    bottom: 14px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    max-width: 280px;
    z-index: 700;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 220ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  #toast-ok.visible {
    opacity: 1;
    transform: translateY(0);
  }

  #toast-ok i {
    color: var(--ok);
    font-size: 13px;
  }

  #toast-ok span {
    font-size: 12px;
    color: var(--text);
  }
