:root {
  color-scheme: light;
  --bg: #f2f2f2; --surface: #fff; --text: #444; --muted: #707070; --border: #d8d8d8;
  --primary: #f08320; --primary-dark: #9a470b; --primary-soft: #fff3e5; --on-primary: #30251b;
  --accent: #5b5857; --sidebar: #2e3030; --success: #237a44; --success-soft: #edf7ef;
  --danger: #b33131; --danger-soft: #fceeee; --warning: #8a601c; --warning-soft: #fff7e7;
  --radius: 3px; --shadow: 0 1px 2px rgba(0,0,0,.04); --header-height: 56px; --sidebar-width: 224px;
  font-family: Meiryo, "Hiragino Kaku Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  font-size: 13px; line-height: 1.65; color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--primary-dark); outline-offset: 3px; }
h1, h2, h3 { line-height: 1.45; }
h2 { font-size: 17px; margin: 22px 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 100; padding: 10px 16px; background: #fff; }
.skip-link:focus { top: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { max-width: 100%; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.grid-2 { display: grid; gap: 12px 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid > *, .grid-2 > * { min-width: 0; }
.logo { display: inline-flex; align-items: center; flex-shrink: 0; color: var(--accent); text-decoration: none; }
.brand-lockup { display: inline-flex; flex-direction: column; align-items: center; }
.brand-logo { display: block; width: 180px; max-width: 100%; height: auto; }
.ui-icon { display: inline-block; flex: 0 0 18px; vertical-align: middle; }

/* Shared controls: compact, consistent heights and clear keyboard focus. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 12px; border: 1px solid #c9c9c9; border-radius: var(--radius); background: #f9f9f9; color: var(--text); font: inherit; line-height: 1.5; cursor: pointer; text-decoration: none; white-space: nowrap; vertical-align: middle; }
.btn:hover { background: #eee; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: #db771d; color: var(--on-primary); font-weight: 700; }
.btn-primary:hover { background: #e57819; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #922727; }
.btn-sm { min-height: 28px; padding: 3px 9px; font-size: 12px; }
.btn-lg { min-height: 46px; padding: 11px 24px; font-size: 16px; font-weight: 700; }
.btn[disabled], button:disabled { opacity: .55; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; color: var(--primary-dark); cursor: pointer; font: inherit; }
label { display: block; font-weight: 600; margin-bottom: 5px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: normal; margin: 0 12px 0 0; }
input:not([type]), input[type="tel"], input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], input[type="url"], select, textarea {
  width: 100%; min-height: 34px; padding: 6px 9px; border: 1px solid #c9c9c9; border-radius: var(--radius); background: #fff; color: var(--text); font: inherit; line-height: 1.5; max-width: 100%;
}
input[type="file"] { max-width: 100%; font: inherit; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-dark); vertical-align: middle; margin: 0 3px 0 0; }
input[readonly], textarea[readonly] { background: #f7f7f7; }
input:disabled, select:disabled, textarea:disabled { background: #eee; color: #777; }
input.inline-edit { width: 90px; min-height: 28px; padding: 3px 6px; }
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f9d9b9; outline-offset: 1px; border-color: var(--primary-dark); }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: normal; }
.field .error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
form.row, form > .row { align-items: flex-end; }
.row > .form-actions { margin-top: 0; }
.row > select, .row > input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) { width: auto; min-width: 100px; }
.row > .field { flex: 1 1 180px; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 16px; background: #fafafa; }
legend { font-weight: 700; padding: 0 6px; }

/* Panels, tables and search areas follow the legacy gray section bars. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card > :last-child { margin-bottom: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.content .card > h2:first-child, .content .card > h3:first-child, .content .card > .panel-title { margin: -16px -16px 16px; padding: 9px 14px; background: #555; color: #fff; border-bottom: 2px solid #333; font-size: 14px; font-weight: 600; }
.content .card > h2:first-child .badge { margin-left: 6px; }
.content > h2 { padding: 8px 0; border-bottom: 2px solid #ccc; }
.content form.card[method="get"] { background: #fafafa; }
.editor-form { max-width: 1120px; }
.editor-form > .form-actions { position: sticky; bottom: 0; z-index: 4; margin: 16px 0 0; padding: 12px 16px; background: #f7f7f7; border: 1px solid #ccc; box-shadow: 0 -2px 5px #00000008; }
.summary-strip { gap: 0; background: #fff; border: 1px solid var(--border); }
.summary-strip .stat { display: flex; align-items: baseline; gap: 12px; border: 0; border-right: 1px solid var(--border); padding: 8px 14px; }
.summary-strip .stat:last-child { border-right: 0; }
.summary-strip .stat .value { font-size: 18px; }
.alert { padding: 10px 14px; margin-bottom: 14px; border: 1px solid; border-left-width: 4px; border-radius: var(--radius); overflow-wrap: anywhere; }
.alert-success { background: var(--success-soft); border-color: #abd2b5; color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: #e5bcbc; color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: #e6cd9c; color: var(--warning); }
.alert-info { background: var(--primary-soft); border-color: #edc49e; color: var(--primary-dark); }
.alert a { font-weight: 700; text-decoration: underline; color: inherit; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11px; font-weight: 700; background: #e7e7e7; color: #555; vertical-align: middle; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.stat { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid #c6c3c0; border-radius: var(--radius); padding: 10px 12px; min-width: 0; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid #bbb; margin: 0 0 16px; padding: 0; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border: 1px solid transparent; border-top: 3px solid transparent; margin-bottom: -1px; color: #666; }
.tabs a:hover { background: #e9e9e9; text-decoration: none; }
.tabs a.active { border-color: #bbb; border-top-color: var(--primary); border-bottom-color: #fff; background: #fff; color: #444; font-weight: 700; }
.pager { display: flex; gap: 4px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.pager a, .pager span.current { padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.pager span.current { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 700; }
details.card > summary { cursor: pointer; font-weight: 700; color: #555; }
details.card[open] > summary { margin: -16px -16px 16px; padding: 10px 16px; background: #eee; border-bottom: 1px solid var(--border); }
.thumb { width: 48px; height: 48px; object-fit: contain; background: #fff; border-radius: 2px; border: 1px solid var(--border); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty p { margin: 0 0 6px; }
.progress { height: 8px; background: #e3e3e3; border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }
.table-wrap { overflow-x: auto; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 7px 9px; border-bottom: 1px solid var(--border); border-right: 1px solid #eee; text-align: left; vertical-align: top; }
.table th { background: #eee; font-size: 12px; color: #555; white-space: nowrap; font-weight: 700; }
.table thead th { border-bottom: 2px solid #bdbdbd; }
.table tr:last-child td { border-bottom: 0; }
.table th:last-child, .table td:last-child { border-right: 0; }
.table tbody tr:nth-child(even) { background: #fafafa; }
.table tbody tr:hover { background: #fff8ee; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table tr.selected td { background: var(--primary-soft); }
.table th a { color: inherit; }
.table td .btn + .btn { margin-left: 3px; }
.table td form { margin: 0; }
.table td.mono { white-space: nowrap; }
.account-entry { border: 1px solid #ddd; border-left: 3px solid #bbb; padding: 14px; margin-top: 10px; background: #fff; }
.account-entry.selected { border-left-color: var(--primary); background: #fffaf3; }
.account-entry-title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; overflow-wrap: anywhere; }
.account-entry-title strong { font-size: 15px; }
.account-entry-meta { display: flex; flex-wrap: wrap; gap: 4px 22px; margin-top: 8px; color: #666; font-size: 12px; }
.account-options { margin-top: 10px; }
.account-options > summary { cursor: pointer; color: #777; font-size: 12px; }
.account-options[open] > summary { margin-bottom: 10px; }

/* Persistent legacy-style masthead and collapsible category menu. */
body.app, body.workspace { padding-top: var(--header-height); }
.workspace-header { height: var(--header-height); position: fixed; inset: 0 0 auto; z-index: 40; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; background: #fff; border-bottom: 3px solid var(--primary); box-shadow: 0 1px 3px #00000012; padding: 0 14px; }
.workspace-header .brand-logo { width: 144px; }
.header-start, .header-end { display: flex; align-items: center; gap: 6px; min-width: 0; }
.header-end { justify-content: flex-end; }
.header-home { color: #666; font-size: 12px; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; border-radius: 3px; background: transparent; color: #555; cursor: pointer; position: relative; }
.icon-button:hover { background: #f0f0f0; text-decoration: none; }
.notification-dot { position: absolute; top: 0; right: 0; background: var(--danger); color: #fff; font-size: 10px; border-radius: 12px; padding: 0 4px; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 8px; cursor: pointer; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu[open] > summary, .user-menu > summary:hover { background: #eee; }
.user-menu-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu nav { position: absolute; right: 0; top: calc(100% + 8px); width: 250px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid #ccc; box-shadow: 0 4px 14px #0002; padding: 5px 0; }
.user-menu nav a, .user-menu nav button { display: block; padding: 8px 14px; width: 100%; text-align: left; color: #555; }
.user-menu nav a:hover, .user-menu nav button:hover { background: var(--primary-soft); text-decoration: none; }
.user-menu-heading { padding: 8px 14px 12px; border-bottom: 1px solid #ddd; font-weight: 700; overflow-wrap: anywhere; }
.user-menu-heading span { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.sidebar { width: var(--sidebar-width); position: fixed; top: var(--header-height); bottom: 0; left: 0; z-index: 30; overflow-y: auto; overscroll-behavior: contain; background: var(--sidebar); color: #eee; padding: 12px 10px 24px; border-right: 1px solid #222; }
.sidebar a:focus-visible, .sidebar summary:focus-visible { outline-color: var(--primary); }
.account-switch { padding: 10px; margin-bottom: 12px; background: #3a3d3d; border: 1px solid #484b4b; }
.account-caption { font-size: 10px; color: #bbb; margin-bottom: 4px; }
.account-name { font-size: 12px; overflow-wrap: anywhere; margin-bottom: 6px; }
.account-manage { color: #ddd; font-size: 11px; }
.account-switch select { min-height: 28px; font-size: 12px; padding: 4px; }
.menu-label { font-size: 11px; color: #aaa; padding: 10px 8px 4px; }
.menu-group { margin-bottom: 4px; }
.menu-group > summary { display: flex; align-items: center; gap: 9px; list-style: none; padding: 9px 8px; cursor: pointer; border-left: 3px solid transparent; }
.menu-group > summary::-webkit-details-marker { display: none; }
.menu-group > summary:hover { background: #444747; }
.menu-group.current-group > summary, .menu-group[open] > summary { background: #444747; border-left-color: var(--primary); }
.menu-chevron { margin-left: auto; font-size: 18px; line-height: 1; }
.menu-group[open] .menu-chevron { transform: rotate(90deg); }
.submenu { padding: 4px 0; background: #262828; }
.submenu a { display: flex; gap: 6px; justify-content: space-between; padding: 7px 10px 7px 35px; color: #ddd; font-size: 12px; }
.submenu a:hover { background: #414444; text-decoration: none; }
.submenu a.active { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.sidebar .count { background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; padding: 0 5px; }
.sidebar-external { display: flex; align-items: center; gap: 10px; padding: 10px; color: #ddd; }
.main { margin-left: var(--sidebar-width); min-width: 0; min-height: calc(100vh - var(--header-height)); display: flex; flex-direction: column; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 20px; background: #ededed; border-bottom: 1px solid #d5d5d5; }
.page-heading h1 { margin: 0; font-size: 20px; font-weight: 500; color: var(--primary-dark); }
.breadcrumb { font-size: 11px; color: #777; margin-bottom: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.content { padding: 18px 20px 32px; min-width: 0; flex: 1; }
.content:focus { outline: none; }
.workspace-footer { display: flex; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid #ddd; border-bottom: 4px solid var(--primary); color: #777; font-size: 11px; background: #fafafa; }
.workspace-container { max-width: 1200px; margin: 0 auto; min-height: calc(100vh - var(--header-height)); display: flex; flex-direction: column; border-inline: 1px solid #ddd; }
.workspace-tabs { margin: 0; padding: 12px 20px 0; background: #ededed; }
.nav-backdrop { display: none; }
.app.nav-collapsed .sidebar { display: none; }
.app.nav-collapsed .main { margin-left: 0; }

/* Public and authentication pages use the same brand and restrained panels. */
body.auth { display: flex; flex-direction: column; align-items: center; padding: 48px 16px 24px; min-height: 100vh; background: #ececec; }
.auth-card { background: #fff; border: 1px solid #ccc; border-top: 4px solid var(--primary); border-radius: 3px; padding: 26px; width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 680px; }
.auth-card .logo { display: flex; justify-content: center; margin: 0 auto 20px; }
.auth-card .brand-logo { width: 240px; }
.auth-card h1 { font-size: 18px; margin: 0 -26px 22px; padding: 12px 26px; background: #f4f4f4; border-block: 1px solid #e2e2e2; text-align: center; }
.auth-footer { padding: 18px 0; color: #888; font-size: 11px; }
.pub-header { display: flex; justify-content: space-between; align-items: center; padding: 8px max(24px, calc((100vw - 1120px) / 2)); background: #fff; border-top: 3px solid var(--primary); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; gap: 12px; flex-wrap: wrap; }
.pub-header nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pub-header nav a:not(.btn) { color: var(--text); }
.pub-footer { text-align: center; padding: 28px 16px; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.pub-footer nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.pub-footer p { margin: 16px 0 0; }
.hero { background: linear-gradient(135deg, #333, #5b5857); color: #fff; padding: 64px 24px; text-align: center; }
.hero .eyebrow { font-weight: 700; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); margin: 10px 0 18px; }
.hero p { font-size: 16px; max-width: 640px; margin: 0 auto 26px; }
.section { padding: 48px 24px; max-width: 1100px; margin: 0 auto; scroll-margin-top: 100px; }
.section > h2 { text-align: center; font-size: 26px; margin: 0 0 8px; }
.section > .lead { text-align: center; color: var(--muted); margin: 0 0 28px; }
.feature { background: #fff; border: 1px solid var(--border); border-radius: 3px; padding: 20px; }
.feature h3 { margin-top: 0; color: var(--accent); }
.feature ul { padding-left: 18px; margin: 8px 0 0; }
.price-card { background: #fff; border: 1px solid #ccc; border-top: 4px solid var(--primary); border-radius: 3px; padding: 24px; text-align: center; max-width: 420px; margin: 0 auto; }
.price-card .amount { font-size: 40px; font-weight: 800; color: var(--primary-dark); }
.faq dt { font-weight: 700; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--muted); }
.steps { counter-reset: s; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); padding-left: 0; }
.steps li { list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 3px; padding: 20px; }
.steps li::before { counter-increment: s; content: "STEP " counter(s); display: block; color: var(--primary-dark); font-weight: 800; margin-bottom: 6px; }
.prose { max-width: 860px; margin: 24px auto; padding: 28px; background: #fff; border: 1px solid var(--border); overflow-wrap: anywhere; }
.prose h1 { font-size: 24px; margin-top: 0; padding-bottom: 12px; border-bottom: 2px solid var(--primary); }

@media (max-width: 900px) {
  .card:has(> .table), fieldset:has(> .table) { overflow-x: auto; }
  .sidebar { display: none; width: min(280px, 85vw); }
  .app.nav-open .sidebar { display: block; }
  .app .main { margin-left: 0; }
  .app.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--header-height) 0 0; z-index: 25; border: 0; background: #0006; }
  .app.nav-open { overflow: hidden; }
  .page-heading { flex-wrap: wrap; padding: 12px 16px; }
  .topbar-actions { max-width: 100%; }
  .content { padding: 16px; }
  .workspace-tabs { padding-left: 16px; padding-right: 16px; }
  .user-menu-name { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .workspace-header { padding: 0 8px; }
  .workspace-header .brand-logo { width: 128px; }
  .header-home { font-size: 10px; }
  .page-heading h1 { font-size: 18px; }
  .topbar-actions { width: 100%; gap: 6px; }
  .topbar-actions .btn { font-size: 12px; }
  .content { padding: 12px; }
  .content .row > * { min-width: 0 !important; }
  .content .row > div:not(.form-actions) { flex-basis: 100%; }
  .content .row > select, .content .row > input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) { flex: 1 1 140px; }
  .content .row .form-actions { margin-top: 4px; }
  .card { padding: 12px; }
  .content .card > h2:first-child, .content .card > h3:first-child, .content .card > .panel-title { margin: -12px -12px 12px; padding: 9px 12px; }
  details.card[open] > summary { margin: -12px -12px 12px; padding: 10px 12px; }
  .tabs a { padding: 7px 9px; font-size: 12px; }
  .table th, .table td { padding: 6px 8px; }
  .pub-header { position: relative; padding: 10px 16px; justify-content: center; }
  .pub-header .brand-logo { width: 150px; }
  .pub-header nav { justify-content: center; gap: 10px 14px; font-size: 12px; }
  .pub-header nav .btn { font-size: 12px; }
  body.auth { padding-top: 24px; }
  .auth-card { padding: 20px; }
  .auth-card h1 { margin-inline: -20px; }
  .prose { margin: 12px; padding: 18px; }
  .section { padding: 36px 16px; }
  .section > h2 { font-size: 22px; }
}
@media print {
  .no-print, .skip-link { display: none !important; }
  body, body.app, body.workspace { background: #fff; padding: 0; }
  .main { margin: 0; }
  .content { padding: 0; }
  .page { page-break-after: always; }
}
