:root {
  --navy-950: #061225;
  --navy-900: #091a33;
  --navy-800: #10294b;
  --blue-700: #135fc0;
  --blue-600: #1478e8;
  --blue-500: #2898ff;
  --cyan-400: #45d2ef;
  --ink-900: #132238;
  --ink-700: #40516a;
  --ink-500: #718096;
  --line: #dce5ef;
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --surface-3: #eaf1f8;
  --green: #17875c;
  --green-bg: #e8f7f0;
  --amber: #ad6b0b;
  --amber-bg: #fff4df;
  --red: #bd3442;
  --red-bg: #fdecef;
  --purple: #6b4fc7;
  --purple-bg: #f0edff;
  --shadow: 0 16px 40px rgba(19, 43, 76, .10);
  --shadow-soft: 0 6px 20px rgba(19, 43, 76, .07);
  --radius: 16px;
  --sidebar: 246px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink-900);
  background: var(--surface-2);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  overflow-y: auto;
  color: #fff;
  background:
    radial-gradient(circle at 15% 8%, rgba(40, 152, 255, .23), transparent 24%),
    linear-gradient(180deg, var(--navy-950), var(--navy-900));
  transition: transform .25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, var(--blue-500), #145bc7);
  box-shadow: 0 8px 24px rgba(20, 120, 232, .35);
  font-weight: 800;
  letter-spacing: .08em;
}

.brand strong { display: block; font-size: 16px; letter-spacing: .02em; }
.brand span { display: block; margin-top: 2px; color: #92a9c5; font-size: 10px; letter-spacing: .06em; }

.main-nav { padding: 18px 12px; }

.nav-section-label {
  margin: 18px 10px 7px;
  color: #6884a5;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .13em;
}

.nav-section-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  margin: 3px 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  color: #aebed2;
  background: transparent;
  text-align: left;
  transition: .18s ease;
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(40, 152, 255, .28), rgba(40, 152, 255, .08)); }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 24px; border-radius: 0 4px 4px 0; background: var(--cyan-400); }
.nav-icon { display: grid; width: 22px; place-items: center; color: #75bfff; font-size: 16px; }
.nav-item span:last-child { flex: 1; }
.nav-count { min-width: 22px; padding: 1px 6px; border-radius: 10px; color: #cdeaff; background: rgba(40, 152, 255, .22); font-size: 10px; text-align: center; }

.sidebar-note {
  margin: auto 14px 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px;
  color: #91a7c1;
  background: rgba(255, 255, 255, .035);
  font-size: 11px;
}
.sidebar-note p { margin: 5px 0 0; }

.main-area { min-height: 100vh; margin-left: var(--sidebar); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(18px, 3vw, 38px);
  border-bottom: 1px solid rgba(218, 228, 239, .9);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}

.page-heading h1 { margin: 3px 0 0; font-size: clamp(20px, 2.2vw, 27px); line-height: 1.2; letter-spacing: .01em; }
.eyebrow { color: var(--blue-600); font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.role-switcher { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.role-switcher span { color: var(--ink-500); font-size: 11px; }
.role-switcher select { max-width: 180px; padding: 4px 26px 4px 2px; border: 0; color: var(--ink-900); background: #fff; font-weight: 700; outline: none; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-700); background: #fff; }
.icon-button:hover { border-color: #b9cee3; color: var(--blue-700); }
.menu-button { display: none; }
.notification-button span { color: var(--red); font-size: 12px; }
.user-badge { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; color: #fff; background: linear-gradient(145deg, var(--navy-800), var(--blue-700)); font-size: 12px; font-weight: 800; }

.role-context {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px clamp(18px, 3vw, 38px);
  color: #2b547d;
  background: #eaf5ff;
  font-size: 12px;
}
.role-context strong { color: var(--blue-700); }

#app { max-width: 1500px; margin: 0 auto; padding: 28px clamp(18px, 3vw, 38px) 56px; outline: none; }

.page-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-tools h2 { margin: 0 0 4px; font-size: 20px; }
.page-tools p { margin: 0; color: var(--ink-500); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-700);
  background: #fff;
  font-weight: 700;
  text-decoration: none;
  transition: .16s ease;
}
.button:hover { border-color: #a8c5e2; transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.button.primary { border-color: var(--blue-600); color: #fff; background: linear-gradient(135deg, var(--blue-600), #1056b8); }
.button.soft { border-color: #cfe4fa; color: var(--blue-700); background: #edf7ff; }
.button.danger { border-color: #f1c5ca; color: var(--red); background: var(--red-bg); }
.button.small { min-height: 31px; padding: 5px 10px; font-size: 12px; }

.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: minmax(0, 1.45fr) minmax(290px, .8fr); }
.grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-soft); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.card-header h3 { margin: 0; font-size: 15px; }
.card-header p { margin: 3px 0 0; color: var(--ink-500); font-size: 12px; }
.card-body { padding: 8px 20px 20px; }

.kpi-card { position: relative; overflow: hidden; min-height: 132px; padding: 19px; }
.kpi-card::after { content: ""; position: absolute; right: -25px; bottom: -40px; width: 110px; height: 110px; border-radius: 50%; background: var(--kpi-glow, #e8f4ff); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--ink-500); font-size: 12px; font-weight: 700; }
.kpi-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; color: var(--kpi-color, var(--blue-600)); background: var(--kpi-bg, #eaf5ff); font-weight: 800; }
.kpi-value { position: relative; z-index: 1; margin: 16px 0 3px; font-size: 27px; font-weight: 800; letter-spacing: -.02em; }
.kpi-foot { position: relative; z-index: 1; color: var(--ink-500); font-size: 11px; }
.kpi-foot strong { color: var(--green); }

.status { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.green { color: var(--green); background: var(--green-bg); }
.status.amber { color: var(--amber); background: var(--amber-bg); }
.status.red { color: var(--red); background: var(--red-bg); }
.status.blue { color: var(--blue-700); background: #e9f3ff; }
.status.purple { color: var(--purple); background: var(--purple-bg); }
.status.gray { color: #667085; background: #eef1f4; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink-500); background: #f8fafc; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-align: left; white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.data-table tbody tr { transition: .15s ease; }
.data-table tbody tr:hover { background: #f7fbff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.table-link { border: 0; color: var(--blue-700); background: transparent; font-weight: 800; text-align: left; }
.muted { color: var(--ink-500); }
.strong { font-weight: 800; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .95em; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 15px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.field { display: grid; gap: 5px; }
.field.grow { flex: 1; min-width: 220px; }
.field label { color: var(--ink-500); font-size: 10px; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-900); background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(40, 152, 255, .12); }

.activity-list, .alert-list, .simple-list { display: grid; gap: 0; }
.activity-item, .alert-item, .simple-item { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px solid #edf1f5; }
.activity-item:last-child, .alert-item:last-child, .simple-item:last-child { border-bottom: 0; }
.activity-dot { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 6px; border: 2px solid #fff; border-radius: 50%; background: var(--blue-500); box-shadow: 0 0 0 2px #cbe7ff; }
.activity-content { flex: 1; }
.activity-content strong { display: block; font-size: 12px; }
.activity-content p { margin: 2px 0 0; color: var(--ink-500); font-size: 11px; }
.activity-time { color: var(--ink-500); font-size: 10px; white-space: nowrap; }
.alert-icon { display: grid; flex: 0 0 auto; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: var(--amber); background: var(--amber-bg); }
.alert-item.danger .alert-icon { color: var(--red); background: var(--red-bg); }

.progress-row { margin: 13px 0; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 11px; }
.progress { height: 7px; overflow: hidden; border-radius: 6px; background: #e8eef5; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue-600), var(--cyan-400)); }

.relationship-canvas { position: relative; min-height: 390px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background-color: #f7faff; background-image: radial-gradient(#cbd8e6 1px, transparent 1px); background-size: 22px 22px; }
.relationship-stage { position: relative; min-width: 920px; min-height: 390px; }
.relation-line { position: absolute; height: 2px; transform-origin: left center; background: #aac6df; }
.relation-line::after { content: ""; position: absolute; right: -1px; top: -4px; border-width: 5px 0 5px 7px; border-style: solid; border-color: transparent transparent transparent #7ca9cf; }
.relation-label { position: absolute; top: -20px; left: 50%; padding: 2px 6px; border: 1px solid #d5e4f1; border-radius: 8px; color: #52718f; background: rgba(255,255,255,.94); font-size: 9px; white-space: nowrap; transform: translateX(-50%); }
.org-node { position: absolute; z-index: 2; width: 150px; padding: 12px; border: 1px solid #cfe0ef; border-radius: 12px; background: #fff; box-shadow: 0 8px 22px rgba(22, 60, 98, .09); }
.org-node.primary { border-color: #58aaff; color: #fff; background: linear-gradient(145deg, #126ddd, #0b4eab); }
.org-node .org-type { display: block; margin-bottom: 3px; color: var(--ink-500); font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.org-node.primary .org-type { color: #c7e5ff; }
.org-node strong { display: block; font-size: 12px; }
.org-node small { display: block; margin-top: 4px; color: var(--ink-500); font-size: 9px; }
.org-node.primary small { color: #c7e5ff; }

.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; padding: 3px 7px; border: 1px solid #cfe0ef; border-radius: 6px; color: #3c638a; background: #f5faff; font-size: 10px; }
.tag.blue { border-color: #bddcff; color: #105cad; background: #eaf5ff; }
.tag.dark { border-color: #cfd7e0; color: #34445a; background: #eef2f6; }

.tabs { display: flex; gap: 5px; overflow-x: auto; margin-bottom: 16px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.tab { padding: 8px 13px; border: 0; border-radius: 8px; color: var(--ink-500); background: transparent; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tab.active { color: var(--blue-700); background: #eaf5ff; }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { min-height: 390px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #eef3f8; }
.kanban-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 800; }
.kanban-count { display: grid; min-width: 24px; height: 24px; place-items: center; border-radius: 8px; color: var(--blue-700); background: #dcecff; font-size: 10px; }
.kanban-card { margin-bottom: 9px; padding: 12px; border: 1px solid #d8e3ed; border-radius: 11px; background: #fff; box-shadow: 0 5px 14px rgba(23, 50, 82, .06); }
.kanban-card button { padding: 0; border: 0; color: var(--ink-900); background: transparent; font-weight: 800; text-align: left; }
.kanban-card p { margin: 6px 0; color: var(--ink-500); font-size: 10px; }
.kanban-meta { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.sla { color: var(--amber); font-size: 9px; font-weight: 800; }
.sla.over { color: var(--red); }

.timeline { position: relative; margin: 4px 0 4px 7px; padding-left: 24px; }
.timeline::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 5px; width: 2px; background: #d9e6f1; }
.timeline-item { position: relative; padding: 0 0 18px; }
.timeline-item::before { content: ""; position: absolute; top: 5px; left: -24px; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--blue-500); box-shadow: 0 0 0 2px #bfe0fc; }
.timeline-item.future::before { background: #c7d2de; box-shadow: 0 0 0 2px #e4eaf0; }
.timeline-item strong { display: block; font-size: 12px; }
.timeline-item span { color: var(--ink-500); font-size: 10px; }

.decision-list { display: grid; gap: 12px; }
.decision { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.decision-label { display: flex; align-items: flex-start; }
.decision h3 { margin: 0 0 5px; font-size: 14px; }
.decision p { margin: 0; color: var(--ink-700); }
.decision .alternative { margin-top: 9px; padding: 9px 11px; border-left: 3px solid var(--blue-500); color: #244a70; background: #f1f8ff; font-size: 12px; }

.metric-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.metric { padding: 13px; background: #fff; }
.metric span { display: block; color: var(--ink-500); font-size: 10px; }
.metric strong { display: block; margin-top: 4px; font-size: 17px; }

.empty-state { display: grid; min-height: 300px; place-items: center; padding: 30px; border: 1px dashed #bfd0e1; border-radius: 14px; color: var(--ink-500); background: #fff; text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink-900); font-size: 16px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(4, 17, 36, .34); backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; z-index: 50; width: min(560px, 96vw); height: 100vh; overflow-y: auto; background: #fff; box-shadow: -24px 0 60px rgba(6, 25, 50, .2); transform: translateX(105%); transition: transform .24s ease; }
.drawer.open { transform: translateX(0); }
.drawer-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); backdrop-filter: blur(10px); }
.drawer-header h2 { margin: 4px 0 0; font-size: 20px; }
.drawer-body { padding: 22px 24px 42px; }
.detail-section { margin-bottom: 24px; }
.detail-section h3 { margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.definition-grid { display: grid; grid-template-columns: 150px 1fr; gap: 0; }
.definition-grid dt, .definition-grid dd { margin: 0; padding: 8px 0; border-bottom: 1px solid #edf1f5; }
.definition-grid dt { color: var(--ink-500); font-size: 11px; }
.definition-grid dd { font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 8px; }
.toast { min-width: 270px; padding: 12px 15px; border-left: 4px solid var(--green); border-radius: 10px; color: var(--ink-900); background: #fff; box-shadow: var(--shadow); animation: toast-in .22s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.access-denied { border-left: 4px solid var(--red); }
.consumer-hero { position: relative; overflow: hidden; padding: 30px; border: 1px solid #b9d9fb; border-radius: 18px; color: #fff; background: linear-gradient(135deg, #0b315f, #0d6acb 75%, #23a9dc); box-shadow: var(--shadow); }
.consumer-hero::after { content: "DDW"; position: absolute; right: 30px; bottom: -32px; color: rgba(255,255,255,.1); font-size: 110px; font-weight: 900; letter-spacing: .04em; }
.consumer-hero h2 { position: relative; z-index: 1; margin: 8px 0; font-size: clamp(24px, 4vw, 36px); }
.consumer-hero p { position: relative; z-index: 1; max-width: 580px; color: #d9efff; }
.consumer-hero .button { position: relative; z-index: 1; margin-top: 10px; }

@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  :root { --sidebar: 244px; }
  .sidebar { transform: translateX(-102%); box-shadow: 18px 0 40px rgba(7, 24, 47, .22); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-button { display: grid; }
  .topbar { min-height: 72px; }
  .role-switcher span { display: none; }
  .page-tools { align-items: stretch; flex-direction: column; }
  .actions { justify-content: flex-start; }
  .grid.equal { grid-template-columns: 1fr; }
  .definition-grid { grid-template-columns: 120px 1fr; }
}

@media (max-width: 560px) {
  .topbar { padding-inline: 12px; }
  .page-heading .eyebrow { display: none; }
  .page-heading h1 { max-width: 145px; overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
  .role-switcher { max-width: 145px; }
  .role-switcher select { width: 125px; font-size: 11px; }
  .notification-button { display: none; }
  .role-context { padding-inline: 14px; }
  #app { padding: 20px 14px 44px; }
  .grid.kpis { grid-template-columns: 1fr; }
  .kpi-card { min-height: 112px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .metric-strip { grid-template-columns: 1fr; }
  .decision { grid-template-columns: 1fr; gap: 8px; }
  .drawer-body { padding-inline: 17px; }
  .definition-grid { grid-template-columns: 1fr; }
  .definition-grid dt { padding-bottom: 2px; border-bottom: 0; }
  .definition-grid dd { padding-top: 0; }
}
