/* =====================================================================
   Life OS - giao dien
   Thiet ke uu tien dien thoai, man hinh rong dung thanh ben
   ===================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --text: #16191d;
  --text-2: #646b75;
  --text-3: #9aa1ab;
  --primary: #2563eb;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --nav-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --border: #2a2f39;
    --text: #e8eaed;
    --text-2: #9aa1ab;
    --text-3: #6b727d;
    --primary: #5b8dff;
    --primary-soft: #1a2436;
    --danger: #f87171;
    --danger-soft: #2a1a1a;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }

/* ---------------------------------------------------------------------
   Khung man hinh
   --------------------------------------------------------------------- */
#app { height: 100%; }
.shell { height: 100%; display: flex; }

.outlet {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  -webkit-overflow-scrolling: touch;
}

.page { padding: 16px 16px 24px; max-width: 900px; margin: 0 auto; }
.page-title { margin-bottom: 14px; }

/* Thanh ben, chi hien tren man hinh rong */
.side { display: none; }

/* Thanh dieu huong duoi man hinh */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
}

.bottom-item {
  flex: 1; border: 0; background: none; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 10.5px; padding: 6px 2px; transition: color .15s;
}
.bottom-item.active { color: var(--primary); }
.bottom-item span { white-space: nowrap; }

/* Nut ghi nhanh */
.fab {
  position: fixed; right: 16px; z-index: 45;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: transform .15s;
}
.fab:active { transform: scale(.93); }

/* ---------------------------------------------------------------------
   Man hinh rong
   --------------------------------------------------------------------- */
@media (min-width: 840px) {
  .bottom, .fab { display: none; }
  .outlet { padding-bottom: 24px; }

  .side {
    display: flex; flex-direction: column; gap: 2px;
    width: 216px; flex-shrink: 0; padding: 16px 10px;
    background: var(--surface); border-right: 1px solid var(--border);
    overflow-y: auto;
  }
  .side-logo {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 10px 16px; color: var(--primary); font-weight: 700; font-size: 16px;
  }
  .side-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--text-2); text-align: left;
    transition: background .12s, color .12s;
  }
  .side-item:hover { background: var(--surface-2); color: var(--text); }
  .side-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  .page { padding: 24px 28px 32px; }
}

/* ---------------------------------------------------------------------
   Man hinh dang nhap
   --------------------------------------------------------------------- */
.auth-screen {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px 18px;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 30px 24px; box-shadow: var(--shadow); text-align: center;
}
.auth-logo {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.auth-sub { color: var(--text-2); font-size: 13.5px; margin: 6px 0 22px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.auth-msg { color: var(--danger); font-size: 13px; min-height: 18px; }
.link-btn {
  border: 0; background: none; color: var(--primary);
  font-size: 13.5px; padding: 6px; text-align: center;
}

/* ---------------------------------------------------------------------
   Truong nhap lieu
   --------------------------------------------------------------------- */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.field-hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 5px; }

.input {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus {
  outline: 0; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
select.input { appearance: none; background-image: none; }

/* ---------------------------------------------------------------------
   Nut bam
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 14.5px; font-weight: 550;
  transition: background .12s, opacity .12s;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: none; border-style: dashed; color: var(--text-2); }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-3); transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------------
   The, danh sach, chuyen muc
   --------------------------------------------------------------------- */
.greet { margin-bottom: 18px; }
.greet p { color: var(--text-2); font-size: 13.5px; margin-top: 3px; }

.section-title { margin: 22px 0 10px; color: var(--text-2); font-size: 13px;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }

.card-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.card-pending { cursor: pointer; }
.card-hint { color: var(--text-3); font-size: 12.5px; margin: 5px 0 9px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-3);
  font-size: 11px; font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 4px 11px; border-radius: 20px; font-size: 12.5px;
  font-weight: 550; border: 1.5px solid; background: var(--surface);
}

.row-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 10px;
}
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row-title { flex: 1; font-weight: 550; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--text-3); font-size: 12.5px; flex-shrink: 0; }

.dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

.tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--surface-2); padding: 3px; border-radius: var(--radius-sm);
  overflow-x: auto;
}
.tab {
  flex: 1; padding: 7px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text-2); font-size: 13.5px;
  font-weight: 550; white-space: nowrap; transition: background .12s, color .12s;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.hint {
  color: var(--text-2); font-size: 13px; line-height: 1.55;
  margin-bottom: 14px;
}

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent; transition: transform .1s;
}
.swatch.on { border-color: var(--text); transform: scale(1.12); }

.version { color: var(--text-3); font-size: 12px; text-align: center; margin-top: 24px; }

/* ---------------------------------------------------------------------
   Tien do xay dung
   --------------------------------------------------------------------- */
.milestones { display: flex; flex-direction: column; gap: 1px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; }
.ms {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 13px; border-bottom: 1px solid var(--border);
  color: var(--text-2); font-size: 13.5px;
}
.ms:last-child { border-bottom: 0; }
.ms-dot {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-2); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700;
}
.ms-done { color: var(--text); }
.ms-done .ms-dot { background: var(--ok); color: #fff; }

/* ---------------------------------------------------------------------
   Trang thai rong, dang tai, chua xay dung
   --------------------------------------------------------------------- */
.empty { padding: 26px 16px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.empty .btn { margin-top: 12px; }

.loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 50px 16px; color: var(--text-3); font-size: 13.5px;
}
.spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.placeholder {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 22px; text-align: center;
}
.ph-icon {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--surface-2); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
}
.placeholder h2 { margin-bottom: 7px; }
.placeholder p { color: var(--text-2); font-size: 13.5px; max-width: 340px; margin: 0 auto; }

/* ---------------------------------------------------------------------
   Hop thoai
   --------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,17,21,.45); backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .18s;
}
.modal-overlay.show { opacity: 1; }

.modal {
  width: 100%; max-width: 460px; max-height: 88vh;
  background: var(--surface); border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(14px); transition: transform .2s;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.modal-overlay.show .modal { transform: translateY(0); }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; }
}

.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 14px 13px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot {
  display: flex; gap: 9px; padding: 13px 18px;
  border-top: 1px solid var(--border);
}
.modal-foot .btn { flex: 1; }

/* Menu truot len tren dien thoai */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15,17,21,.4);
  display: flex; align-items: flex-end;
  opacity: 0; transition: opacity .18s;
}
.sheet-overlay.show { opacity: 1; }
.sheet {
  width: 100%; background: var(--surface);
  border-radius: 16px 16px 0 0; padding: 10px 8px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.sheet-item {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 13px 14px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text); text-align: left; font-size: 15px;
}
.sheet-item:active { background: var(--surface-2); }

/* ---------------------------------------------------------------------
   Thong bao ngan
   --------------------------------------------------------------------- */
.toast-box {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 200;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 90vw;
}
@media (min-width: 840px) { .toast-box { bottom: 24px; } }

.toast {
  padding: 10px 16px; border-radius: 22px;
  background: #16191d; color: #fff; font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--danger); }
