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

:root {
    --bg: #0a0e17;
    --fg: #e0e0e0;
    --muted: #888;
    --accent: #00d4ff;
    --accent2: #7b2ff7;
    --card: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.08);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    line-height: 1.7;
    min-height: 100vh;
}

.grid-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 18px;
    padding-bottom: 18px;
}
.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.site-nav { display: flex; gap: 24px; }
.site-nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}
.site-nav a:hover { color: var(--accent); }

/* Hero */
.hero {
    padding: 96px 0 72px;
    text-align: center;
}
.eyebrow {
    display: inline-block;
    font-size: 12px;
    letter-spacing: 3px;
    color: var(--accent);
    padding: 6px 14px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 999px;
    margin-bottom: 24px;
}
.hero h1 {
    font-size: clamp(1.8rem, 4.5vw, 2.8rem);
    line-height: 1.3;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero .lead {
    color: #bbb;
    font-size: 1.05rem;
    margin-bottom: 36px;
}
.cta-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
.btn {
    display: inline-block;
    padding: 12px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 212, 255, 0.25);
}
.btn-ghost {
    border: 1px solid var(--border);
    color: var(--fg);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Sections */
.section { padding: 72px 0; }
.section-alt { background: rgba(255, 255, 255, 0.015); }
.section h2 {
    font-size: 1.6rem;
    margin-bottom: 40px;
    text-align: center;
    color: var(--fg);
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    transition: border-color 0.2s, transform 0.2s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-icon { font-size: 32px; margin-bottom: 14px; }
.card h3 { font-size: 1.1rem; margin-bottom: 10px; color: var(--accent); }
.card p { font-size: 14px; color: #bbb; }

/* Steps */
.steps {
    list-style: none;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.steps li {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 24px;
}
.step-num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.step-body { color: #bbb; font-size: 14px; }
.step-body strong { color: var(--fg); font-size: 15px; }

/* FAQ */
.faq { max-width: 720px; margin: 0 auto; }
.faq dt {
    font-weight: 600;
    color: var(--accent);
    margin-top: 22px;
    margin-bottom: 6px;
}
.faq dt:first-child { margin-top: 0; }
.faq dd { color: #bbb; font-size: 14px; margin-left: 18px; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
}
.footer-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.footer-nav a {
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-nav a:hover { color: var(--accent); }
.copy { font-size: 12px; color: #555; }

@media (max-width: 600px) {
    .site-nav { gap: 14px; font-size: 13px; }
    .hero { padding: 64px 0 48px; }
    .section { padding: 56px 0; }
}

/* Auth */
.container-narrow { max-width: 420px; }
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 24px;
}
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-form input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--fg);
    font-size: 14px;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-form button { margin-top: 8px; cursor: pointer; border: none; }
.auth-alt { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-alt a { color: var(--accent); }

/* Nav additions */
.site-nav { align-items: center; }
.nav-user { color: var(--muted); font-size: 13px; }
.inline-form { display: inline; }
.link-button {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 14px;
    padding: 0;
}
.link-button:hover { color: var(--accent); }
.logo { text-decoration: none; }

/* Flash */
.flash-area { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid var(--border);
    background: var(--card);
}
.flash-error { border-color: rgba(255, 90, 90, 0.5); color: #ff8a8a; }
.flash-message { border-color: rgba(110, 255, 176, 0.4); color: #6effb0; }

/* Danger / withdrawal */
.btn-danger {
    background: linear-gradient(135deg, #ff5a5a, #c2185b);
    color: #fff;
    border: none;
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 90, 90, 0.25);
}
.danger-box {
    margin-top: 24px;
    padding: 16px 20px;
    border-radius: 10px;
    background: rgba(255, 90, 90, 0.06);
    border: 1px solid rgba(255, 90, 90, 0.4);
    color: #ff8a8a;
    font-size: 14px;
}
.danger-box ul { margin-top: 8px; padding-left: 20px; }
.danger-box li { margin: 4px 0; }
.danger-box strong { color: #ffb3b3; }

/* Verification banner */
.verify-banner {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    background: rgba(255, 215, 110, 0.08);
    border: 1px solid rgba(255, 215, 110, 0.4);
    color: #ffd76e;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.verify-banner .link-button { color: #ffd76e; text-decoration: underline; }
.verify-banner .link-button:hover { color: var(--accent); }

/* Section subhead */
.section-subhead {
    margin-top: 32px;
    margin-bottom: 12px;
    font-size: 1.05rem;
    color: var(--fg);
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

/* Billing */
.plan-card {
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--border);
}
.status-active { color: #6effb0; }
.status-inactive { color: var(--muted); }

/* Invoices */
.invoice-table-wrap {
    margin-top: 24px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    color: var(--fg);
}
.invoice-table th,
.invoice-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.invoice-table tr:last-child td { border-bottom: none; }
.invoice-table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
}
.invoice-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.invoice-table .mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12px; }
.invoice-table a { color: var(--accent); text-decoration: none; margin-right: 10px; }
.invoice-table a:hover { text-decoration: underline; }
.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11px;
    border: 1px solid var(--border);
    color: var(--muted);
}
.status-pill.status-paid { color: #6effb0; border-color: rgba(110, 255, 176, 0.4); }
.status-pill.status-open { color: #ffd76e; border-color: rgba(255, 215, 110, 0.4); }
.status-pill.status-uncollectible,
.status-pill.status-void { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.4); }

/* Viewer filter */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 24px 0 16px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}
.filter-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}
.filter-form input {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 13px;
}
.filter-form input:focus { outline: none; border-color: var(--accent); }
.filter-actions { display: flex; gap: 8px; }
.filter-form .btn { padding: 8px 16px; font-size: 13px; cursor: pointer; }
.result-count { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

/* Date preset row */
.preset-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -4px 0 14px;
    font-size: 12px;
}
.preset-label { color: var(--muted); margin-right: 4px; }
.btn-pill {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--fg);
    text-decoration: none;
    font-size: 12px;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-pill:hover { border-color: var(--accent); color: var(--accent); }
.btn-pill.is-active {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(123, 47, 247, 0.15));
    border-color: var(--accent);
    color: var(--accent);
}

/* Company-grouped disclosure list */
.company-groups {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 16px;
}
.company-group {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    overflow: hidden;
}
.company-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.015);
}
.company-header h3 {
    margin: 0;
    font-size: 1rem;
    color: var(--fg);
    font-weight: 600;
}
.company-header h3 .mono {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.85rem;
    margin-left: 8px;
}
.company-count {
    color: var(--muted);
    font-size: 12px;
}
.disclosure-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.disclosure-list li {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    transition: background-color 0.12s ease, color 0.12s ease;
}
.disclosure-list li:hover {
    background: rgba(0, 212, 255, 0.28);
    box-shadow: inset 3px 0 0 var(--accent);
}
.disclosure-list li:hover .disclosure-title,
.disclosure-list li:hover .disclosure-date {
    color: #fff;
}
.disclosure-list li:hover .disclosure-link {
    color: #fff;
    text-decoration: underline;
}
.disclosure-title {
    color: var(--fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.doc-title {
    font-size: 1rem;
    color: var(--fg);
    margin-top: 8px;
    line-height: 1.4;
}
.missing-html {
    margin-top: 24px;
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--muted);
}
.disclosure-list li:last-child { border-bottom: none; }
.disclosure-date {
    font-variant-numeric: tabular-nums;
    color: var(--fg);
}
.disclosure-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
}
.disclosure-link:hover { text-decoration: underline; }

/* Search suggest */
.filter-suggest { position: relative; min-width: 240px; }
.suggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 4px 0 0;
    list-style: none;
    padding: 4px 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    max-height: 280px;
    overflow-y: auto;
    z-index: 20;
}
.suggest-dropdown li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--fg);
    display: flex;
    gap: 10px;
    align-items: baseline;
}
.suggest-dropdown li:hover,
.suggest-dropdown li[aria-selected="true"] {
    background: rgba(0, 212, 255, 0.08);
    color: var(--accent);
}
.suggest-dropdown .mono { color: var(--muted); font-size: 12px; }

/* Viewer doc */
.doc-meta { margin-bottom: 24px; }
.back-link-row { margin: 0 0 18px; }
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-color: rgba(0, 212, 255, 0.45);
    background: rgba(0, 212, 255, 0.08);
    color: var(--accent);
}
.back-link:hover {
    border-color: var(--accent);
    background: rgba(0, 212, 255, 0.16);
    color: var(--accent);
}
.back-link .back-link-arrow {
    font-size: 16px;
    line-height: 1;
    transition: transform 0.15s ease;
}
.back-link:hover .back-link-arrow { transform: translateX(-3px); }
.doc-meta-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 6px 16px;
    margin-top: 12px;
    font-size: 13px;
}
.doc-meta-list dt { color: var(--muted); }
.doc-meta-list dd { color: var(--fg); }
.doc-meta-list a,
.missing-html a {
    color: #ffd76e;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}
.doc-meta-list a:hover,
.missing-html a:hover { color: #ffe9a3; }
.doc-frame {
    width: 100%;
    height: 75vh;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

/* Inline document rendering (HTML, not iframe) */
.doc-body {
    color: #222;
    line-height: 1.85;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
}
.doc-body .page,
.doc-body div[id^="page"] {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    padding: 32px 40px;
    margin: 0 0 24px;
}
.doc-body .page > *:first-child,
.doc-body div[id^="page"] > *:first-child { margin-top: 0; }
.doc-body .page > *:last-child,
.doc-body div[id^="page"] > *:last-child { margin-bottom: 0; }
.doc-body h1, .doc-body h2, .doc-body h3, .doc-body h4 {
    font-weight: 600;
    color: #222;
}
.doc-body h1 { font-size: 1.4em; margin: 1.4em 0 .6em; }
.doc-body h2 {
    font-size: 1.2em;
    margin: 1.4em 0 .6em;
    border-bottom: 1px solid #ddd;
    padding-bottom: .2em;
}
.doc-body h3 {
    font-size: 1.1em;
    margin: 1.4em 0 .5em;
    border-left: 3px solid #4a6cf7;
    padding-left: .6em;
}
.doc-body h4 { font-size: 1em; margin: 1.1em 0 .4em; color: #444; }
.doc-body h3.sec {
    font-size: 1.1em;
    margin: 1.8em 0 .6em;
    font-weight: 600;
    color: #222;
    border-left: 3px solid #4a6cf7;
    padding-left: .6em;
}
.doc-body h4.subsec { font-size: 1em; margin: 1.2em 0 .4em; color: #444; }
.doc-body p { margin: .7em 0; color: #222; }
.doc-body p.end-mark {
    text-align: right;
    font-size: .95em;
    color: #555;
    margin-top: 1.8em;
}
.doc-body table { border-collapse: collapse; margin: .7em 0; }
.doc-body th, .doc-body td {
    border: 1px solid #e0e0e0;
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
}
.doc-body th { background: #fafafa; font-weight: 600; }
.doc-body img { max-width: 100%; height: auto; }
.doc-body pre.tabular {
    white-space: pre;
    overflow-x: auto;
    font-family: "SFMono-Regular", "Menlo", "Consolas", "Noto Sans Mono CJK JP", monospace;
    font-size: .88em;
    background: #fafafa;
    border: 1px solid #eee;
    padding: 12px;
    border-radius: 4px;
    line-height: 1.5;
    margin: .7em 0;
    color: #222;
}
.doc-body pre.preserve {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 1em;
    line-height: 1.85;
    background: transparent;
    border: none;
    padding: 0;
    margin: .7em 0;
    color: #222;
}
.doc-body ul.cells {
    list-style: none;
    padding: 0;
    margin: .6em 0;
    column-count: auto;
    column-width: 11em;
    column-gap: 1em;
    font-size: .92em;
    line-height: 1.5;
}
.doc-body ul.cells li {
    padding: 3px 8px;
    border-bottom: 1px solid #f0f0f0;
    break-inside: avoid;
}

/* Color mode: PyMuPDF html output uses absolute positioning inside the
   page div with explicit pt sizes. The children have top/left but no
   `position` declaration — we add it here. Don't add padding to the
   page (would shift coords) and let the inline width/height stand. */
.doc-body--color { overflow-x: auto; }
.doc-body--color div[id^="page"] {
    position: relative;
    padding: 0;
    margin: 0 auto 24px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    background: #fff;
}
.doc-body--color div[id^="page"] > p,
.doc-body--color div[id^="page"] > img {
    position: absolute;
    margin: 0;
}
.doc-body--color div[id^="page"] > img { max-width: none; height: auto; }
.doc-mode-toggle {
    margin-top: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}
.doc-mode-toggle a { color: var(--accent); text-decoration: none; }
.doc-mode-toggle a:hover { text-decoration: underline; }
