* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; max-width: 100%; }
body { margin: 0; color: #172126; background: #f3f6f7; font-family: system-ui, sans-serif; letter-spacing: 0; overflow-wrap: anywhere; }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.app-nav { padding: 24px 18px; color: #fff; background: #14272b; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; }
.brand > span { width: 44px; height: 44px; display: grid; place-items: center; color: #fff; background: var(--brand); border-radius: 6px; }
.user-panel { display: grid; margin: 28px 0; padding: 14px; border: 1px solid #ffffff2b; border-radius: 6px; }
.nav-group { display: grid; gap: 6px; }
.nav-group hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid #ffffff2b; }
.nav-button, .link-button { border: 0; color: inherit; background: transparent; text-align: left; padding: 11px 12px; border-radius: 6px; }
.nav-button:hover, .nav-button.active { background: #ffffff18; }
.nav-submenu { display: grid; gap: 6px; margin-top: -4px; padding-left: 14px; }
.nav-submenu[hidden] { display: none; }
.nav-sub-button { display: block; width: 100%; min-height: 34px; padding: 8px 12px; border: 1px solid transparent; border-radius: 6px; color: inherit; background: transparent; text-align: left; text-decoration: none; }
.nav-sub-button:hover, .nav-sub-button.active { border-color: #ffffff18; background: #ffffff18; }
main, .app-view, .content-panel, .plan-card, .domain-view-slot { min-width: 0; }
main { padding: 34px; }
.app-view { display: none; }
.app-view.active { display: block; }
.content-panel, .plan-card, .domain-view-slot { padding: 20px; background: #fff; border: 1px solid #d7e0e2; border-radius: 6px; }
.domain-view-slot:empty::before { content: "この領域にサービス固有機能を実装します。"; color: #65777d; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.billing-management { margin-top: 16px; }
.plan-card button, .primary { padding: 10px 16px; border: 0; border-radius: 6px; color: #fff; background: var(--brand); }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel { width: min(420px, 100%); display: grid; gap: 16px; padding: 28px; background: #fff; border: 1px solid #d7e0e2; border-radius: 6px; }
label { display: grid; gap: 6px; }
input, select { width: 100%; padding: 10px; border: 1px solid #b8c5c8; border-radius: 4px; }
input[type="checkbox"], input[type="radio"] { width: auto; }
.password-field { position: relative; display: block; color: #172126; font-size: 16px; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 8px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; color: #65777d; background: transparent; transform: translateY(-50%); }
.password-toggle:hover, .password-toggle:focus-visible { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); outline: none; }
.eye-icon { position: absolute; top: 50%; left: 50%; width: 20px; height: 12px; border: 2px solid currentColor; border-radius: 50% / 65%; transform: translate(-50%, -50%); }
.eye-icon::before { content: ""; position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: currentColor; transform: translate(-50%, -50%); }
.password-toggle[aria-pressed="true"] .eye-icon::after { content: ""; position: absolute; top: 50%; left: -3px; width: 26px; height: 2px; border-radius: 999px; background: currentColor; transform: rotate(-35deg); }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button { padding: 9px 12px; border: 1px solid #c7d2d5; background: #fff; border-radius: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px; border-bottom: 1px solid #d7e0e2; text-align: left; }
.admin-table-scroll { overflow-x: auto; }
.admin-user-table { min-width: 1180px; }
.admin-activity-table { min-width: 1400px; }
.admin-activity-table code { display: block; max-width: 320px; overflow-wrap: anywhere; white-space: normal; }
.admin-user-table input, .admin-user-table select { min-width: 110px; }
.admin-user-table input[data-admin-user-field="displayName"] { min-width: 160px; }
.admin-checkbox-cell { text-align: center; }
.admin-checkbox-cell input { width: auto; min-width: 0; }
.admin-filter-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.admin-filter-form label { display: grid; gap: 4px; }
.admin-delete-button { margin-left: 6px; border-color: #a53131; color: #8b2020; background: #fff; }
.admin-save-button { white-space: nowrap; }
.admin-plan-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 16px; }
.admin-plan-head h2, .admin-plan-head p { margin-top: 0; }
.admin-plan-table { min-width: 920px; }
.admin-plan-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-plan-form input, .admin-plan-form textarea { width: 100%; }
.admin-plan-wide, .admin-plan-actions { grid-column: 1 / -1; }
.admin-plan-checkbox { display: flex; align-items: center; gap: 8px; }
.admin-plan-checkbox input { width: auto; }
.admin-plan-actions { display: flex; gap: 10px; }
.busy-overlay { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: transparent; cursor: progress; }
.busy-indicator { display: flex; align-items: center; gap: 11px; padding: 12px 16px; border: 1px solid rgba(184, 197, 200, 0.82); border-radius: 999px; color: #496066; background: #fff; box-shadow: 0 8px 28px rgba(23, 33, 38, 0.14); font-size: 14px; font-weight: 600; }
.busy-spinner { width: 28px; height: 28px; border: 3px solid rgba(16, 142, 137, 0.18); border-color: color-mix(in srgb, var(--brand) 18%, transparent); border-top-color: rgba(16, 142, 137, 0.72); border-top-color: color-mix(in srgb, var(--brand) 72%, transparent); border-radius: 50%; animation: busy-spin 0.8s linear infinite; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 18px; bottom: 18px; max-width: 420px; padding: 12px; color: #fff; background: #172126; border-radius: 4px; opacity: 0; pointer-events: none; }
.toast.visible { opacity: 1; }
.legal-page { width: min(900px, calc(100% - 40px)); margin: 50px auto; padding: 28px; background: #fff; border: 1px solid #d7e0e2; }
@media (prefers-reduced-motion: reduce) {
  .busy-spinner { animation-duration: 1.8s; }
}
@media (max-width: 760px) {
  html, body { min-width: 0; overflow-x: hidden; }
  button, input, select { font-size: 16px; }
  .shell { display: block; }
  .app-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 12px 12px;
    box-shadow: 0 10px 26px rgba(15, 30, 32, 0.18);
  }
  .brand { min-width: 0; gap: 10px; font-size: 21px; line-height: 1.1; }
  .brand > span { flex: 0 0 auto; width: 38px; height: 38px; font-size: 20px; }
  .brand > strong { min-width: 0; overflow-wrap: anywhere; }
  .user-panel {
    display: flex;
    align-items: center;
    gap: 6px 10px;
    flex-wrap: wrap;
    margin: 4px 0 0;
    padding: 9px 10px;
  }
  .user-panel > strong,
  .user-panel > small {
    min-width: 0;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .user-panel .link-button { flex: 0 0 auto; min-height: 32px; margin-left: auto; padding: 4px 0; white-space: nowrap; }
  .nav-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0 0 2px;
  }
  .nav-group hr { display: none; }
  .nav-group .nav-button {
    flex: 0 0 auto;
    width: auto;
    min-height: 42px;
    padding: 10px 13px;
    border: 1px solid #ffffff2b;
    text-align: center;
    white-space: nowrap;
  }
  .nav-submenu {
    display: flex;
    flex: 1 0 100%;
    order: 99;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0 0 2px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .nav-submenu::-webkit-scrollbar { display: none; }
  .nav-submenu[hidden] { display: none; }
  .nav-sub-button { flex: 0 0 auto; width: auto; min-height: 42px; padding: 10px 13px; text-align: center; white-space: nowrap; }
  main {
    width: 100%;
    max-width: 100vw;
    padding: 16px 10px 28px;
    overflow-x: hidden;
  }
  main h1 { margin: 0 0 16px; font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
  .content-panel, .plan-card, .domain-view-slot { width: 100%; max-width: 100%; padding: 14px; }
  .plan-grid { grid-template-columns: 1fr; }
  main button, .auth-panel button, input:not([type="checkbox"]):not([type="radio"]), select { min-height: 44px; }
  .auth-screen { padding: 12px; }
  .auth-panel { padding: 20px; }
  .admin-table-scroll, .tabs { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
  .admin-plan-head { display: grid; }
  .admin-plan-form { grid-template-columns: 1fr; }
  .toast { left: 10px; right: 10px; bottom: 10px; max-width: none; }
  .legal-page { width: calc(100% - 20px); margin: 10px auto; padding: 18px 14px; }
}
