/* ============================================================
   SolarSize — ระบบประเมินขนาดโซลาร์โรงเรียน
   Palette: navy #0f294a · teal #0d9488 · green #16a34a · amber #d97706
   ============================================================ */
:root {
  --navy: #0f294a;
  --navy-700: #1b3a5e;
  --teal: #0d9488;
  --teal-600: #0f766e;
  --green: #16a34a;
  --amber: #d97706;
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #1a2330;
  --ink-soft: #5a6573;
  --line: #e3e9f0;
  --radius: 18px;
  --shadow: 0 4px 24px rgba(15, 41, 74, .07);
  --shadow-lg: 0 12px 40px rgba(15, 41, 74, .13);
  --font: 'Sarabun', 'Prompt', system-ui, sans-serif;
  --font-head: 'Prompt', 'Sarabun', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 11px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--amber), #fbbf24);
  display: grid; place-items: center; color: #fff; font-size: 22px;
  box-shadow: 0 4px 14px rgba(217,119,6,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-head); font-size: 18px; color: var(--navy); font-weight: 700; }
.brand-text small { font-size: 11.5px; color: var(--ink-soft); }
.topnav { display: flex; gap: 6px; }
.topnav a {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 11px; font-size: 14.5px; font-weight: 500;
  color: var(--ink-soft); transition: .18s;
}
.topnav a:hover { background: #f1f5fa; color: var(--navy); }
.topnav a.active { background: var(--navy); color: #fff; }
.topnav a i { font-size: 17px; }
/* ปุ่มเข้าผู้ดูแล — ขอบจางๆ แยกจากเมนูหลัก */
.topnav a.nav-admin { border: 1.5px solid var(--line); color: var(--ink-soft); }
.topnav a.nav-admin:hover { border-color: var(--teal); background: #f0fdfa; color: var(--teal-600); }
.topnav a.nav-admin.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Flash ---------- */
.flash-wrap { max-width: 1180px; margin: 14px auto 0; padding: 0 18px; }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; font-size: 14.5px; font-weight: 500; }
.flash-success { background: #dcfce7; color: #15803d; }
.flash-warning { background: #fef3c7; color: #b45309; }
.flash-danger  { background: #fee2e2; color: #b91c1c; }

/* ---------- Hero ---------- */
.hero {
  background: radial-gradient(120% 140% at 80% 0%, var(--navy-700) 0%, var(--navy) 55%);
  color: #fff; padding: 40px 18px 84px; position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -60px; top: -40px; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(251,191,36,.22), transparent 70%); pointer-events: none;
}
.hero-inner { max-width: 1180px; margin: 0 auto; position: relative; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; margin-bottom: 16px;
}
.hero h1 {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(26px, 4.4vw, 42px);
  line-height: 1.18; letter-spacing: -.3px;
}
.hero h1 .hl { color: #fbbf24; }
.hero-sub { margin-top: 14px; font-size: clamp(15px, 2vw, 18px); color: #c8d4e4; max-width: 620px; }

/* ---------- Container ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 18px 40px; }
.page { min-height: 60vh; }

/* ---------- Mode switch ---------- */
.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: -56px; position: relative; z-index: 5;
}
.mode-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius);
  padding: 18px 20px; cursor: pointer; text-align: left; transition: .2s;
  box-shadow: var(--shadow); font-family: var(--font);
}
.mode-btn i { font-size: 26px; transition: .2s; }
.mode-btn .mode-title { font-family: var(--font-head); font-weight: 600; font-size: 17px; color: var(--ink); }
.mode-btn .mode-desc { font-size: 13px; color: var(--ink-soft); }
.mode-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* โหมด A — ใส่ค่าไฟเฉลี่ย = เขียว */
.mode-btn[data-mode="average"] { background: #f0fdf4; border-color: #bbf7d0; }
.mode-btn[data-mode="average"] i { color: var(--green); }
.mode-btn[data-mode="average"] .mode-title { color: #15803d; }
.mode-btn[data-mode="average"].active { border-color: var(--green); box-shadow: 0 6px 20px rgba(22,163,74,.22); }

/* โหมด B — กรอกตัวเลขจากบิล = ส้ม */
.mode-btn[data-mode="bill"] { background: #fff7ed; border-color: #fed7aa; }
.mode-btn[data-mode="bill"] i { color: var(--amber); }
.mode-btn[data-mode="bill"] .mode-title { color: #c2630a; }
.mode-btn[data-mode="bill"].active { border-color: var(--amber); box-shadow: 0 6px 20px rgba(217,119,6,.22); }

/* ---------- Work grid ---------- */
.work-grid {
  display: grid; grid-template-columns: 1fr 1.05fr; gap: 22px; margin-top: 22px; align-items: start;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; border: 1px solid var(--line);
}
.card-title {
  font-family: var(--font-head); font-weight: 600; font-size: 18px; color: var(--navy);
  display: flex; align-items: center; gap: 9px; margin-bottom: 18px;
}
.card-title i { color: var(--teal); font-size: 22px; }
/* ไอคอนหัวฟอร์มให้ตรงสีโหมด (เขียว/ส้ม) */
#form-average .card-title i { color: var(--green); }
#form-bill .card-title i { color: var(--amber); }

.form-col, .result-col { display: flex; flex-direction: column; gap: 18px; }
.mode-panel { display: none; }
.mode-panel.active { display: block; }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 14px; font-weight: 500; color: var(--ink); margin-bottom: 7px; }
.field-label em { color: var(--ink-soft); font-style: normal; font-weight: 400; font-size: 12.5px; }
.field input[type=text], .field input[type=number], .field select {
  width: 100%; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 16px; font-family: var(--font); color: var(--ink); background: #fff; transition: .16s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
.field-hint { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }
.field-emphasis .field-label strong { color: var(--teal-600); }
.input-money { position: relative; display: flex; align-items: center; }
.input-money input { padding-right: 92px; font-weight: 600; font-size: 18px; }
.input-money .suffix {
  position: absolute; right: 14px; font-size: 13px; color: var(--ink-soft); font-weight: 500; pointer-events: none;
}
.field-emphasis .input-money input { font-size: 22px; color: var(--navy); }

/* ---------- Months table (โหมดกรอกบิลหลายเดือน) ---------- */
.months-block { margin-bottom: 16px; }
.months-head {
  display: grid; grid-template-columns: 38px 1fr 1fr 1fr 30px; gap: 8px;
  padding: 0 2px 6px; font-size: 12px; color: var(--ink-soft); font-weight: 500;
}
.months-head em { font-style: normal; opacity: .75; font-size: 11px; }
.mh-month { text-align: center; }
.mh-del { }
#months-rows { display: flex; flex-direction: column; gap: 8px; }
.month-row {
  display: grid; grid-template-columns: 38px 1fr 1fr 1fr 30px; gap: 8px; align-items: center;
}
.mr-month {
  display: grid; place-items: center; height: 44px; border-radius: 10px;
  background: #fff7ed; color: #c2630a; font-family: var(--font-head); font-weight: 700; font-size: 15px;
}
.mr-in { position: relative; display: flex; align-items: center; }
.mr-in input {
  width: 100%; padding: 12px 38px 12px 11px; border: 1.5px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: var(--font); color: var(--navy); font-weight: 600; background: #fff; transition: .15s;
}
.mr-in input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,.12); }
.mr-in .mr-unit { position: absolute; right: 9px; font-size: 11px; color: var(--ink-soft); pointer-events: none; }
.mr-del {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: #cbd5e1; cursor: pointer; display: grid; place-items: center; font-size: 17px; transition: .15s;
}
.mr-del:hover { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.add-month-btn {
  margin-top: 10px; width: 100%; padding: 11px; border: 1.5px dashed #fed7aa; border-radius: 11px;
  background: #fff7ed; color: #c2630a; font-family: var(--font); font-weight: 600; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: .15s;
}
.add-month-btn:hover { background: #ffedd5; border-color: var(--amber); }

/* กล่องค่าเฉลี่ยสด */
.avg-box {
  margin-bottom: 16px; padding: 14px 16px; border-radius: 13px;
  background: linear-gradient(120deg, #f0fdf4, #ecfdf5); border: 1px solid #bbf7d0;
}
.avg-title {
  font-family: var(--font-head); font-size: 13.5px; font-weight: 600; color: #15803d;
  display: flex; align-items: center; gap: 7px; margin-bottom: 10px;
}
.avg-title i { font-size: 17px; }
.avg-count { font-family: var(--font); font-weight: 400; color: var(--ink-soft); font-size: 12.5px; }
.avg-figs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.avg-fig { text-align: center; background: rgba(255,255,255,.7); border-radius: 10px; padding: 9px 6px; }
.avg-lbl { display: block; font-size: 11px; color: var(--ink-soft); }
.avg-fig b { display: block; font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--green); line-height: 1.2; }
.avg-u { font-size: 10.5px; color: var(--ink-soft); }

.more-options { margin: 4px 0 16px; }
.more-options summary {
  cursor: pointer; font-size: 13.5px; color: var(--teal-600); font-weight: 500;
  list-style: none; display: inline-flex; align-items: center; gap: 5px; padding: 4px 0;
}
.more-options summary::-webkit-details-marker { display: none; }
.more-options[open] summary { margin-bottom: 10px; }

/* ---------- Buttons ---------- */
.btn-primary {
  width: 100%; padding: 15px; border: none; border-radius: 13px; cursor: pointer;
  background: linear-gradient(135deg, var(--teal), var(--teal-600));
  color: #fff; font-family: var(--font-head); font-weight: 600; font-size: 16.5px;
  display: flex; align-items: center; justify-content: center; gap: 9px; transition: .18s;
  box-shadow: 0 6px 18px rgba(13,148,136,.32);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(13,148,136,.42); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary i { font-size: 20px; }
.btn-secondary {
  width: 100%; padding: 13px; border: 1.5px solid var(--teal); border-radius: 12px; cursor: pointer;
  background: #fff; color: var(--teal-600); font-family: var(--font-head); font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: .16s;
}
.btn-secondary:hover { background: #f0fdfa; }
.link-btn {
  background: none; border: none; cursor: pointer; color: var(--teal-600);
  font-family: var(--font); font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 0;
}
.link-btn:hover { text-decoration: underline; }
.manual-link { text-align: center; margin-top: 14px; }

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative; border: 2px dashed #c5d2e2; border-radius: 14px;
  padding: 30px 18px; text-align: center; transition: .18s; background: #f8fafc; margin-bottom: 16px; cursor: pointer;
}
.dropzone.drag { border-color: var(--teal); background: #f0fdfa; }
.dropzone.has-file { border-style: solid; border-color: var(--teal); background: #f0fdfa; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dz-idle i { font-size: 42px; color: #9fb2c8; }
.dz-main { font-size: 15.5px; font-weight: 500; margin-top: 8px; }
.dz-main span { color: var(--teal-600); text-decoration: underline; }
.dz-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.dz-picked { display: flex; align-items: center; gap: 10px; justify-content: center; }
.dz-picked i { font-size: 28px; color: var(--teal); }
.dz-fname { font-weight: 600; font-size: 15px; color: var(--navy); word-break: break-all; }
.dz-clear {
  background: #fff; border: 1px solid var(--line); width: 30px; height: 30px; border-radius: 8px;
  cursor: pointer; color: var(--ink-soft); display: grid; place-items: center; flex-shrink: 0;
}
.dz-clear:hover { background: #fee2e2; color: #b91c1c; }

/* ---------- Manual fields ---------- */
.manual-fields { margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.manual-grid .field { margin-bottom: 0; }

/* ---------- Alert ---------- */
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; margin-bottom: 16px; font-size: 13.5px; }
.alert i { font-size: 22px; flex-shrink: 0; }
.alert-warn { background: #fef3c7; color: #92400e; }
.alert-info { background: #eff6ff; color: #1e40af; }
.alert-info i { color: var(--teal); }
.alert strong { display: block; margin-bottom: 2px; font-size: 14.5px; }
.alert p { margin: 0; }
.alert u { text-decoration-color: currentColor; }

/* ---------- Info card ---------- */
.info-card { background: linear-gradient(180deg, #f8fbff, #fff); }
.info-card h3 {
  font-family: var(--font-head); font-size: 15.5px; color: var(--navy); font-weight: 600;
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.info-card h3 i { color: var(--amber); font-size: 19px; }
.info-card p { font-size: 13.5px; color: var(--ink-soft); }
.info-card u { text-decoration-color: var(--teal); }

/* ---------- Result empty / loading ---------- */
.result-empty { text-align: center; padding: 56px 28px; }
.empty-art {
  width: 90px; height: 90px; margin: 0 auto 18px; border-radius: 26px;
  background: linear-gradient(135deg, #fef3c7, #fde68a); display: grid; place-items: center;
}
.empty-art i { font-size: 46px; color: var(--amber); }
.result-empty h3 { font-family: var(--font-head); color: var(--navy); font-size: 19px; margin-bottom: 8px; }
.result-empty p { color: var(--ink-soft); font-size: 14.5px; }

.result-loading { text-align: center; padding: 70px 28px; }
.spinner {
  width: 52px; height: 52px; margin: 0 auto 20px; border-radius: 50%;
  border: 5px solid #e3e9f0; border-top-color: var(--teal); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--ink-soft); font-size: 15px; font-weight: 500; }

/* ---------- Result card ---------- */
.result-card { padding: 0; overflow: hidden; animation: rise .4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.result-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 22px 24px 16px;
}
.result-eyebrow { font-size: 12.5px; font-weight: 600; color: var(--teal); text-transform: uppercase; letter-spacing: .4px; }
.result-head h2 { font-family: var(--font-head); font-size: 21px; color: var(--navy); font-weight: 700; margin-top: 2px; }
.btn-pdf {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 10px;
  background: #fee2e2; color: #dc2626; font-weight: 600; font-size: 14px; transition: .16s; flex-shrink: 0;
}
.btn-pdf:hover { background: #dc2626; color: #fff; }

/* headline kwp */
.headline-kwp {
  margin: 0 24px; padding: 22px 24px; border-radius: 16px;
  background: linear-gradient(120deg, var(--teal), var(--teal-600));
  color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  box-shadow: 0 10px 28px rgba(13,148,136,.3);
}
.hk-label { font-size: 13.5px; opacity: .9; }
.hk-value { display: block; font-family: var(--font-head); line-height: 1; margin: 4px 0; }
.hk-value strong { font-size: 46px; font-weight: 700; }
.hk-value em { font-size: 22px; font-style: normal; font-weight: 500; }
.hk-range { font-size: 13px; opacity: .9; }
.hk-side { display: flex; flex-direction: column; gap: 8px; }
.hk-chip {
  background: rgba(255,255,255,.16); padding: 8px 13px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; display: flex; align-items: center; gap: 7px; white-space: nowrap;
}

/* stat row */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 20px 24px 6px; }
.stat {
  border-radius: 14px; padding: 16px 14px; text-align: center; position: relative; overflow: hidden;
}
.stat-green { background: #f0fdf4; }
.stat-teal  { background: #f0fdfa; }
.stat-navy  { background: #f1f5fb; }
.stat-label { display: block; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.stat-value { display: block; font-family: var(--font-head); font-size: 27px; font-weight: 700; line-height: 1.2; }
.stat-green .stat-value { color: var(--green); }
.stat-teal .stat-value { color: var(--teal-600); }
.stat-navy .stat-value { color: var(--navy); }
.stat-unit { font-size: 12px; color: var(--ink-soft); }

/* offset viz */
.offset-viz { padding: 14px 24px 8px; }
.offset-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.offset-head > span:first-child { font-size: 13.5px; color: var(--ink-soft); font-weight: 500; }
.offset-pct { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--teal-600); }
.offset-bar {
  position: relative; height: 38px; background: #eef2f7; border-radius: 11px; overflow: hidden; display: flex; align-items: center;
}
.offset-fill {
  height: 100%; background: linear-gradient(90deg, var(--green), var(--teal));
  display: flex; align-items: center; padding-left: 12px; transition: width 1s cubic-bezier(.2,.8,.2,1);
  min-width: 60px;
}
.offset-fill-label { color: #fff; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.offset-rest-label { position: absolute; right: 12px; font-size: 12px; color: var(--ink-soft); }

/* detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 16px 24px 8px; }
.detail-block h4 {
  font-family: var(--font-head); font-size: 13.5px; color: var(--navy); font-weight: 600;
  display: flex; align-items: center; gap: 6px; margin-bottom: 9px; padding-bottom: 7px; border-bottom: 1px solid var(--line);
}
.detail-block h4 i { color: var(--teal); font-size: 16px; }
.dl { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; font-size: 13px; gap: 8px; }
.dl span { color: var(--ink-soft); }
.dl b { color: var(--ink); font-weight: 600; text-align: right; }

/* ocr readout */
.ocr-readout { margin: 12px 24px; padding: 16px; background: #f6f9fd; border-radius: 13px; border: 1px solid var(--line); }
.ocr-readout h4 {
  font-family: var(--font-head); font-size: 14px; color: var(--navy); font-weight: 600;
  display: flex; align-items: center; gap: 7px; margin-bottom: 11px;
}
.ocr-readout h4 i { color: var(--teal); font-size: 18px; }
.ocr-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.ocr-tag {
  background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 6px 11px; font-size: 12.5px;
  display: inline-flex; gap: 6px; align-items: center;
}
.ocr-tag b { color: var(--navy); font-weight: 700; }
.ocr-tag.conf-high  { border-color: #86efac; }
.ocr-tag.conf-low   { border-color: #fcd34d; }
.ocr-note { font-size: 12.5px; color: var(--ink-soft); margin-top: 9px; }

/* notes */
.notes-box { margin: 8px 24px; display: flex; flex-direction: column; gap: 8px; }
.note-item {
  display: flex; gap: 9px; padding: 11px 14px; border-radius: 11px; font-size: 13px; line-height: 1.5;
}
.note-item i { font-size: 17px; flex-shrink: 0; margin-top: 1px; }
.note-warn { background: #fffbeb; color: #92400e; }
.note-warn i { color: var(--amber); }
.note-info { background: #f1f5fb; color: var(--ink-soft); }
.note-info i { color: var(--navy); }

.disclaimer {
  margin: 8px 24px 24px; padding: 13px 16px; background: #f8fafc; border-radius: 11px;
  font-size: 12px; color: var(--ink-soft); display: flex; gap: 8px; line-height: 1.5;
}
.disclaimer i { font-size: 16px; flex-shrink: 0; color: var(--ink-soft); }

/* ---------- Footer ---------- */
.site-footer { text-align: center; padding: 28px 18px; color: var(--ink-soft); font-size: 13px; }
.site-footer .muted { font-size: 12px; opacity: .8; margin-top: 4px; }
.footer-admin { margin-top: 10px; opacity: 1; }
.footer-admin a { color: var(--teal-600); font-weight: 500; }
.footer-admin a:hover { text-decoration: underline; }

/* ---------- Settings page ---------- */
.settings-wrap { max-width: 760px; margin: 28px auto; }
.settings-intro { color: var(--ink-soft); font-size: 14.5px; margin-bottom: 20px; }
.rate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.rate-grid .field-default { font-size: 11.5px; color: var(--ink-soft); margin-top: 5px; display: block; }
.settings-actions { display: flex; gap: 12px; margin-top: 22px; }
.settings-actions .btn-primary { width: auto; flex: 1; }
.btn-ghost {
  padding: 15px 22px; border: 1.5px solid var(--line); border-radius: 13px; background: #fff;
  color: var(--ink-soft); font-family: var(--font-head); font-weight: 600; cursor: pointer; font-size: 15px;
}
.btn-ghost:hover { border-color: #fca5a5; color: #dc2626; }
.tariff-note {
  background: #f1f5fb; border-radius: 13px; padding: 16px 18px; margin-bottom: 22px; font-size: 13.5px; color: var(--ink-soft);
  display: flex; gap: 11px;
}
.tariff-note i { font-size: 22px; color: var(--navy); flex-shrink: 0; }

/* ---------- Login ---------- */
.login-wrap { max-width: 420px; margin: 50px auto; }
.login-card { text-align: center; padding: 36px 28px; }
.login-icon {
  width: 70px; height: 70px; margin: 0 auto 18px; border-radius: 20px;
  background: linear-gradient(135deg, var(--navy), var(--navy-700));
  display: grid; place-items: center;
}
.login-icon i { font-size: 36px; color: #fff; }
.login-card h1 { font-family: var(--font-head); font-size: 22px; color: var(--navy); }
.login-sub { color: var(--ink-soft); font-size: 14px; margin: 6px 0 22px; }
.login-card .field { text-align: left; }
.login-card .btn-primary { margin-top: 6px; }

/* ---------- Admin ---------- */
.admin-page { padding-top: 26px; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.admin-head h1 { font-family: var(--font-head); font-size: 24px; color: var(--navy); display: flex; align-items: center; gap: 9px; }
.admin-head h1 i { color: var(--teal); }
.admin-head .muted { color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }
.admin-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-mini {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px;
  background: var(--teal); color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.btn-mini:hover { background: var(--teal-600); }
.btn-mini-ghost { background: #fff; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-mini-ghost:hover { background: #f1f5fa; color: var(--navy); }
.btn-mini-pdf { background: #fee2e2; color: #dc2626; }
.btn-mini-pdf:hover { background: #dc2626; color: #fff; }

.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.astat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 14px;
  text-align: center; box-shadow: var(--shadow);
}
.astat-num { display: block; font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.astat-lbl { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

.top-card { margin-bottom: 18px; padding: 18px 20px; }
.top-card h3 { font-family: var(--font-head); font-size: 15px; color: var(--navy); display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.top-card h3 i { color: var(--amber); }
.top-list { display: flex; flex-direction: column; gap: 8px; }
.top-item { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.top-item:last-child { border-bottom: none; }
.top-name { font-weight: 600; color: var(--ink); font-size: 14.5px; }
.top-meta { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }

.admin-search { position: relative; display: flex; align-items: center; margin-bottom: 16px; }
.admin-search i { position: absolute; left: 14px; color: var(--ink-soft); font-size: 18px; }
.admin-search input {
  width: 100%; padding: 12px 14px 12px 42px; border: 1.5px solid var(--line); border-radius: 12px;
  font-size: 15px; font-family: var(--font); background: #fff;
}
.admin-search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
.search-clear { position: absolute; right: 12px; color: var(--ink-soft); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; }
.search-clear:hover { background: #fee2e2; color: #b91c1c; }

.usage-list { display: flex; flex-direction: column; gap: 11px; }
.usage-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow); position: relative;
}
.usage-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding-right: 28px; }
.usage-school { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.usage-name { font-family: var(--font-head); font-weight: 600; font-size: 16px; color: var(--navy); }
.usage-mode { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.mode-ค่าไฟเฉลี่ย { background: #f0fdfa; color: var(--teal-600); }
.mode-ตัวเลขบิล { background: #eff6ff; color: #1e40af; }
.mode-อัปโหลดบิล { background: #eff6ff; color: #1e40af; }
.mode-กรอกเอง { background: #f1f5fb; color: var(--navy); }
.usage-time { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.usage-figures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ufig { background: #f8fafc; border-radius: 10px; padding: 9px 6px; text-align: center; }
.ufig-primary { background: #f0fdf4; }
.ufig-val { display: block; font-family: var(--font-head); font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.ufig-primary .ufig-val { color: var(--green); }
.ufig-lbl { display: block; font-size: 10.5px; color: var(--ink-soft); margin-top: 1px; }

/* แถบตัวเลขดิบที่กรอก (ไว้ตรวจการคำนวณ) */
.usage-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px;
  margin-top: 10px; padding: 9px 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px;
}
.ui-tag { font-size: 11.5px; font-weight: 600; color: #b45309; display: inline-flex; align-items: center; gap: 4px; }
.ui-tag i { font-size: 14px; }
.ui-val { font-size: 12.5px; color: var(--ink-soft); }
.ui-val b { color: var(--navy); font-weight: 700; font-family: var(--font-head); }
.ui-muted { color: #9aa6b2; margin-left: auto; }
.usage-del { position: absolute; top: 12px; right: 12px; }
.usage-del button {
  background: none; border: none; cursor: pointer; color: #cbd5e1; font-size: 18px; padding: 2px;
}
.usage-del button:hover { color: #dc2626; }

.empty-usage { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-usage i { font-size: 44px; color: #cbd5e1; display: block; margin-bottom: 10px; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); opacity: 0; transition: .3s; z-index: 200; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .work-grid { grid-template-columns: 1fr; }
  /* ฟอร์มมาก่อน ผลตามหลัง (กดแล้ว JS เลื่อนลงไปหาผลเอง) */
  .form-col { order: 1; }
  .result-col { order: 2; }
  /* ซ่อนกล่อง placeholder ว่างบนมือถือ (ฟอร์มอยู่ตรงนั้นแล้ว) */
  .result-empty { display: none; }
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .detail-block { padding-bottom: 4px; }
}
@media (max-width: 600px) {
  /* header กระชับ — ซ่อนคำบรรยายแบรนด์ที่ตกบรรทัด */
  .topbar-inner { padding: 9px 14px; }
  .brand-mark { width: 36px; height: 36px; font-size: 20px; border-radius: 11px; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 17px; }
  .topnav { gap: 2px; }
  .topnav a { padding: 8px 10px; }
  .topnav a span { display: none; }
  .topnav a i { font-size: 19px; }

  .hero { padding: 26px 16px 72px; }
  .hero-badge { font-size: 12px; padding: 5px 12px; margin-bottom: 13px; }
  .hero h1 { font-size: 27px; line-height: 1.22; }
  .hero-sub { font-size: 14.5px; margin-top: 11px; }

  .mode-switch { grid-template-columns: 1fr; margin-top: -54px; gap: 10px; }
  .mode-btn { flex-direction: row; align-items: center; gap: 12px; padding: 14px 16px; }
  .mode-btn i { font-size: 26px; flex-shrink: 0; }
  .mode-btn .mode-title { font-size: 16px; }
  .mode-btn .mode-desc { font-size: 12px; }

  .work-grid { gap: 16px; margin-top: 18px; }
  .card { padding: 18px 16px; }
  .card-title { font-size: 17px; }

  .rate-grid { grid-template-columns: 1fr; }
  .manual-grid { grid-template-columns: 1fr; }

  /* ตารางเดือนบนมือถือ — แต่ละเดือนเป็นการ์ดเล็ก (หัวเดือน + 3 ช่องเรียง) */
  .months-head { display: none; }
  #months-rows { gap: 13px; }
  .month-row {
    display: block; position: relative;
    background: #fffdfa; border: 1px solid #fef0e0; border-radius: 12px; padding: 44px 12px 12px;
  }
  /* หัวเดือน = แถบเต็มด้านบนการ์ด */
  .mr-month {
    position: absolute; top: 0; left: 0; right: 0; width: auto; height: 34px;
    display: flex; align-items: center; padding: 0 14px; border-radius: 12px 12px 0 0;
    background: #fff7ed; color: #c2630a; font-family: var(--font-head); font-weight: 700;
    font-size: 13px; justify-content: flex-start; border-bottom: 1px solid #fef0e0;
  }
  .mr-month::before { content: "เดือนที่ "; font-weight: 600; margin-right: 3px; }
  .mr-month .mr-num { display: inline; }
  .month-row .mr-in { margin-bottom: 9px; }
  .month-row .mr-in:last-of-type { margin-bottom: 0; }
  .mr-in input { padding: 13px 44px 13px 12px; font-size: 16px; }
  .mr-in .mr-unit { font-size: 12px; right: 12px; }
  .m-on::placeholder { color: #c2630a; opacity: .65; }
  .mr-del {
    position: absolute; top: 4px; right: 6px; width: 26px; height: 26px;
    background: transparent; border: none; color: #d8a679;
  }
  .mr-del:hover { background: #fee2e2; color: #dc2626; }
  .avg-figs { gap: 7px; }
  .avg-fig b { font-size: 16px; }

  /* result card เต็มความกว้าง ขอบเสมอ */
  .result-card { padding: 0; }
  .result-head { padding: 18px 16px 14px; }
  .result-head h2 { font-size: 19px; }
  .headline-kwp { flex-direction: column; align-items: flex-start; gap: 13px; margin: 0 16px; padding: 18px; }
  .hk-value strong { font-size: 42px; }
  .hk-side { flex-direction: row; gap: 8px; flex-wrap: wrap; }
  .stat-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 18px 16px 4px; }
  .stat { padding: 13px 8px; text-align: center; }
  .stat-value { font-size: 21px; }
  .stat-label { font-size: 11px; }
  .stat-unit { font-size: 11px; }
  .offset-viz { padding: 12px 16px 6px; }
  .detail-grid { grid-template-columns: 1fr; gap: 6px; padding: 14px 16px 6px; }
  .notes-box { margin: 8px 16px; }
  .disclaimer { margin: 8px 16px 18px; }

  .settings-actions { flex-direction: column; }

  /* admin บนมือถือ */
  .admin-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .admin-head { flex-direction: column; gap: 12px; }
  .admin-actions { width: 100%; }
  .btn-mini { flex: 1; justify-content: center; }
  .usage-figures { grid-template-columns: 1fr 1fr; gap: 7px; }
  /* ชื่อ+เวลา ขึ้นบรรทัดใหม่ไม่ชนปุ่มลบ */
  .usage-main { flex-direction: column; align-items: flex-start; gap: 5px; }
  .usage-time { font-size: 11.5px; }
}
