@layer reset, base, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { color-scheme: light; }
  body, h1, h2, h3, p { margin: 0; }
  button, input { font: inherit; }
  [hidden] { display: none !important; }
  button, a { -webkit-tap-highlight-color: transparent; }
}

@layer base {
  :root {
    --paper: #eef7fb;
    --paper-deep: #dcecf4;
    --card: #fbfdfe;
    --ink: #132c42;
    --muted: #60758a;
    --line: #c5d9e4;
    --blue: #006f91;
    --blue-dark: #07526f;
    --cyan: #62c4d1;
    --orange: #ff8a4c;
    --danger: #a13c46;
    --shadow: 0 18px 50px rgb(20 67 91 / 12%);
  }

  body {
    min-width: 320px;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    line-height: 1.5;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: 7px;
    background: linear-gradient(90deg, var(--blue) 0 38%, var(--cyan) 38% 72%, var(--orange) 72%);
    z-index: 20;
  }

  .grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .16;
    background-image: radial-gradient(rgb(19 44 66 / 20%) .45px, transparent .45px);
    background-size: 5px 5px;
    mask-image: linear-gradient(to bottom, black, transparent 80%);
  }

  button, a { color: inherit; }
  button { border: 0; }
  button:focus-visible, a:focus-visible, input:focus-visible {
    outline: 3px solid rgb(0 111 145 / 28%);
    outline-offset: 3px;
  }

  code, .kicker, .header-status, .summary span, .mini-ledger, .account-meta,
  .ticket-spine, .quota-head, .account-actions, .trust-line, .eyebrow {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  }

  h1, h2, h3 {
    font-family: Rockwell, "Roboto Slab", "Courier New", serif;
    line-height: 1.02;
    letter-spacing: -.035em;
  }

  .kicker {
    margin-bottom: 12px;
    color: var(--blue);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
  }
}

@layer components {
  .site-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: 30px 0 18px;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-family: Rockwell, "Roboto Slab", serif;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
  }

  .brand-mark { display: flex; gap: 3px; align-items: end; height: 20px; }
  .brand-mark i { display: block; width: 5px; background: var(--blue); border-radius: 1px; }
  .brand-mark i:nth-child(1) { height: 11px; }
  .brand-mark i:nth-child(2) { height: 20px; background: var(--orange); }
  .brand-mark i:nth-child(3) { height: 15px; background: var(--cyan); }

  .header-status { color: var(--muted); font-size: .73rem; letter-spacing: .04em; }
  .status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #30a46c; box-shadow: 0 0 0 4px rgb(48 164 108 / 12%); }

  main { position: relative; z-index: 1; width: min(1180px, calc(100% - 48px)); margin: 0 auto; }

  .hero {
    display: grid;
    grid-template-columns: 1.5fr .65fr;
    gap: 80px;
    align-items: end;
    padding: 76px 0 55px;
  }

  .hero h1 { max-width: 800px; font-size: clamp(3.6rem, 7.5vw, 7.4rem); font-weight: 700; }
  .hero h1 em { color: var(--blue); font-style: normal; }
  .hero-note { padding: 0 0 12px 24px; border-left: 3px solid var(--orange); color: var(--muted); }
  .hero-note > p { max-width: 33ch; font-size: .94rem; }
  .mini-ledger { display: grid; grid-template-columns: 1fr auto; gap: 5px 20px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; }
  .mini-ledger strong { color: var(--ink); }

  .toolbar { display: flex; justify-content: space-between; gap: 18px; padding: 18px 0; border-block: 1px solid var(--line); }
  .toolbar-left { display: flex; gap: 10px; }
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: rgb(255 255 255 / 54%);
    color: var(--ink);
    font-size: .82rem;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, border-color .18s ease;
  }
  .button:hover { transform: translateY(-1px); border-color: #8eb3c5; background: #fff; }
  .button.primary { border-color: var(--blue); background: var(--blue); color: white; }
  .button.primary:hover { background: var(--blue-dark); }
  .button:disabled { cursor: wait; opacity: .58; transform: none; }
  .button.wide { width: 100%; }
  .text-button { padding: 8px 0; background: transparent; color: var(--muted); font-size: .82rem; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

  .summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr) 1.7fr;
    margin: 28px 0 78px;
    background: var(--ink);
    color: white;
    box-shadow: var(--shadow);
  }
  .summary > div { min-height: 112px; padding: 23px 26px; border-right: 1px solid rgb(255 255 255 / 14%); }
  .summary > div:last-child { border: 0; }
  .summary span { display: block; margin-bottom: 12px; color: #a9c2d2; font-size: .65rem; letter-spacing: .1em; text-transform: uppercase; }
  .summary strong { display: block; overflow: hidden; font-family: Rockwell, serif; font-size: 2rem; font-weight: 700; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  .summary-wide strong { padding-top: 6px; font-family: ui-monospace, monospace; font-size: .9rem; font-weight: 500; }

  .section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 24px; }
  .section-heading h2 { font-size: clamp(2rem, 4vw, 3.2rem); }
  .section-heading > p { color: var(--muted); font-size: .75rem; }

  .account-grid { display: grid; gap: 18px; }
  .account-card {
    --used: 0%;
    position: relative;
    display: grid;
    grid-template-columns: 112px minmax(230px, .9fr) 1.5fr auto;
    min-height: 220px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--card);
    box-shadow: 0 8px 30px rgb(27 75 98 / 7%);
    animation: slide-in .35s ease both;
  }
  .account-card::after {
    content: "";
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--paper);
    box-shadow: 0 0 0 1px var(--line);
  }
  .ticket-spine {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 25px 19px;
    background: var(--blue);
    color: white;
    font-size: .66rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
  }
  .ticket-spine strong { color: #9de2ea; font-weight: 800; }
  .account-identity { align-self: stretch; padding: 27px 26px; border-right: 1px dashed var(--line); }
  .eyebrow { color: var(--blue); font-size: .65rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
  .account-identity h3 { margin: 13px 0 7px; overflow-wrap: anywhere; font-size: clamp(1.35rem, 2.5vw, 2.05rem); }
  .account-email { overflow: hidden; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
  .account-meta { margin-top: 28px; color: var(--muted); font-size: .63rem; text-transform: uppercase; letter-spacing: .06em; }

  .quota-list { display: grid; align-content: center; gap: 25px; padding: 28px 34px; }
  .quota-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 9px; font-size: .69rem; letter-spacing: .04em; text-transform: uppercase; }
  .quota-head span { color: var(--muted); }
  .quota-head strong { color: var(--ink); }
  .quota-track { height: 11px; overflow: hidden; border-radius: 1px; background: var(--paper-deep); }
  .quota-track i { display: block; width: var(--fill); height: 100%; background: var(--cyan); transition: width .55s cubic-bezier(.2,.75,.25,1); }
  .quota.is-hot .quota-track i { background: var(--orange); }
  .reset-line { margin-top: 7px; color: var(--muted); font-size: .72rem; }
  .quota-empty { padding: 14px 0; color: var(--muted); font-size: .84rem; }

  .account-actions { display: flex; flex-direction: column; justify-content: center; min-width: 148px; padding: 24px; border-left: 1px solid var(--line); }
  .account-actions button { padding: 9px 0; background: transparent; color: var(--blue); font-size: .67rem; font-weight: 800; text-align: left; text-transform: uppercase; letter-spacing: .06em; cursor: pointer; }
  .account-actions button:hover { color: var(--ink); }
  .account-actions .danger { margin-top: 13px; padding-top: 15px; border-top: 1px solid var(--line); color: var(--danger); }
  .account-actions button:disabled { color: var(--muted); cursor: wait; }
  .error-note { color: var(--danger); font-size: .75rem; }

  .empty-state { padding: 80px 20px 120px; border: 1px dashed #9ebbc9; text-align: center; }
  .empty-state h2 { margin: 18px 0 8px; font-size: 2rem; }
  .empty-state p { margin-bottom: 24px; color: var(--muted); }
  .empty-rack { display: flex; justify-content: center; align-items: end; gap: 6px; height: 48px; }
  .empty-rack i { width: 11px; height: 30px; background: var(--cyan); }
  .empty-rack i:nth-child(2) { height: 47px; background: var(--blue); }
  .empty-rack i:nth-child(3) { height: 38px; background: var(--orange); }

  .not-found { display: grid; align-content: center; min-height: 100vh; }
  .not-found h1 { margin-bottom: 20px; font-size: clamp(3.5rem, 10vw, 7rem); }
  .not-found > p:not(.kicker) { max-width: 45ch; margin-bottom: 26px; color: var(--muted); }
  .not-found .button { justify-self: start; }

  footer { position: relative; z-index: 1; display: flex; justify-content: space-between; width: min(1180px, calc(100% - 48px)); margin: 100px auto 0; padding: 26px 0 42px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
  footer > span { color: var(--ink); font-family: Rockwell, serif; font-weight: 700; }

  .gate {
    position: fixed;
    z-index: 30;
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 35px 20px;
    background: var(--ink);
  }
  .gate::before { content: ""; position: absolute; inset: 7px 0 0 52%; background: var(--paper); clip-path: polygon(26% 0, 100% 0, 100% 100%, 0 100%); }
  .gate-card { position: relative; width: min(100%, 480px); padding: 45px; border-top: 6px solid var(--orange); background: var(--card); box-shadow: 0 30px 80px rgb(0 0 0 / 30%); }
  .gate-card h1 { margin-bottom: 20px; font-size: clamp(2.5rem, 7vw, 4.15rem); }
  .gate-copy { margin-bottom: 27px; color: var(--muted); }
  label:not(.drop-zone) { display: block; margin: 14px 0 7px; color: var(--ink); font-size: .74rem; font-weight: 750; }
  input[type="password"] { width: 100%; height: 47px; padding: 0 13px; border: 1px solid var(--line); border-radius: 3px; background: white; }
  .form-error { min-height: 22px; padding: 7px 0; color: var(--danger); font-size: .74rem; }
  .trust-line { margin-top: 24px; color: var(--muted); font-size: .61rem; line-height: 1.4; text-transform: uppercase; letter-spacing: .04em; }
  .trust-line span { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #30a46c; }

  dialog { width: min(630px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 0; overflow-y: auto; border: 0; border-top: 6px solid var(--orange); border-radius: 4px; background: var(--card); color: var(--ink); box-shadow: 0 30px 90px rgb(7 40 59 / 38%); }
  dialog::backdrop { background: rgb(7 34 51 / 68%); backdrop-filter: blur(6px); }
  .dialog-head { display: flex; align-items: start; justify-content: space-between; padding: 30px 34px 24px; border-bottom: 1px solid var(--line); }
  .dialog-head h2 { font-size: 2.2rem; }
  .close-button { padding: 0 4px; background: transparent; color: var(--muted); font-size: 2rem; line-height: 1; cursor: pointer; }
  dialog section { padding: 28px 34px; }
  .method-title { display: flex; gap: 17px; align-items: start; margin-bottom: 20px; }
  .method-title > span { display: grid; place-items: center; flex: 0 0 35px; height: 35px; border-radius: 50%; background: var(--paper-deep); color: var(--blue); font: 800 .68rem ui-monospace, monospace; }
  .method-title h3 { margin-bottom: 4px; font-size: 1.22rem; }
  .method-title p { color: var(--muted); font-size: .78rem; }
  .or { position: relative; height: 1px; margin: 0 34px; background: var(--line); text-align: center; }
  .or span { position: relative; top: -11px; padding: 0 10px; background: var(--card); color: var(--muted); font-size: .7rem; }
  .drop-zone { display: grid; place-items: center; min-height: 112px; padding: 20px; border: 1px dashed #87aebe; border-radius: 3px; background: var(--paper); text-align: center; cursor: pointer; }
  .drop-zone:hover, .drop-zone.is-over { border-color: var(--blue); background: #e5f4f8; }
  .drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
  .drop-zone strong { color: var(--blue); font-size: .86rem; }
  .drop-zone span { color: var(--muted); font-size: .7rem; }
  .device-code > p { margin-bottom: 10px; color: var(--muted); font-size: .78rem; }
  .device-code > button { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 12px; padding: 15px 17px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; }
  .device-code > button strong { font: 800 1.5rem ui-monospace, monospace; letter-spacing: .12em; }
  .device-code > button span { color: var(--blue); font-size: .72rem; font-weight: 700; }
  .waiting { display: flex; gap: 10px; align-items: center; margin-top: 16px; color: var(--muted); font-size: .75rem; }
  .waiting span { width: 9px; height: 9px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }

  .toast { position: fixed; z-index: 60; right: 22px; bottom: 22px; max-width: min(390px, calc(100% - 44px)); padding: 13px 17px; border-left: 4px solid var(--cyan); border-radius: 3px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: .78rem; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; }
  .toast.show { opacity: 1; transform: translateY(0); }
  .toast.error { border-color: var(--orange); }

  @keyframes spin { to { transform: rotate(1turn); } }
  @keyframes slide-in { from { opacity: 0; transform: translateY(10px); } }
}

@layer responsive {
  @media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; gap: 35px; }
    .hero-note { max-width: 480px; }
    .summary { grid-template-columns: repeat(3, 1fr); }
    .summary-wide { grid-column: 1 / -1; }
    .account-card { grid-template-columns: 74px 1fr auto; }
    .account-identity { border: 0; }
    .quota-list { grid-column: 2 / -1; padding-top: 0; }
    .account-actions { grid-column: 3; grid-row: 1; }
  }

  @media (max-width: 650px) {
    .site-header, main, footer { width: min(100% - 28px, 1180px); }
    .header-status { display: none; }
    .hero { padding: 55px 0 40px; }
    .hero h1 { font-size: clamp(3rem, 15vw, 4.7rem); }
    .toolbar, .toolbar-left { align-items: stretch; flex-direction: column; }
    .toolbar .text-button { align-self: start; }
    .summary { grid-template-columns: 1fr 1fr; margin-bottom: 60px; }
    .summary > div { min-height: 94px; padding: 19px; }
    .summary > div:nth-child(2) { border-right: 0; }
    .summary > div:nth-child(3) { border-top: 1px solid rgb(255 255 255 / 14%); }
    .summary strong { font-size: 1.65rem; }
    .summary-wide { grid-column: auto; border-top: 1px solid rgb(255 255 255 / 14%); }
    .summary-wide strong { white-space: normal; }
    .section-heading > p { display: none; }
    .account-card { grid-template-columns: 48px 1fr; }
    .ticket-spine { padding: 19px 13px; }
    .account-identity { padding: 23px 20px; }
    .account-meta { margin-top: 18px; }
    .quota-list { grid-column: 2; padding: 5px 20px 25px; }
    .account-actions { grid-column: 2; grid-row: auto; flex-flow: row wrap; justify-content: start; gap: 0 18px; padding: 14px 20px 20px; border-top: 1px solid var(--line); border-left: 0; }
    .account-actions .danger { margin: 0; padding-top: 9px; border: 0; }
    footer { display: block; margin-top: 70px; }
    footer p { margin-top: 7px; }
    .gate::before { display: none; }
    .gate-card { padding: 32px 24px; }
    .dialog-head, dialog section { padding-inline: 22px; }
    .or { margin-inline: 22px; }
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  }
}
