:root {
  --navy: #0f172a;
  --navy-soft: #1e2d4c;
  --blue: #0071b7;
  --blue-dark: #0f3f8c;
  --sky: #eaf5fd;
  --sky-strong: #cdeaff;
  --white: #fff;
  --surface: #f5f8fc;
  --ink: #152238;
  --muted: #66758a;
  --line: #dce5ef;
  --success: #1c8b68;
  --shadow: 0 18px 50px rgba(28, 55, 92, .09);
}

* { box-sizing: border-box; }
html { background: var(--surface); }
body { margin: 0; color: var(--ink); background: var(--surface); font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif; font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.demo-banner { min-height: 42px; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 24px; color: var(--white); background: linear-gradient(90deg, var(--blue-dark), var(--blue)); font-size: .82rem; }
.demo-banner strong { padding: 2px 9px; border: 1px solid rgba(255,255,255,.4); border-radius: 999px; font-size: .7rem; letter-spacing: .08em; }
.demo-banner a { margin-left: 10px; color: var(--white); font-weight: 700; }

.app-shell { min-height: calc(100vh - 42px); display: grid; grid-template-columns: 268px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 30; height: calc(100vh - 42px); display: flex; flex-direction: column; padding: 28px 20px 22px; color: var(--white); background: var(--navy); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 28px; border-bottom: 1px solid rgba(255,255,255,.09); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--blue-dark); background: linear-gradient(145deg, #fff, var(--sky-strong)); font-family: Georgia, serif; font-size: 1.25rem; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Yu Mincho", serif; font-size: 1.05rem; }
.brand small { margin-top: 1px; color: rgba(255,255,255,.48); font-size: .62rem; letter-spacing: .08em; }

.main-nav { display: grid; gap: 7px; padding-top: 25px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 13px; border: 0; border-radius: 12px; color: rgba(255,255,255,.68); background: transparent; text-align: left; font-size: .88rem; font-weight: 700; }
.nav-item span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; color: rgba(255,255,255,.72); background: rgba(255,255,255,.07); font-size: .74rem; }
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.07); }
.nav-item.is-active { color: var(--white); background: linear-gradient(135deg, var(--blue-dark), var(--blue)); box-shadow: 0 12px 28px rgba(0,113,183,.22); }
.nav-item.is-active span { color: var(--blue-dark); background: var(--sky-strong); }

.sidebar-note { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.09); }
.storage-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #57d6ad; box-shadow: 0 0 0 5px rgba(87,214,173,.1); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: .72rem; }
.sidebar-note small { color: rgba(255,255,255,.46); font-size: .58rem; }
.reset-button { border: 0; color: rgba(255,255,255,.52); background: transparent; font-size: .67rem; text-decoration: underline; }
.reset-button:hover { color: var(--white); }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 90px; display: flex; align-items: center; gap: 24px; padding: 16px 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.menu-button { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 11px; color: var(--navy); background: var(--white); }
.topbar-title { flex: 1; }
.topbar-title p { margin: 0 0 1px; color: var(--blue); font-size: .65rem; font-weight: 800; letter-spacing: .18em; }
.topbar-title h1 { margin: 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: 1.45rem; line-height: 1.3; }
.topbar-actions { display: flex; gap: 10px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 18px; border-radius: 11px; font-size: .82rem; font-weight: 700; }
.button-primary { border: 1px solid var(--blue); color: var(--white); background: var(--blue); box-shadow: 0 8px 22px rgba(0,113,183,.18); }
.button-primary:hover { background: #005f9b; }
.button-secondary { border: 1px solid var(--line); color: var(--blue-dark); background: var(--white); }
.button-secondary:hover { border-color: #b8cee0; background: var(--sky); }

.main-content { padding: 30px 34px 54px; outline: none; }
.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.welcome h2 { margin: 0 0 6px; font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: clamp(1.55rem, 2.4vw, 2.25rem); }
.welcome p { margin: 0; color: var(--muted); font-size: .9rem; }
.today { padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--blue-dark); background: var(--white); font-size: .75rem; white-space: nowrap; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 22px; }
.stat-card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--white); box-shadow: 0 8px 30px rgba(28,55,92,.045); }
.stat-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.stat-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 9px; color: var(--blue); background: var(--sky); font-size: .72rem; }
.stat-card strong { display: block; color: var(--navy); font-family: Georgia, serif; font-size: 1.75rem; line-height: 1; }
.stat-card small { display: block; margin-top: 7px; color: #8a98aa; font-size: .66rem; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 20px; }
.stack { display: grid; gap: 20px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: var(--shadow); }
.panel-heading { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: .98rem; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: .68rem; }
.panel-link { border: 0; color: var(--blue); background: transparent; font-size: .74rem; font-weight: 700; }
.panel-body { padding: 20px; }

.client-table { width: 100%; border-collapse: collapse; }
.client-table th { padding: 11px 13px; color: #7c8a9e; background: #f8fafd; font-size: .66rem; text-align: left; letter-spacing: .06em; }
.client-table td { padding: 14px 13px; border-top: 1px solid var(--line); font-size: .8rem; vertical-align: middle; }
.client-row { cursor: pointer; }
.client-row:hover td { background: #f8fbfe; }
.client-name { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 11px; color: var(--blue-dark); background: var(--sky); font-family: "Yu Mincho", serif; font-weight: 800; }
.client-name strong, .client-name small { display: block; }
.client-name strong { font-size: .82rem; }
.client-name small { color: #8997a8; font-size: .62rem; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; color: #176c54; background: #eaf8f3; font-size: .66rem; font-weight: 700; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }

.appointment-list, .timeline, .knowledge-grid { margin: 0; padding: 0; list-style: none; }
.appointment-item { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.appointment-item:first-child { padding-top: 0; border-top: 0; }
.date-tile { padding: 7px 4px; border-radius: 10px; color: var(--blue-dark); background: var(--sky); text-align: center; }
.date-tile strong, .date-tile small { display: block; }
.date-tile strong { font-family: Georgia, serif; font-size: 1.05rem; line-height: 1.1; }
.date-tile small { font-size: .58rem; }
.appointment-item h3 { margin: 1px 0 3px; font-size: .82rem; }
.appointment-item p { margin: 0; color: var(--muted); font-size: .69rem; }

.quick-list { display: grid; gap: 10px; }
.quick-button { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--white); text-align: left; font-size: .76rem; font-weight: 700; }
.quick-button:hover { border-color: #bbd8ea; background: var(--sky); }
.quick-button span { color: var(--blue); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.search-box { flex: 1; position: relative; }
.search-box span { position: absolute; left: 14px; top: 50%; color: #8290a2; transform: translateY(-50%); }
.search-box input { width: 100%; min-height: 46px; padding: 0 15px 0 40px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--white); outline: none; }
.search-box input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,183,.09); }
.view-count { color: var(--muted); font-size: .75rem; white-space: nowrap; }

.detail-layout { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr); gap: 20px; }
.profile-card { padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--white); box-shadow: var(--shadow); }
.profile-main { display: flex; align-items: center; gap: 15px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.profile-main .avatar { width: 54px; height: 54px; font-size: 1.1rem; }
.profile-main h2 { margin: 0; font-size: 1.15rem; }
.profile-main p { margin: 2px 0 0; color: var(--muted); font-size: .7rem; }
.profile-list { display: grid; gap: 13px; margin: 20px 0 0; }
.profile-list div { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.profile-list dt { color: var(--muted); font-size: .69rem; }
.profile-list dd { margin: 0; font-size: .78rem; overflow-wrap: anywhere; }
.state-box { margin-top: 20px; padding: 15px; border-radius: 12px; background: var(--sky); }
.state-box small { color: var(--blue); font-weight: 800; }
.state-box p { margin: 6px 0 0; font-size: .78rem; }
.detail-actions { display: flex; gap: 8px; margin-top: 18px; }

.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 1px; background: #c9d8e6; }
.timeline-item { position: relative; padding: 0 0 24px 38px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: 5px; top: 5px; width: 13px; height: 13px; border: 3px solid var(--white); border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.timeline-date { margin-bottom: 7px; color: var(--blue); font-family: Georgia, serif; font-size: .73rem; font-weight: 700; }
.timeline-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #fbfdff; }
.timeline-card h3 { margin: 0 0 10px; font-size: .82rem; }
.timeline-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.timeline-grid div { padding: 10px; border-radius: 9px; background: var(--white); }
.timeline-grid small { color: var(--muted); font-size: .62rem; font-weight: 700; }
.timeline-grid p { margin: 4px 0 0; font-size: .72rem; }
.timeline-next { margin: 11px 0 0; color: var(--blue-dark); font-size: .72rem; }

.knowledge-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.knowledge-card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 9px 28px rgba(28,55,92,.045); }
.knowledge-tag { display: inline-block; margin-bottom: 13px; padding: 4px 9px; border-radius: 999px; color: var(--blue); background: var(--sky); font-size: .62rem; font-weight: 800; }
.knowledge-card h3 { margin: 0 0 10px; font-size: .96rem; }
.knowledge-card p { margin: 0; color: var(--muted); font-size: .78rem; }
.knowledge-card footer { margin-top: 17px; padding-top: 12px; border-top: 1px solid var(--line); color: #8b99aa; font-size: .62rem; }

.empty { padding: 50px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 4px; color: var(--ink); }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8,20,41,.62); backdrop-filter: blur(4px); }
.modal-panel { position: relative; width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 27px; border-radius: 20px; background: var(--white); box-shadow: 0 28px 90px rgba(4,15,34,.3); }
.modal-panel-small { width: min(590px, 100%); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-heading p { margin: 0 0 2px; color: var(--blue); font-size: .64rem; font-weight: 800; letter-spacing: .17em; }
.modal-heading h2 { margin: 0; font-family: "Yu Mincho", serif; font-size: 1.45rem; }
.modal-heading > button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: var(--white); font-size: 1.15rem; }
.modal form { display: grid; gap: 15px; }
.modal label { display: grid; gap: 6px; color: var(--ink); font-size: .75rem; font-weight: 700; }
.modal input, .modal select, .modal textarea { width: 100%; border: 1px solid #cdd9e6; border-radius: 10px; color: var(--ink); background: #fbfdff; outline: none; }
.modal input, .modal select { min-height: 45px; padding: 0 12px; }
.modal textarea { padding: 11px 12px; resize: vertical; }
.modal input:focus, .modal select:focus, .modal textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0,113,183,.08); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 8px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 340px; padding: 13px 17px; border-radius: 11px; color: var(--white); background: var(--navy); box-shadow: 0 14px 40px rgba(8,20,41,.25); font-size: .78rem; opacity: 0; pointer-events: none; transform: translateY(15px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .knowledge-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .demo-banner { justify-content: flex-start; padding: 8px 15px; }
  .demo-banner span { display: none; }
  .demo-banner a { margin-left: auto; }
  .app-shell { display: block; }
  .sidebar { position: fixed; top: 42px; left: 0; width: 268px; height: calc(100vh - 42px); transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 42px 0 0; z-index: 25; background: rgba(8,20,41,.45); }
  .sidebar-backdrop:not([hidden]) { display: block; }
  .menu-button { display: grid; place-items: center; }
  .topbar { min-height: 78px; padding: 13px 18px; }
  .topbar-title h1 { font-size: 1.18rem; }
  .topbar-actions .button-secondary { display: none; }
  .main-content { padding: 24px 18px 46px; }
  .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 590px) {
  .demo-banner { font-size: .72rem; }
  .demo-banner strong { font-size: .61rem; }
  .topbar-actions .button { min-height: 40px; padding: 0 12px; font-size: .72rem; }
  .welcome { display: block; }
  .today { display: inline-block; margin-top: 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-card-head { gap: 5px; font-size: .64rem; }
  .stat-card-head > span:first-child { white-space: nowrap; }
  .stat-icon { width: 28px; height: 28px; }
  .stat-card strong { font-size: 1.4rem; }
  .client-table thead, .client-table th:nth-child(3), .client-table td:nth-child(3), .client-table th:nth-child(4), .client-table td:nth-child(4) { display: none; }
  .client-table td { padding: 12px 8px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .knowledge-grid { grid-template-columns: 1fr; }
  .timeline-grid, .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 10px; }
  .modal-panel { max-height: calc(100vh - 20px); padding: 21px 17px; border-radius: 16px; }
  .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .toast { right: 14px; bottom: 14px; left: 14px; max-width: none; }
}
