:root {
  --shori-green: #1F7A5C;
  --shori-green-dark: #145C45;
  --shori-green-light: #E8F5EF;
  --shori-green-hover: #24906B;
  --text-primary: #1C2320;
  --text-secondary: #5C6B65;
  --text-muted: #93A19B;
  --border: #DCE5E1;
  --border-strong: #C2D0CA;
  --surface-0: #F4F8F6;
  --surface-1: #EEF5F1;
  --surface-2: #FFFFFF;
  --radius: 8px;
  --danger: #B3392C;
  --danger-bg: #FBEAE7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", Helvetica, Arial, sans-serif;
  background: var(--surface-0);
  color: var(--text-primary);
}

#app { max-width: 960px; margin: 0 auto; padding: 24px 20px 60px; }

h1, h2, h3 { font-weight: 500; margin: 0; }

button {
  font-family: inherit;
  font-size: 13px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-primary);
  cursor: pointer;
}
button:hover { background: var(--surface-1); }
button:active { transform: scale(0.98); }
button.primary {
  background: var(--shori-green);
  border-color: var(--shori-green);
  color: #fff;
}
button.primary:hover { background: var(--shori-green-hover); }
button.ghost { border-color: transparent; background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
}
textarea { height: auto; padding: 8px 10px; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--shori-green);
  box-shadow: 0 0 0 3px var(--shori-green-light);
}
label.field-label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--shori-green);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 15px;
}
.brand-name { font-weight: 500; font-size: 15px; }
.brand-user { font-size: 12px; color: var(--text-muted); }

.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  display: inline-block;
}
.badge.draft { background: var(--surface-1); color: var(--text-secondary); }
.badge.exported { background: var(--shori-green-light); color: var(--shori-green-dark); }
.badge.signed { background: #1F7A5C; color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface-1); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; color: var(--text-muted); font-weight: 400; padding: 8px 14px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--surface-1); }

.stepper { display: flex; gap: 6px; margin-bottom: 20px; }
.step-dot { flex: 1; text-align: center; cursor: pointer; }
.step-bar { height: 4px; border-radius: 2px; margin-bottom: 6px; background: var(--border); }
.step-bar.active, .step-bar.done { background: var(--shori-green); }
.step-label { font-size: 11px; color: var(--text-muted); }
.step-label.active { color: var(--shori-green-dark); font-weight: 500; }

.upload-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--shori-green-light);
  color: var(--shori-green-dark);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.upload-slot:hover { background: #DCEFE6; }
.upload-slot.done { background: var(--shori-green); color: #fff; }
.upload-slot input { display: none; }

.ocr-result {
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--shori-green-light);
  border: 1px solid var(--shori-green);
}
.ocr-result.low-confidence { background: #FDF3E7; border-color: #C98A2A; }

.attach-row {
  display: flex; align-items: center; justify-content: space-between;
  border: none; border-radius: var(--radius);
  padding: 12px 14px; font-size: 13px; margin-bottom: 8px;
  background: var(--shori-green-light); color: var(--shori-green-dark);
  font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.attach-row:hover { background: #DCEFE6; }
.attach-row.done { background: var(--shori-green); color: #fff; }

.sign-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--shori-green); color: #fff; border: none;
  border-radius: var(--radius); padding: 7px 12px; font-size: 12px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.15s;
}
.sign-btn:hover { background: var(--shori-green-hover); }
.sign-btn input { display: none; }

.help-text { font-size: 12px; color: var(--text-muted); margin: 4px 0 12px; }
.section-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.section-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.footer-actions { display: flex; justify-content: space-between; margin-top: 20px; }
.footer-actions .right { display: flex; gap: 8px; }

.login-wrap { max-width: 360px; margin: 80px auto; }
.login-wrap .card { text-align: left; }
.login-logo { width: 48px; height: 48px; border-radius: 10px; background: var(--shori-green); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 500; margin: 0 auto 16px; }

.error-text { color: var(--danger); font-size: 12px; margin-top: 6px; }
.hint-users { font-size: 11px; color: var(--text-muted); margin-top: 16px; text-align: center; line-height: 1.6; }
