/* h5-common.css - Loan Coach Unified Design System */
:root {
  --bg: #f4f7fb;
  --surface: #fff;
  --text: #17212b;
  --muted: #667382;
  --line: #e5ebf0;
  --primary: #F15A24;
  --primary-pressed: #D94E1E;
  --secondary: #1e40af;
  --soft: #FFF5F0;
  --warn: #b45309;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --radius: 8px;
  --radius-lg: 10px;
}

/* Mobile base styles */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 22px);
}

/* Page layout */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -14px -14px 14px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 12px;
  background: rgba(244,247,251,.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.account-user {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.status {
  min-height: 18px;
  color: var(--warn);
  font-size: 12px;
  margin-top: 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Components */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

.title {
  font-weight: 900;
  font-size: 17px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.title-sm {
  font-weight: 900;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.meta-line {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  max-width: 100%;
  border-radius: 999px;
  background: #f1f4f7;
  color: #596575;
  padding: 3px 8px;
  font-size: 12px;
}

.pill-hot {
  background: #fff3df;
  color: #9a5a12;
}

.pill-source {
  background: var(--soft);
  color: var(--primary);
  font-weight: 900;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.assigned {
  background: #fff3df;
  color: #9a5a12;
}

.badge.started {
  background: #e8f2ff;
  color: #11568f;
}

.badge.completed {
  background: #e7f6ef;
  color: #137044;
}

.badge.cancelled {
  background: #f1f3f5;
  color: #667382;
}

.remark {
  font-size: 13px;
  color: #35485a;
  background: #f8fafc;
  border-left: 3px solid #d8e4f0;
  padding: 8px;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 22px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* Buttons */
button, .btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  min-height: 44px;
  padding: 11px 12px;
  font-weight: 900;
  font-size: 15px;
  text-align: center;
  text-decoration: none;
  display: block;
  cursor: pointer;
  font-family: inherit;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .08s ease, box-shadow .08s ease, background .08s ease;
}

button:active, .btn:active {
  transform: scale(0.98);
}

button:disabled, .btn.disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

button:disabled:active, .btn.disabled:active {
  transform: none;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:active {
  background: var(--primary-pressed);
}

.btn-muted {
  background: #eef2f5;
  color: #26323f;
}

.link-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--secondary);
}

.secondary {
  background: #eef2f5;
  color: #26323f;
}

.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.mini-btn {
  appearance: none;
  border: 0;
  border-radius: var(--radius);
  min-height: 34px;
  min-width: 46px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f5;
  color: #26323f;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.link {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 900;
  font-size: 13px;
}

/* Inputs */
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #fff;
  min-height: 40px;
  font: 14px/1.4 inherit;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(241,90,36,.12);
}

input:disabled, select:disabled, textarea:disabled {
  background: #eef2f5;
  color: #7c8794;
}

/* Modal / Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 20;
  display: none;
  align-items: flex-end;
  padding: 0;
}

.overlay.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: 14px 14px 0 0;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px);
  box-shadow: 0 -8px 24px rgba(18,32,45,.08);
}

/* Dialogue page specific */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(18,32,45,.08);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
}

.msg {
  max-width: 88%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.msg.customer {
  align-self: flex-start;
  border-left: 4px solid var(--primary);
}

.msg.student {
  align-self: flex-end;
  background: #eef4ff;
  border-color: #d8e5ff;
}

/* Chips */
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  max-width: 100%;
  border-radius: 999px;
  background: #f1f4f7;
  color: #596575;
  padding: 3px 7px;
  font-size: 11px;
}

/* Turn timeline */
.turn {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

.turn.customer {
  border-left: 4px solid var(--primary);
}

.turn.student {
  border-left: 4px solid #4f79c7;
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Scrollbar styling for webkit */
.log, .timeline, .modal {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

.log::-webkit-scrollbar, .timeline::-webkit-scrollbar, .modal::-webkit-scrollbar {
  width: 4px;
}

.log::-webkit-scrollbar-thumb, .timeline::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

/* Responsive */
@media (max-width: 720px) {
  .app {
    padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 18px);
  }
  .top {
    margin: -12px -12px 12px;
    padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  }
  h1 {
    font-size: 20px;
  }
}
