:root{
  --navy:#0B1B3A; --navy2:#122A52;
  --orange:#FF7819; --orange2:#FF944D;
  --bg:#F6F7F9; --card:#fff;
  --ring:rgba(11,27,58,.12); --text:#0f172a;
  --muted:#64748b; --muted2:#94a3b8;
  --shadow:0 10px 20px rgba(2,6,23,.06);
  --radius:18px;
  --btn-h:36px;
  --btn-h-sm:32px;
  --btn-h-toolbar:34px;
}
*{box-sizing:border-box;margin:0;padding:0;}
html,body{min-height:100%;background:var(--bg);color:var(--text);}
body{font-family:ui-sans-serif,system-ui,-apple-system,"Hiragino Kaku Gothic ProN","Noto Sans JP","Yu Gothic",sans-serif;font-size:14px;line-height:1.6;}

.housing-wrap,.housing-wrap *{box-sizing:border-box;font-family:inherit;}
.housing-wrap a{text-decoration:none;color:inherit;}
.housing-wrap button{margin:0;background:none;border:none;cursor:pointer;line-height:inherit;font-size:inherit;font-family:inherit;}

.bg-glow{position:fixed;inset:0;pointer-events:none;z-index:0;}
.glow1{position:absolute;left:50%;top:-120px;width:500px;height:500px;transform:translateX(-50%);border-radius:999px;filter:blur(48px);background:radial-gradient(circle,rgba(255,106,42,.15),transparent 60%);}
.glow2{position:absolute;right:-120px;top:-100px;width:580px;height:580px;border-radius:999px;filter:blur(60px);background:radial-gradient(circle,rgba(11,27,58,.12),transparent 60%);}
.housing-wrap{position:relative;z-index:1;max-width:1200px;margin:0 auto;padding:24px 16px 80px;}

.header{display:flex;gap:12px;align-items:center;justify-content:space-between;margin-bottom:20px;flex-wrap:wrap;}
.brand{display:flex;gap:12px;align-items:center;}
.logo{
  width:48px;height:40px;padding:4px 8px;border-radius:16px;
  background:#fff;box-shadow:var(--shadow);border:1px solid var(--ring);
  display:flex;align-items:center;justify-content:center;
  font-weight:900;font-size:13px;color:var(--navy);
}
.title small{display:block;color:var(--muted);font-weight:700;font-size:11px;letter-spacing:.05em;text-transform:uppercase;}
.title h1{font-size:20px;color:var(--navy);font-weight:900;}
.header-btns{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.auth-header{display:inline-flex;align-items:center;gap:6px;flex-wrap:wrap;}
.auth-user-label{font-size:11px;font-weight:800;color:var(--navy);max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}

.housing-wrap .btn,.auth-gate .btn{
  all:unset;box-sizing:border-box;display:inline-flex!important;align-items:center!important;justify-content:center!important;
  gap:6px!important;min-height:var(--btn-h-sm)!important;padding:0 12px!important;border-radius:10px!important;
  font-weight:800!important;font-size:12px!important;cursor:pointer!important;line-height:1.2!important;
  font-family:inherit!important;
}
.housing-wrap .btn-outline,.auth-gate .btn-outline{background:#fff!important;border:1px solid var(--ring)!important;color:var(--navy)!important;}
.housing-wrap .btn-outline:hover,.auth-gate .btn-outline:hover{background:#f8fafc!important;}
.housing-wrap .btn-orange,.auth-gate .btn-orange{background:var(--orange)!important;color:#fff!important;border:1px solid var(--orange)!important;}

.filter-bar{
  display:flex;flex-wrap:wrap;gap:12px 16px;align-items:flex-end;
  margin-bottom:18px;padding:14px 16px;background:var(--card);border:1px solid var(--ring);
  border-radius:var(--radius);box-shadow:var(--shadow);
}
.filter-field{display:flex;flex-direction:column;gap:4px;min-width:200px;}
.filter-field label{font-size:11px;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;}
.filter-field select{
  border:1px solid var(--ring);border-radius:10px;padding:8px 12px;font-size:13px;font-weight:700;color:var(--navy);
  background:#fff;min-height:40px;cursor:pointer;font-family:inherit;
}
.filter-field input[type=month]{
  border:1px solid var(--ring);border-radius:10px;padding:8px 12px;font-size:13px;font-weight:700;color:var(--navy);
  background:#fff;min-height:40px;font-family:inherit;
}
#data-status{font-size:12px;color:var(--muted);font-weight:600;}
.data-error{
  margin-bottom:12px;padding:10px 14px;background:#fef2f2;border:1px solid #fecaca;border-radius:12px;
  color:#b91c1c;font-size:13px;font-weight:600;
}
.data-error[hidden]{display:none!important;}

.charts-grid{
  display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:20px;
}
@media(max-width:900px){.charts-grid{grid-template-columns:1fr;}}

.chart-card{
  background:var(--card);border:1px solid var(--ring);border-radius:var(--radius);
  box-shadow:var(--shadow);padding:14px 16px 12px;
}
.chart-card h2{font-size:14px;font-weight:900;color:var(--navy);margin-bottom:8px;}
.starts-summary{
  margin:0 0 10px;
  padding:10px 12px;
  border-radius:12px;
  background:linear-gradient(135deg, rgba(11,27,58,.06), rgba(255,120,25,.08));
  border:1px solid rgba(11,27,58,.1);
  font-size:13px;
  font-weight:700;
  color:var(--navy);
  line-height:1.45;
}
.starts-summary-main{
  font-size:22px;
  font-weight:900;
  letter-spacing:.01em;
  color:var(--navy);
}
.starts-summary-sub{
  font-size:13px;
  color:var(--muted);
  font-weight:700;
}
.starts-summary-diff{
  display:inline-block;
  margin-left:6px;
  padding:2px 8px;
  border-radius:999px;
  font-size:13px;
  font-weight:900;
  border:1px solid transparent;
}
.starts-summary-diff.up{
  color:#065f46;
  background:#d1fae5;
  border-color:#6ee7b7;
}
.starts-summary-diff.down{
  color:#991b1b;
  background:#fee2e2;
  border-color:#fecaca;
}
.chart-canvas-wrap{position:relative;height:280px;}

.table-card{
  background:var(--card);border:1px solid var(--ring);border-radius:var(--radius);
  box-shadow:var(--shadow);padding:14px 16px 18px;
}
.table-card h2{font-size:14px;font-weight:900;color:var(--navy);margin-bottom:12px;}
.table-fy-label{font-size:12px;font-weight:700;color:var(--muted);margin-left:6px;}
.table-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;}
#stats-table{width:100%;border-collapse:collapse;font-size:12px;white-space:nowrap;}
#stats-table th,#stats-table td{
  border-bottom:1px solid var(--ring);padding:8px 10px;text-align:right;
}
#stats-table th:first-child,#stats-table td:first-child{text-align:left;font-weight:700;}
#stats-table th{
  background:#f8fafc;font-weight:800;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.03em;
  position:sticky;top:0;z-index:1;
}
.col-prev{color:#94a3b8;}
.col-yoy{font-weight:700;}
.yoy-up{color:#059669;}
.yoy-down{color:#dc2626;}
.tfoot-row td{
  border-top:2px solid var(--navy);border-bottom:none;
  font-weight:900;background:#f8fafc;
}

.modal-bg{
  position:fixed;inset:0;z-index:500;
  background:rgba(15,23,42,.5);backdrop-filter:blur(4px);
  display:flex;align-items:center;justify-content:center;padding:20px 16px;
}
.modal-bg[hidden]{display:none!important;}
.modal-card{
  width:100%;max-width:680px;max-height:calc(100vh - 60px);
  background:var(--card);border-radius:var(--radius);
  border:1px solid var(--ring);box-shadow:0 24px 64px rgba(2,6,23,.18);
  display:flex;flex-direction:column;overflow:hidden;
}
.modal-header{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px 20px 12px;border-bottom:1px solid var(--ring);flex-shrink:0;
}
.modal-header h2{font-size:16px;font-weight:900;color:var(--navy);}
.modal-close{
  all:unset;cursor:pointer;font-size:22px;line-height:1;color:var(--muted);
  width:32px;height:32px;display:flex;align-items:center;justify-content:center;
  border-radius:8px;
}
.modal-close:hover{background:#f1f5f9;color:var(--text);}
.modal-body{padding:18px 20px 22px;overflow-y:auto;flex:1;}
.settings-section h3{font-size:14px;font-weight:900;color:var(--navy);margin-bottom:6px;}
.upload-desc{font-size:12px;color:var(--muted);margin-bottom:14px;line-height:1.55;}

.upload-pair{
  padding:12px;margin-bottom:10px;background:#f8fafc;
  border:1px solid var(--ring);border-radius:12px;
}
.upload-pair-header{
  display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:8px;
}
.upload-pair-label{font-size:10px;font-weight:700;color:var(--orange);}
.upload-ym-label{
  display:flex;align-items:center;gap:6px;
  font-size:11px;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;
}
.upload-ym-input{
  font-size:13px;font-family:inherit;font-weight:700;color:var(--navy);
  padding:4px 8px;border:1px solid var(--ring);border-radius:8px;
  background:#fff;min-width:140px;
}
.upload-ym-input:focus{outline:2px solid var(--navy);outline-offset:1px;}
.upload-ym-detected{font-size:11px;color:#6b7280;font-weight:600;}
.upload-ym-warn{color:#b45309;}
.upload-pair-files{
  display:grid;grid-template-columns:1fr 1fr;gap:10px;
}
@media(max-width:600px){.upload-pair-files{grid-template-columns:1fr;}}
.upload-field{display:flex;flex-direction:column;gap:4px;}
.upload-field label{font-size:11px;font-weight:800;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;}
.upload-hint{font-weight:600;color:var(--muted2);font-size:10px;margin-left:6px;text-transform:none;letter-spacing:0;}
.upload-field input[type=file]{
  font-size:12px;font-family:inherit;padding:8px;border:1px dashed var(--ring);
  border-radius:10px;background:#fff;cursor:pointer;
}
.upload-field input[type=file]:hover{border-color:rgba(11,27,58,.25);background:#f5f7fa;}
.upload-pair-remove{
  all:unset;cursor:pointer;font-size:18px;color:var(--muted);
  width:28px;height:28px;display:flex;align-items:center;justify-content:center;
  border-radius:8px;margin-left:auto;
}
.upload-pair-remove:hover{background:#fee2e2;color:#b91c1c;}
.upload-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap;}
.upload-status{font-size:12px;color:var(--muted);font-weight:600;}
.upload-log{
  margin-top:10px;padding:10px 12px;background:#f0fdf4;border:1px solid #bbf7d0;
  border-radius:10px;font-size:12px;color:#166534;line-height:1.5;max-height:160px;overflow-y:auto;
}
.upload-log[hidden]{display:none!important;}
.btn-with-icon{gap:5px!important;}
.btn-with-icon .btn-ico{width:16px;height:16px;flex-shrink:0;}

.auth-gate{
  position:fixed;inset:0;z-index:400;
  background:rgba(15,23,42,.58);
  display:flex;align-items:center;justify-content:center;
  padding:20px 16px;
  backdrop-filter:blur(4px);
}
.auth-gate[hidden]{display:none!important;}
.auth-gate-card{
  width:100%;max-width:400px;
  background:var(--card);border-radius:var(--radius);
  border:1px solid var(--ring);box-shadow:0 24px 64px rgba(2,6,23,.2);
  padding:24px 22px;
}
.auth-gate-title{font-size:17px;font-weight:900;color:var(--navy);margin-bottom:10px;}
.auth-gate-text{font-size:13px;color:var(--muted);line-height:1.55;margin-bottom:18px;}
body.auth-gate-active{overflow:hidden;}
