:root {
  color-scheme: light;
  --paper: #f4f1e9;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #19231f;
  --muted: #6c756f;
  --line: #dcd9cf;
  --accent: #116a51;
  --accent-strong: #0a4f3c;
  --accent-soft: #dceee7;
  --warm: #d96f3c;
  --shadow: 0 24px 70px rgba(30, 45, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(217, 111, 60, 0.13), transparent 28rem),
    radial-gradient(circle at 92% 30%, rgba(17, 106, 81, 0.12), transparent 32rem),
    var(--paper);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(17, 106, 81, 0.26);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 48px;
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child { display: grid; line-height: 1; }
.brand strong { font-size: 1.15rem; letter-spacing: -0.02em; }
.brand small { margin-top: 5px; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; }

.brand-mark { position: relative; display: block; width: 38px; height: 34px; }
.brand-mark i { position: absolute; width: 27px; height: 16px; border: 2px solid var(--ink); border-radius: 5px; background: var(--paper); }
.brand-mark i:nth-child(1) { top: 0; left: 0; }
.brand-mark i:nth-child(2) { top: 8px; left: 5px; }
.brand-mark i:nth-child(3) { top: 16px; left: 10px; background: var(--accent); border-color: var(--accent); }

.header-account { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 0.88rem; }
.page-shell { max-width: 1440px; min-height: calc(100vh - 178px); margin: 0 auto; padding: 32px 48px 72px; }

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.72fr);
  gap: clamp(48px, 8vw, 128px);
  align-items: center;
  min-height: 650px;
}

.auth-intro { max-width: 730px; }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.16em; text-transform: uppercase; }
.auth-intro h1, .content-heading h1 { margin: 0; letter-spacing: -0.055em; line-height: 0.98; }
.auth-intro h1 { max-width: 680px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.2rem, 6.8vw, 6.7rem); font-weight: 500; }
.auth-intro > p:not(.eyebrow) { max-width: 590px; margin: 28px 0 0; color: var(--muted); font-size: 1.12rem; line-height: 1.7; }

.feature-list { display: grid; gap: 14px; margin: 40px 0 0; padding: 0; list-style: none; }
.feature-list li { display: flex; gap: 14px; align-items: center; font-size: 0.9rem; }
.feature-list span { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 0.62rem; }

.auth-card, .account-panel, .content-panel { border: 1px solid rgba(25, 35, 31, 0.1); background: rgba(255, 253, 248, 0.92); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.auth-card { display: grid; gap: 30px; padding: clamp(28px, 5vw, 52px); border-radius: 28px; }
.auth-card h2, .account-panel h2 { margin: 0; font-size: 1.75rem; letter-spacing: -0.035em; }
.muted { color: var(--muted); }
.auth-card .muted { margin: 8px 0 0; line-height: 1.5; }

.social-auth { display: grid; gap: 10px; }
.provider-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 0 16px;
  color: var(--ink);
  background: var(--surface-strong);
  cursor: pointer;
  font-weight: 720;
}
.provider-button:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.provider-button:disabled { cursor: not-allowed; opacity: 0.48; }
.provider-button span { display: grid; width: 28px; height: 28px; margin-right: 10px; place-items: center; border-radius: 9px; color: white; font-size: 0.78rem; font-weight: 820; }
.provider-google span { color: #3157a4; background: #e8efff; }
.provider-yandex span { background: #ef3e36; }
.provider-vk span { background: #447bba; }
.provider-hint { min-height: 1.2em; margin: 2px 0 0; color: var(--muted); font-size: 0.72rem; line-height: 1.4; text-align: center; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; }
.auth-divider::before, .auth-divider::after { height: 1px; flex: 1; background: var(--line); content: ""; }

form { display: grid; gap: 12px; }
label > span, form > label { color: var(--muted); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
input, select {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 15px;
  color: var(--ink);
  background: var(--surface-strong);
}
input::placeholder { color: #9ca39f; }

.button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  cursor: pointer;
  font-weight: 720;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button-primary { color: white; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-strong); }
.button-secondary { border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.button-danger { border: 1px solid #e3b6b2; color: #912f2f; background: #fff0ee; }
.button-danger:hover:not(:disabled) { background: #ffe3e0; }
.button-danger-strong { color: white; background: #a43131; }
.button-danger-strong:hover:not(:disabled) { background: #812323; }
.button-quiet { min-height: 36px; padding: 0 13px; color: var(--muted); background: transparent; }
.button-wide { width: 100%; }
.auth-card .button-primary { margin-top: 6px; }
.code-recipient { margin: 0 0 6px; color: var(--muted); font-size: 0.86rem; }
.form-status { min-height: 1.3em; margin: 0; color: var(--muted); font-size: 0.86rem; }
.form-status[data-tone="error"] { color: #a43131; }
.form-status[data-tone="success"] { color: var(--accent); }

.dashboard { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; align-items: start; }
.account-panel, .content-panel { border-radius: 24px; }
.account-panel { position: sticky; top: 24px; display: grid; min-width: 0; gap: 24px; padding: 28px; }
.account-avatar { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 18px; color: white; background: var(--accent); font-family: Georgia, serif; font-size: 1.8rem; }
.account-panel h2 { overflow-wrap: anywhere; }
.account-panel .muted { margin: 5px 0 0; overflow-wrap: anywhere; font-size: 0.84rem; }
.account-stats { display: grid; gap: 0; margin: 0; border-block: 1px solid var(--line); }
.account-stats div { display: flex; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.account-stats div:last-child { border: 0; }
.account-stats dt { color: var(--muted); }
.account-stats dd { margin: 0; font-weight: 720; text-transform: capitalize; }
.device-section h3 { margin: 0 0 13px; font-size: 0.84rem; }
.device-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.device-list li { display: grid; gap: 3px; font-size: 0.78rem; }
.device-list small { color: var(--muted); }
.account-actions { display: grid; gap: 10px; }

.content-panel { min-width: 0; padding: clamp(24px, 4vw, 42px); }
.content-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.content-heading h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.25rem, 4.5vw, 4.6rem); font-weight: 500; }
.payment-notice { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 26px; border: 1px solid #d8c7a3; border-radius: 16px; padding: 16px 18px; background: #fff6dc; }
.payment-notice strong { font-size: 0.9rem; }
.payment-notice p { margin: 4px 0 0; color: #6e654d; font-size: 0.78rem; line-height: 1.45; }
.payment-notice[data-tone="success"] { border-color: #aad5c4; background: var(--accent-soft); }
.payment-notice[data-tone="error"] { border-color: #e3b6b2; background: #fff0ee; }
.search-bar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(150px, 0.3fr) auto; gap: 12px; align-items: end; margin-top: 34px; }
.search-field, .filter-field { display: grid; gap: 7px; }
.results-meta { display: flex; justify-content: space-between; gap: 20px; margin: 28px 0 12px; font-size: 0.82rem; }
.results-meta p { margin: 0; }

.table-wrap { overflow-x: auto; border-block: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 10px; color: var(--muted); font-size: 0.67rem; letter-spacing: 0.08em; text-align: left; text-transform: uppercase; }
td { padding: 17px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
td:first-child { width: 56%; }
td strong, td small { display: block; }
td strong { max-width: 620px; overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
td small, td time { color: var(--muted); font-size: 0.74rem; }
td small { max-width: 620px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; color: var(--accent-strong); background: var(--accent-soft); font-size: 0.66rem; font-weight: 750; text-transform: capitalize; }
.entity-session { color: #7c482c; background: #f4e3d8; }
.entity-group { color: #55527d; background: #e8e6f5; }
.entity-settings { color: #626a66; background: #e8ebe9; }
.table-action { color: var(--accent); font-size: 0.78rem; font-weight: 750; text-decoration: none; }
.table-action:hover { text-decoration: underline; }
.empty-state { padding: 64px 24px; text-align: center; }
.empty-state p { margin: 8px 0 0; color: var(--muted); }
.load-more { display: block; margin: 22px auto 0; }
.content-panel > .form-status { margin-top: 15px; }

.billing-section { margin-top: 48px; border-top: 1px solid var(--line); padding-top: 38px; }
.billing-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.billing-heading h2 { max-width: 650px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 3vw, 2.8rem); font-weight: 500; letter-spacing: -0.04em; line-height: 1; }
.current-plan { flex: none; border-radius: 999px; padding: 8px 12px; color: var(--accent-strong); background: var(--accent-soft); font-size: 0.7rem; font-weight: 760; text-transform: capitalize; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 26px; }
.plan-card { display: grid; min-width: 0; gap: 22px; border: 1px solid var(--line); border-radius: 18px; padding: 22px; background: var(--surface); }
.plan-card.plan-featured { border-color: rgba(17, 106, 81, 0.45); background: linear-gradient(145deg, var(--accent-soft), var(--surface) 70%); }
.plan-card h3 { margin: 0; font-size: 1.05rem; }
.plan-card div > p { min-height: 2.8em; margin: 7px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.plan-price { display: grid; gap: 4px; margin: 0; }
.plan-price strong { overflow-wrap: anywhere; font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; letter-spacing: -0.04em; }
.plan-price span { color: var(--muted); font-size: 0.72rem; }
.billing-section > .form-status { margin-top: 13px; }

.delete-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
}
.delete-dialog::backdrop { background: rgba(10, 18, 14, 0.58); backdrop-filter: blur(4px); }
.delete-card {
  display: grid;
  gap: 20px;
  border: 1px solid rgba(25, 35, 31, 0.12);
  border-radius: 24px;
  padding: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.delete-card h2 { margin: 0; font-size: 1.8rem; letter-spacing: -0.04em; }
.eyebrow-danger { color: #a43131; }
.delete-warning { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

footer { display: flex; justify-content: space-between; max-width: 1440px; margin: 0 auto; padding: 22px 48px 32px; border-top: 1px solid rgba(25, 35, 31, 0.1); color: var(--muted); font-size: 0.72rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 960px) {
  .site-header, .page-shell, footer { padding-inline: 24px; }
  .auth-layout { grid-template-columns: 1fr; min-height: auto; padding-block: 44px; }
  .auth-intro h1 { font-size: clamp(3.4rem, 12vw, 6rem); }
  .auth-card { max-width: 620px; }
  .dashboard { grid-template-columns: minmax(0, 1fr); }
  .account-panel { position: static; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .account-stats, .device-section, .account-actions { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .site-header { padding-block: 18px; }
  .header-account > span { display: none; }
  .page-shell { padding-top: 10px; }
  .auth-layout { gap: 36px; padding-top: 26px; }
  .auth-intro h1 { font-size: clamp(3rem, 16vw, 4.8rem); }
  .feature-list { display: none; }
  .auth-card { padding: 25px; border-radius: 20px; }
  .account-panel { grid-template-columns: auto minmax(0, 1fr); padding: 22px; }
  .content-panel { padding: 22px 18px; border-radius: 20px; }
  .content-heading { align-items: center; }
  .content-heading h1 { font-size: 2.5rem; }
  .payment-notice, .billing-heading { display: grid; }
  .search-bar { grid-template-columns: 1fr; }
  .results-meta { display: grid; }
  th:nth-child(3), td:nth-child(3) { display: none; }
  td:first-child { width: auto; min-width: 210px; }
  .plan-grid { grid-template-columns: 1fr; }
  .delete-card { padding: 24px; }
  .dialog-actions { display: grid; }
  .dialog-actions .button { width: 100%; }
  footer { display: grid; gap: 6px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #141a17;
    --surface: #1b2420;
    --surface-strong: #202b26;
    --ink: #eef3ef;
    --muted: #a6b0aa;
    --line: #38423d;
    --accent: #5bc39f;
    --accent-strong: #78d5b4;
    --accent-soft: #203f34;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
  }
  .auth-card, .account-panel, .content-panel { background: rgba(27, 36, 32, 0.92); }
  .brand-mark i { background: var(--paper); border-color: var(--ink); }
  .brand-mark i:nth-child(3) { background: var(--accent); border-color: var(--accent); }
  .entity-session { color: #f1b48d; background: #4e3021; }
  .entity-group { color: #c5c2f5; background: #35334f; }
  .entity-settings { color: #c7d0cb; background: #353d39; }
  .payment-notice { border-color: #6b6041; background: #3b3421; }
  .payment-notice p { color: #d6cda8; }
  .payment-notice[data-tone="error"] { border-color: #75413c; background: #3d2523; }
  .button-danger { border-color: #75413c; color: #f3aaaa; background: #3d2523; }
  .button-danger:hover:not(:disabled) { background: #4c2927; }
  .delete-card { border-color: var(--line); background: var(--surface); }
}
