:root {
  --side-bg: #16283c;
  --side-bg2: #1d3350;
  --side-text: #b8c9da;
  --side-active: #2f81c7;
  --accent: #2470b3;
  --accent-hover: #1c5c96;
  --bg: #f2f5f8;
  --card: #ffffff;
  --line: #dfe6ec;
  --text: #24303a;
  --muted: #71808d;
  --pin: #e8a723;
  --danger: #b3372b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(22, 40, 60, .08);
  --shadow-hover: 0 6px 18px rgba(22, 40, 60, .14);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }

/* ---- レイアウト ---- */
#layout { display: flex; min-height: 100vh; }
#mainwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; max-width: 1180px; width: 100%; margin: 0 auto; padding: 22px 26px 70px; }

/* ---- サイドバー ---- */
#sidebar {
  width: 232px; flex-shrink: 0; background: linear-gradient(180deg, var(--side-bg) 0%, #101e2e 100%);
  color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: bold; font-size: 16.5px; padding: 18px 18px 14px; letter-spacing: .02em; }
.brand-icon { font-size: 22px; }
#sidenav { flex: 1; padding: 6px 10px; }
#sidenav .nav-title { font-size: 10.5px; letter-spacing: .14em; color: #6d8199; padding: 14px 10px 6px; }
#sidenav a {
  display: flex; align-items: center; gap: 9px; color: var(--side-text); font-size: 13.5px;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 1px;
}
#sidenav a:hover { background: rgba(255,255,255,.07); color: #fff; }
#sidenav a.active { background: var(--side-active); color: #fff; font-weight: bold; }
#sidenav .cnt { margin-left: auto; font-size: 11px; background: rgba(255,255,255,.13); border-radius: 9px; padding: 1px 7px; }
#sidenav a.active .cnt { background: rgba(255,255,255,.25); }
#sidenav .ico { width: 18px; text-align: center; flex-shrink: 0; }
#sidefoot { padding: 10px; border-top: 1px solid rgba(255,255,255,.09); }
#sidefoot a, #sidefoot button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; color: var(--side-text);
  font-size: 13px; padding: 8px 10px; border-radius: 8px; background: none; border: none; cursor: pointer; font-family: inherit;
}
#sidefoot a:hover, #sidefoot button:hover { background: rgba(255,255,255,.07); color: #fff; }
#scrim { display: none; }

/* ---- 上部バー ---- */
#mainbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 26px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
#menu-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); padding: 4px 8px; }
#search {
  flex: 1; max-width: 480px; font-size: 14px; padding: 9px 16px; border: 1px solid var(--line);
  border-radius: 22px; background: var(--bg); font-family: inherit;
}
#search:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(36,112,179,.12); }
#bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.view-toggle { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle button { border: none; background: var(--card); padding: 6px 11px; cursor: pointer; font-size: 14px; color: var(--muted); }
.view-toggle button.on { background: var(--accent); color: #fff; }

/* ---- 見出し ---- */
h1 { font-size: 20px; margin: 4px 0 18px; }
h2.sec {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); font-weight: bold;
  margin: 26px 0 12px; letter-spacing: .03em;
}
h2.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
h2.sec .cnt { font-weight: normal; font-size: 12px; }
.muted { color: var(--muted); font-size: 12.5px; }

/* ---- サービスカード ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.svc-card {
  position: relative; display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 15px 13px; color: inherit;
  box-shadow: var(--shadow); transition: box-shadow .16s, transform .16s, border-color .16s;
}
.svc-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); border-color: #c6d3de; text-decoration: none; }
.svc-body { min-width: 0; flex: 1; }
.svc-card .name { font-weight: bold; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px; }
.svc-card .desc { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; }
.svc-card .meta { margin-top: 8px; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

.logo { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 5px; }
.logo-fallback {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: bold; font-size: 17px;
}
.logo-sm, .logo-fallback-sm { width: 26px; height: 26px; border-radius: 7px; font-size: 12px; padding: 3px; }

.pin-btn {
  position: absolute; top: 9px; right: 9px; background: none; border: none; cursor: pointer;
  font-size: 15px; color: #c9d4dd; padding: 3px; line-height: 1;
}
.pin-btn:hover { color: var(--pin); transform: scale(1.15); }
.pin-btn.on { color: var(--pin); }

.tag { display: inline-block; background: #e9f0f7; color: #3c618a; font-size: 10.5px; border-radius: 8px; padding: 2px 8px; }
.keyicon { font-size: 10.5px; color: #8a6d1a; background: #faf1d3; border-radius: 8px; padding: 2px 8px; }
.cat-chip { font-size: 10.5px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 2px 8px; }

/* ---- 一覧(リスト)表示 ---- */
.svc-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.svc-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; border-bottom: 1px solid #edf1f5; color: inherit; }
.svc-row:last-child { border-bottom: none; }
.svc-row:hover { background: #f7fafc; text-decoration: none; }
.svc-row .name { font-weight: bold; font-size: 13.5px; width: 220px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-row .desc { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc-row .pin-btn { position: static; }

/* ---- カード/フォーム/テーブル 共通 ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 14px 0 5px; font-weight: bold; }
input[type=text], input[type=password], input[type=url], textarea, select {
  width: 100%; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36,112,179,.12); }
textarea { min-height: 72px; resize: vertical; }

button, .btn {
  font-size: 13.5px; padding: 8px 17px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; font-family: inherit; color: var(--text); display: inline-block;
}
button:hover, .btn:hover { background: #f0f4f8; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--danger); border-color: #dfc0bc; }
button.danger:hover { background: #fbeeec; }
button.small { font-size: 12px; padding: 4px 11px; }
.btnrow { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; align-items: center; }

table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
th { background: #f4f7fa; color: #51636f; font-size: 11.5px; white-space: nowrap; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---- 詳細ページ ---- */
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h1 { margin: 0; }
.detail-head .logo { width: 52px; height: 52px; border-radius: 13px; }
.detail-head .logo-fallback { width: 52px; height: 52px; border-radius: 13px; font-size: 22px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.cred { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 15px 17px; margin-bottom: 10px; box-shadow: var(--shadow); }
.cred .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cred .label { font-weight: bold; font-size: 13.5px; }
.cred .secret { margin-top: 11px; background: #f6f9fb; border: 1px dashed #b9c8d4; border-radius: 9px; padding: 11px 13px; font-family: Consolas, monospace; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.cred .secret .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cred .secret .val { user-select: all; word-break: break-all; }
.countdown { font-size: 11px; color: #a05c17; }

/* ---- 通知 ---- */
.error { background: #fbeeec; color: #92382e; border: 1px solid #e9c6c1; border-radius: 9px; padding: 11px 13px; margin: 10px 0; font-size: 13.5px; }
.notice { background: #eaf5ea; color: #2c6b34; border: 1px solid #c4dfc6; border-radius: 9px; padding: 11px 13px; margin: 10px 0; font-size: 13.5px; }
#toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #24303a; color: #fff; padding: 10px 22px; border-radius: 22px; font-size: 13.5px; box-shadow: 0 6px 18px rgba(0,0,0,.3); z-index: 60; }

/* ---- ログイン ---- */
#authwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(150deg, #16283c 0%, #24466b 100%); }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h1 { color: #fff; text-align: center; font-size: 22px; margin-bottom: 20px; }
.auth-box .card { padding: 26px; }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; text-align: center; font-weight: bold; padding: 11px; }
.google-btn .g { font-weight: bold; background: linear-gradient(90deg, #4285F4 0%, #EA4335 30%, #FBBC05 55%, #34A853 80%); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 16px; }
.or-sep { display: flex; align-items: center; gap: 10px; color: #9aa7b1; font-size: 11.5px; margin: 16px 0 2px; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- スマホ ---- */
@media (max-width: 760px) {
  #sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; width: 250px; }
  #layout.side-open #sidebar { transform: none; }
  #layout.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  #menu-btn { display: block; }
  #mainbar { padding: 10px 12px; }
  main { padding: 16px 12px 60px; }
  .grid { grid-template-columns: 1fr; }
  .svc-row .name { width: auto; flex-shrink: 1; }
  .svc-row .desc { display: none; }
  .kv { grid-template-columns: 82px 1fr; }
}
