:root {
  --green: #1a365d;
  --green-dark: #152b4a;
  --gold: #b08d57;
  --cream: #f6f5f4;
  --paper: #ffffff;
  --ink: #1b1319;
  --muted: #5c6570;
  --line: #e4ddd6;
  --danger: #c4452d;
  --ok: #1f8a5b;
  --warn: #dd8f3b;
  --shadow: 0 10px 30px rgba(26, 54, 93, 0.14);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
}

body {
  font-family: "Cairo", "Nunito", system-ui, sans-serif;
  padding: 0;
}

#app {
  max-width: 480px !important;
  width: 100% !important;
  margin: 0 auto !important;
  min-height: 100dvh;
  background: linear-gradient(180deg, #1a365d 0 158px, var(--cream) 158px);
  position: relative;
  padding-bottom: calc(96px + var(--safe-bottom));
  isolation: isolate;
  display: block !important;
  float: none !important;
}

[dir="ltr"] body {
  font-family: "Nunito", "Cairo", system-ui, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(10px + var(--safe-top)) 12px 12px;
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #fff;
  min-height: calc(68px + var(--safe-top));
  background: #1a365d;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(176, 141, 87, 0.55);
}

.brand > div {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.safari-hint {
  background: #fff8ea;
  color: #5c3d10;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  padding: 10px 12px;
  margin: 0;
  border-bottom: 1px solid #ead9b4;
}

.brand small {
  display: block;
  opacity: 0.82;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-btn,
.lang-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
  border-radius: 11px;
  padding: 0 12px;
  height: 38px;
  min-width: 48px;
  font: inherit;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.topbar-btn.logout {
  background: var(--gold);
  border-color: #c4a46e;
  color: #1a365d;
  min-width: 64px;
}

.screen {
  padding: 0 16px 16px;
}

.hero-card,
.card,
.app-tile,
.task,
.field,
.app-btn {
  border-radius: var(--radius);
}

.hero-card,
.card,
.task {
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 16px;
  margin-bottom: 14px;
}

.hero-card h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.app-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
}

.app-tile {
  background: var(--paper) !important;
  border: 1px solid #eee8df !important;
  box-shadow: var(--shadow);
  padding: 14px 12px !important;
  text-align: start !important;
  font: inherit !important;
  color: inherit !important;
  min-height: 124px;
  width: 100%;
  display: flex !important;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  border-radius: 18px !important;
}

.app-tile .icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.app-tile strong {
  display: block;
  font-size: 16px;
  line-height: 1.3;
}

.app-tile span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.icon svg {
  width: 26px;
  height: 26px;
}

.bg-green { background: #e7f4ef; color: var(--green); }
.bg-gold { background: #f6ecd9; color: #8a6a32; }
.bg-blue { background: #e8f1f8; color: #215f8a; }
.bg-red { background: #fdece8; color: var(--danger); }

.task {
  display: flex;
  gap: 12px;
  padding: 14px;
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  border: 0;
  width: 100%;
  font: inherit;
  text-align: start;
}

.task b { display: block; font-size: 15px; }
.task small { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
}

.badge.new { background: #e8f1f8; color: #215f8a; }
.badge.progress { background: #f6ecd9; color: #8a6a32; }
.badge.done { background: #e7f4ef; color: var(--ok); }
.badge.high { background: #fdece8; color: var(--danger); }

.app-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + var(--safe-bottom));
  width: min(456px, calc(100% - 16px));
  background: #fff;
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 8px 6px;
  box-shadow: 0 10px 30px rgba(26, 54, 93, 0.2);
  border: 1px solid #eee8df;
  border-radius: 22px;
  z-index: 40;
}

.app-nav button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 4px;
  min-width: 0;
  width: 100%;
  cursor: pointer;
  border-radius: 16px;
}

.app-nav button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav button.active {
  color: var(--green);
  background: #eef2f7;
}

.app-nav button.active svg {
  background: transparent;
  border-radius: 0;
}

.app-nav svg {
  width: 22px;
  height: 22px;
  padding: 0;
  box-sizing: content-box;
}

.app-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 0 !important;
  padding: 14px 16px !important;
  font: inherit !important;
  font-weight: 800 !important;
  background: var(--green) !important;
  color: #fff !important;
  margin-top: 10px;
  text-decoration: none !important;
  box-sizing: border-box;
  cursor: pointer;
  border-radius: var(--radius) !important;
  line-height: 1.2 !important;
}

.app-btn.secondary {
  background: #fff !important;
  color: var(--green) !important;
  border: 1.5px solid var(--green) !important;
}

.app-btn.ghost {
  background: transparent !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.35) !important;
  width: auto;
  margin: 0 auto;
}

.app-btn.warn { background: var(--warn) !important; }
.app-btn.ok { background: var(--ok) !important; }

input,
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin: 12px 0 6px;
}

.login {
  min-height: 100dvh;
  background: var(--green-dark);
  padding: calc(36px + var(--safe-top)) 20px 24px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login > img,
.login .store-icon {
  display: block;
  margin: 0 auto 12px;
}

.login h1 {
  margin: 0;
  font-size: 28px;
}

.login > p {
  margin: 8px 0 0;
  opacity: 0.85;
}

.login .panel {
  background: #fff;
  color: var(--ink);
  border-radius: 28px;
  padding: 22px 18px;
  margin-top: 22px;
  width: 100%;
  text-align: start;
}

.store-icon {
  width: 112px;
  height: 112px;
  border-radius: 28px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.login.store .panel .app-btn {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 18px;
  padding: 16px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.error {
  background: #fdece8;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
}

.detail p {
  color: var(--muted);
  line-height: 1.7;
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.scan-box {
  background: #111;
  border-radius: 20px;
  overflow: hidden;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #fff;
}

.scan-box video,
.scan-box canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty {
  text-align: center;
  padding: 36px 12px;
  color: var(--muted);
}

.install {
  background: #fff8ea;
  border: 1px solid #ead9b4;
  border-radius: 18px;
  padding: 14px;
  margin: 12px 0;
  font-size: 13px;
}

.back {
  border: 0;
  background: rgba(255,255,255,.16);
  color: #fff;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 22px;
  flex-shrink: 0;
  cursor: pointer;
  line-height: 1;
}

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

.cal-nav b {
  flex: 1;
  text-align: center;
  font-size: 15px;
}

.cal-nav .app-btn {
  width: 44px !important;
  min-width: 44px;
  margin-top: 0;
  padding: 10px 0 !important;
}

.cal-grid {
  display: grid !important;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  background: #fff;
  padding: 10px;
  border-radius: 18px;
  margin-bottom: 12px;
}

.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  padding: 4px 0;
}

.cal-day {
  border: 0;
  background: #f6f5f4;
  border-radius: 12px;
  min-height: 42px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  position: relative;
}

.cal-day.has {
  background: #e8f1f8;
  color: #215f8a;
}

.cal-day.today {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.cal-day.picked {
  background: var(--green);
  color: #fff;
}

.cal-day i {
  display: block;
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  opacity: 0.8;
}

.stat-row {
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.stat-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.stat-bar {
  height: 8px;
  background: #eef2f7;
  border-radius: 99px;
  overflow: hidden;
}

.stat-bar i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 99px;
}
