/* =========================================================
   I'llony — Irony Console / Admin  ·  Light "paper + gold" theme
   ========================================================= */

:root {
  /* surfaces — warm off-white paper */
  --bg:        #f3eee4;
  --bg-grad:   #f6f1e8;
  --surface:   #fffdf9;
  --surface-2: #faf6ee;
  --surface-3: #f4eedf;

  /* ink */
  --ink:    #2b2720;
  --ink-2:  #6d6457;
  --ink-3:  #9d937f;
  --ink-4:  #b7ad97;

  /* hairlines */
  --line:   #ece4d4;
  --line-2: #f2ecdf;
  --line-3: #e2d7c0;

  /* gold accent */
  --gold:        #b58e3c;
  --gold-deep:   #8a6a1f;
  --gold-bright: #caa765;
  --gold-soft:   #f4ebd4;
  --gold-soft-2: #efe2c4;
  --gold-line:   #e3d2a4;

  /* semantic (muted, harmonised) */
  --rose:      #b0533f;  --rose-bg:  #f6e4dd;
  --amber:     #b1842d;  --amber-bg: #f5ead0;
  --green:     #5a8553;  --green-bg: #e4eddd;
  --blue:      #4f6f9a;  --blue-bg:  #e2e9f1;
  --plum:      #8a5783;  --plum-bg:  #efe2ed;
  --sage:      #6f8a5e;  --sage-bg:  #e6ecdd;

  --shadow-sm: 0 1px 2px rgba(60,48,24,.05);
  --shadow:    0 1px 2px rgba(60,48,24,.05), 0 10px 28px -14px rgba(70,54,22,.18);
  --shadow-lg: 0 2px 4px rgba(60,48,24,.06), 0 22px 48px -22px rgba(70,54,22,.28);

  --radius:    14px;
  --radius-sm: 9px;

  --sidebar-w: 248px;

  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sans: "Noto Sans JP", system-ui, -apple-system, sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 78% -8%, var(--bg-grad), transparent 60%),
    var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--gold-soft-2); }

/* ---------------------------------------------------------- layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------------------------------------------------------- sidebar */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  background: linear-gradient(180deg, #fffefb, #fbf6ec);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 16px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 14px;
}
.brand .mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, #d8b863, #b58e3c 55%, #936f25);
  color: #fffdf6;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 22px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), var(--shadow-sm);
}
.brand .name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: .2px;
  line-height: 1;
  color: var(--ink);
}
.brand .sub {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 4px;
}

.nav-group { margin-top: 14px; }
.nav-group:first-of-type { margin-top: 2px; }
.nav-label {
  font-size: 10.5px;
  letter-spacing: .16em;
  color: var(--ink-4);
  font-weight: 600;
  padding: 0 10px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: background .15s, color .15s;
}
.nav-item .ico { width: 18px; height: 18px; color: var(--ink-3); flex: none; transition: color .15s; }
.nav-item .txt { flex: 1; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item:hover .ico { color: var(--gold-deep); }

.nav-item.active {
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-weight: 700;
}
.nav-item.active .ico { color: var(--gold-deep); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.nav-count {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
}
.nav-count.warn { background: var(--rose-bg); color: var(--rose); }
.nav-item.active .nav-count { background: #fff; color: var(--gold-deep); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
}
.me-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  background: var(--gold-soft-2); color: var(--gold-deep);
  flex: none;
}
.me-card .nm { font-weight: 600; font-size: 13px; line-height: 1.2; }
.me-card .rl { font-size: 11px; color: var(--ink-3); }

/* ---------------------------------------------------------- main */
.main {
  padding: 0 30px 44px;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 20px 0 16px;
  margin-bottom: 8px;
  background:
    linear-gradient(180deg, var(--bg) 62%, rgba(243,238,228,0));
  backdrop-filter: blur(2px);
}
.page-h { display: flex; flex-direction: column; gap: 3px; }
.page-h h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.page-h .crumb { font-size: 12px; color: var(--ink-3); }
.page-h .crumb b { color: var(--gold-deep); font-weight: 600; }

.topbar .spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  width: 280px;
  padding: 9px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink-3);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within {
  border-color: var(--gold-line);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.search svg { width: 16px; height: 16px; flex: none; }
.search input {
  border: 0; outline: 0; background: transparent;
  font-family: var(--sans); font-size: 13px; color: var(--ink);
  width: 100%;
}
.search input::placeholder { color: var(--ink-3); }
.search kbd {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 6px; border-radius: 6px;
  background: var(--surface-3); color: var(--ink-3);
  border: 1px solid var(--line);
}

.icon-btn {
  position: relative;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 11px;
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--gold-deep); border-color: var(--gold-line); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rose); border: 2px solid var(--surface);
}
.date-chip {
  display: flex; flex-direction: column; align-items: flex-end;
  font-size: 12px; color: var(--ink-2); line-height: 1.25;
  padding-left: 4px;
}
.date-chip b { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------- grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}
.col-7 { grid-column: span 7; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-8 { grid-column: span 8; }

/* ---------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card-h {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-2);
}
.card-h .ttl {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 14.5px;
}
.card-h .ttl .gi {
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold-deep);
  flex: none;
}
.card-h .ttl .gi svg { width: 15px; height: 15px; }
.card-h .meta { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.card-h .grow { flex: 1; }
.card-action {
  font-size: 12.5px; font-weight: 600; color: var(--gold-deep);
  background: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 6px; border-radius: 7px;
  transition: background .15s;
}
.card-action:hover { background: var(--gold-soft); }
.card-body { padding: 8px 8px 10px; }
.card-body.pad { padding: 18px 20px 20px; }
.card-foot {
  padding: 11px 20px;
  border-top: 1px solid var(--line-2);
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 14px;
}

/* ---------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px;
  letter-spacing: .04em;
  font-weight: 600;
  color: var(--ink-3);
  text-align: left;
  padding: 6px 12px 10px;
}
thead th.num { text-align: right; }
tbody td {
  padding: 11px 12px;
  border-top: 1px solid var(--line-2);
  font-size: 13px;
  vertical-align: middle;
}
tbody td.num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:hover td:first-child { box-shadow: inset 2px 0 0 var(--gold); }

.cust { display: flex; flex-direction: column; }
.cust .nm { font-weight: 600; }
.cust .nm a { color: inherit; text-decoration: none; }
tbody tr:hover .cust .nm a { color: var(--gold-deep); }
.cust .rk { font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.ltv { font-weight: 700; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.dash { color: var(--ink-4); }

/* ---------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dt { width: 6px; height: 6px; border-radius: 50%; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }

.b-gold  { background: var(--gold-soft); color: var(--gold-deep); border-color: var(--gold-line); }
.b-rose  { background: var(--rose-bg);  color: var(--rose); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-blue  { background: var(--blue-bg);  color: var(--blue); }
.b-plum  { background: var(--plum-bg);  color: var(--plum); }
.b-sage  { background: var(--sage-bg);  color: var(--sage); }
.b-gray  { background: var(--surface-3); color: var(--ink-2); }

/* store chip */
.store {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 8px;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.store .dt { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.store.auto { background: transparent; color: var(--ink-3); border-style: dashed; font-weight: 500; }

/* care flag with hover hint */
.care { position: relative; cursor: help; }
.care .hint {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content; max-width: 220px;
  background: var(--ink); color: #fdf8ec;
  font-size: 11.5px; font-weight: 500; line-height: 1.45;
  padding: 8px 11px; border-radius: 9px;
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity .16s, transform .16s;
  z-index: 30;
}
.care .hint::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--ink);
}
.care:hover .hint { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------- routing list */
.rule-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 11px 12px;
  border-radius: 9px;
  transition: background .12s;
}
.rule-row:hover { background: var(--surface-2); }
.rule-row .cat { font-weight: 500; }
.rule-row .cat small { display: block; color: var(--ink-3); font-size: 11px; font-weight: 400; }

/* ---------------------------------------------------------- feature flags */
.flags { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.flag {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line-2);
}
.flag .info { flex: 1; min-width: 0; }
.flag .code {
  font-family: var(--mono); font-size: 11px; color: var(--gold-deep);
  font-weight: 600; letter-spacing: .02em;
}
.flag .ttl2 { font-weight: 600; font-size: 13px; }
.flag .desc { font-size: 11.5px; color: var(--ink-3); }

.toggle {
  --tw: 42px; --th: 24px;
  width: var(--tw); height: var(--th);
  border-radius: 999px;
  border: 0; padding: 0; cursor: pointer;
  background: #ddd3c0;
  position: relative; flex: none;
  transition: background .2s;
}
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .2s;
}
.toggle[aria-pressed="true"] {
  background: linear-gradient(180deg, #c9a44e, #b58e3c);
}
.toggle[aria-pressed="true"]::after { transform: translateX(18px); }

/* ---------------------------------------------------------- staff */
.staff-row td:first-child { font-weight: 600; }
.ago { color: var(--ink-3); font-size: 12px; }
.ago.live { color: var(--green); font-weight: 600; }
.ago .pulse {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin-right: 5px; vertical-align: 1px;
  box-shadow: 0 0 0 0 rgba(90,133,83,.5);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(90,133,83,.45); }
  70% { box-shadow: 0 0 0 6px rgba(90,133,83,0); }
  100% { box-shadow: 0 0 0 0 rgba(90,133,83,0); }
}

/* ---------------------------------------------------------- KPI */
.kpi-wrap { display: grid; grid-template-columns: 230px 1fr; gap: 0; }
.kpi-left { padding: 18px 20px; border-right: 1px solid var(--line-2); }
.kpi-tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--surface-3); padding: 4px; border-radius: 10px; }
.kpi-tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--ink-2);
  padding: 7px 4px; border-radius: 7px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.kpi-tab.active { background: var(--surface); color: var(--gold-deep); box-shadow: var(--shadow-sm); }

.kpi-big { font-size: 38px; font-weight: 700; letter-spacing: -.02em; font-family: var(--mono); line-height: 1; }
.kpi-big .u { font-size: 16px; color: var(--ink-3); font-weight: 500; }
.kpi-cap { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 5px; margin-top: 14px;
  font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.kpi-delta.up   { background: var(--green-bg); color: var(--green); }
.kpi-delta.down { background: var(--rose-bg); color: var(--rose); }

.chart { padding: 16px 18px 10px; min-width: 0; }
.chart svg { width: 100%; height: 180px; display: block; }
.chart .axis { font-family: var(--mono); font-size: 10px; fill: var(--ink-4); }

.kpi-table td { padding: 10px 20px; }
.kpi-table thead th { padding: 6px 20px; }
.target { color: var(--ink-3); }
.bar-cell { width: 120px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg,#cdaa55,#b58e3c); }

/* ---------------------------------------------------------- audit log */
.log-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  transition: background .12s;
}
.log-item:hover { background: var(--surface-2); }
.log-time { font-family: var(--mono); font-size: 12px; color: var(--ink-3); padding-top: 1px; }
.log-main { min-width: 0; }
.log-act {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink);
}
.log-act.sys { color: var(--blue); }
.log-target { font-size: 12px; color: var(--ink-3); }
.log-target .ar { color: var(--gold-deep); font-weight: 600; }
.log-who {
  display: inline-block; font-size: 11px; font-weight: 600; color: var(--ink-2);
  margin-left: 6px;
}
.log-flag { color: var(--rose); font-weight: 600; }

/* scrollbar */
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #e2d8c5; border-radius: 4px; }

@media (max-width: 1180px) {
  .col-7,.col-5,.col-4,.col-8 { grid-column: span 12; }
  .kpi-wrap { grid-template-columns: 1fr; }
  .kpi-left { border-right: 0; border-bottom: 1px solid var(--line-2); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .flags { grid-template-columns: 1fr; }
}
