:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --line: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7280;
  --brand: #1d4ed8;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* The UA stylesheet applies `hidden` as `[hidden] { display: none }` at the same
   specificity as a class, so any later class that sets `display` silently wins
   and the element stays visible. Every view here is toggled with `hidden`, and
   the modal has a full-screen overlay — when it leaked through, it swallowed
   every click on the page. Make `hidden` mean hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
}

/* --- brand ---------------------------------------------------------------- */

.brand { display: flex; align-items: center; gap: .55rem; }
.brand-mark {
  background: var(--brand); color: #fff; font-weight: 700; letter-spacing: .04em;
  padding: .2rem .45rem; border-radius: 5px; font-size: .8rem;
}
.brand-name { font-weight: 600; }

/* --- sign-in -------------------------------------------------------------- */

.signin { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.signin-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 2.25rem; width: min(420px, 100%); text-align: center;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.signin-card .brand { justify-content: center; margin-bottom: 1.5rem; }
.signin-lead { color: var(--muted); margin: 0 0 1.5rem; }
.signin-note { color: var(--muted); font-size: .8rem; margin: 1.25rem 0 0; }

/* --- shell ---------------------------------------------------------------- */

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.topbar-right { display: flex; align-items: center; gap: .9rem; }
.who { display: flex; align-items: center; gap: .5rem; }
.who-name { font-weight: 600; }

.badge {
  background: #eef2ff; color: var(--brand); border-radius: 999px;
  padding: .1rem .55rem; font-size: .75rem; font-weight: 600;
}

.tabs {
  display: flex; gap: .25rem; padding: 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: .6rem .9rem; font: inherit; color: var(--muted); cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.content { padding: 1.25rem; max-width: 1100px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }

/* --- banner (503 etc.) ---------------------------------------------------- */

.banner {
  margin: 1rem 1.25rem 0; padding: .7rem .9rem; border-radius: var(--radius);
  background: #fffaeb; border: 1px solid #fedf89; color: var(--warn);
}

/* --- table ---------------------------------------------------------------- */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #fafbfc; font-size: .78rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.table tr:last-child td { border-bottom: none; }
.table .right { text-align: right; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }

.state { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.state.denied { color: var(--text); }

.row-form { display: flex; gap: .5rem; padding: .9rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row-form input { flex: 1 1 12rem; }

/* --- controls ------------------------------------------------------------- */

input, select {
  font: inherit; padding: .4rem .55rem; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: inherit; min-width: 0;
}
input:focus, select:focus { outline: 2px solid #c7d2fe; outline-offset: 0; border-color: var(--brand); }

.btn {
  font: inherit; padding: .4rem .8rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #f3f4f6; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #912018; }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-block { display: block; width: 100%; text-decoration: none; text-align: center; padding: .6rem; }

.ws-picker { display: flex; flex-wrap: wrap; gap: .35rem .8rem; }
.ws-picker label { display: flex; align-items: center; gap: .3rem; font-size: .85rem; }

/* --- modal ---------------------------------------------------------------- */

.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; padding: 1rem; }
.modal-card { background: var(--surface); border-radius: 10px; padding: 1.4rem; width: min(420px, 100%); }
.modal-card h3 { margin: 0 0 .5rem; }
.modal-card p { margin: 0 0 1.2rem; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* --- toasts --------------------------------------------------------------- */

.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 10; }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--ok);
  border-radius: var(--radius); padding: .6rem .9rem; max-width: 26rem;
  box-shadow: 0 4px 12px rgba(16, 24, 40, .12);
}
.toast.error { border-left-color: var(--danger); }
.toast .toast-title { font-weight: 600; }
.toast .toast-detail { color: var(--muted); font-size: .85rem; }

@media (max-width: 620px) {
  .table th:nth-child(2), .table td:nth-child(2) { display: none; }
  .content { padding: .75rem; }
}
