/* Base */
:root {
  color-scheme: light;
  --brand-blue: #0868ae;
  --brand-navy: #12233a;
  --brand-cyan: #22b9df;
  --canvas: #f4f8fb;
  --surface: #ffffff;
  --intro: #eef8fc;
  --text: #12233a;
  --secondary: #4d6478;
  --inactive: #647b8e;
  --line: #dce8f0;
  --page-padding: 16px;
  --card-radius: 20px;
  --shadow-soft: 0 8px 22px rgba(35, 70, 94, 0.065);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: #eaf2f7;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a, button { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }

/* Layout */
.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  overflow: clip;
  background: var(--canvas);
}

main { padding: 0 var(--page-padding) calc(75px + env(safe-area-inset-bottom, 0px)); }

/* Header */
.app-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: center;
  padding: calc(7px + env(safe-area-inset-top, 0px)) var(--page-padding) 0;
  background: #f8fbfd;
}

.brand-logo {
  width: 150px;
  height: auto;
  max-height: 76px;
  object-fit: contain;
}

.intro-card {
  display: grid;
  min-height: 60px;
  place-items: center;
  padding: 1px 12px 14px;
  background: #f8fbfd;
  text-align: center;
}

.intro-content { width: 100%; }

.intro-card h1 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 1.48rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.035em;
}

.intro-card p {
  margin: 6px 0 0;
  color: var(--secondary);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.65;
}

/* Tools Grid */
#home-view {
  background: #f4f7fa;
}

#home-view main { padding-inline: var(--page-padding); }

.home-tools {
  display: grid;
  gap: 14px;
}

.home-tool-section { min-width: 0; }

.home-section-header {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  padding: 7px 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: start;
}

.home-section-header > div { min-width: 0; }

.home-section-header h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.4;
}

.home-section-header p {
  margin: 2px 0 0;
  color: var(--secondary);
  font-size: 0.69rem;
  font-weight: 500;
  line-height: 1.45;
}

.section-header-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: #e9f4fb;
  color: var(--brand-blue);
}

.section-header-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.section-header-icon.rights-icon svg { fill: currentColor; stroke: none; }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 118px;
  gap: 10px;
}

.rights-tools-grid .tool-card[data-tool-id="insurance"] {
  width: 100%;
  grid-column: 1 / -1;
  justify-self: center;
}

/* Tool Cards */
.tool-card {
  --tool-accent: var(--brand-blue);
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 44px;
  grid-template-columns: 42px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 7px;
  padding: 11px 10px;
  overflow: hidden;
  border: 1px solid #e0e8ee;
  border-radius: 15px;
  background: #ffffff;
  box-shadow: 0 5px 13px rgba(38, 68, 89, 0.045);
  text-align: start;
  transition: border-color 150ms ease, transform 150ms ease;
}

.tool-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: #f4f7f9;
  box-shadow: none;
}

.tool-card[data-tool-id="dawami"] { --tool-accent: #18a98f; }
.tool-card[data-tool-id="permission"] { --tool-accent: #258bd0; }
.tool-card[data-tool-id="shifts"] { --tool-accent: #df8a25; }
.tool-card[data-tool-id="fingerprint"] { --tool-accent: #775ac7; }
.tool-card[data-tool-id="bonus"] { --tool-accent: #d7a124; }
.tool-card[data-tool-id="promotion"] { --tool-accent: #d85f89; }
.tool-card[data-tool-id="insurance"] { --tool-accent: #18aabd; }

.tool-icon img { width: 39px; height: 39px; }
.tool-card[data-tool-id="shifts"] .tool-icon img,
.tool-card[data-tool-id="fingerprint"] .tool-icon img { width: 41px; height: 41px; }

.tool-card-arrow {
  position: static;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--tool-accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.tool-copy {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 0;
}

.tool-card h2 {
  display: -webkit-box;
  min-height: 19px;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.38;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-card p {
  display: -webkit-box;
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--secondary);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tool-card:active { transform: scale(0.985); }

.tool-card:focus-visible,
.community-button:focus-visible,
.nav-item:focus-visible {
  outline: 3px solid rgba(8, 104, 174, 0.25);
  outline-offset: 2px;
}

/* Community Card */
.community-card {
  margin-top: 11px;
  padding: 12px;
  border: 1px solid #d9e8f1;
  border-radius: 22px;
  background: linear-gradient(145deg, #ffffff, #f1f9fd);
  box-shadow: 0 7px 19px rgba(35, 70, 94, 0.05);
  text-align: center;
}

.community-card h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.45;
}

.community-card p {
  margin: 4px auto 0;
  color: var(--secondary);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.55;
}

.community-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 9px;
  border-radius: 14px;
  background: var(--brand-blue);
  box-shadow: 0 6px 14px rgba(8, 104, 174, 0.17);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
  transition: background-color 150ms ease, transform 150ms ease;
}

.community-button svg { width: 18px; height: 18px; fill: currentColor; }
.community-button:active { transform: scale(0.99); }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  z-index: 10;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, 480px);
  min-height: 60px;
  padding: 4px 7px calc(4px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #e0e8ee;
  background: #ffffff;
  box-shadow: 0 -4px 14px rgba(33, 67, 91, 0.045);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-item {
  display: flex;
  min-width: 0;
  min-height: 52px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--inactive);
  cursor: pointer;
}

.nav-item svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.nav-item span {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.66rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item.is-active { color: var(--brand-blue); }
.nav-item.is-active span { font-weight: 600; }

/* Secondary Views */
.secondary-view { background: var(--canvas); }

.secondary-header {
  padding: calc(18px + env(safe-area-inset-top, 0px)) var(--page-padding) 15px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.secondary-header h1 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 1.34rem;
  font-weight: 700;
  line-height: 1.35;
}

.secondary-header p {
  margin: 3px 0 0;
  color: var(--secondary);
  font-size: 0.8rem;
  font-weight: 500;
}

.secondary-content {
  min-height: calc(100dvh - 86px);
  padding: 15px var(--page-padding) calc(82px + env(safe-area-inset-bottom, 0px));
}

.notifications-list {
  display: grid;
  gap: 10px;
}

.notification-card {
  position: relative;
  padding: 14px;
  border: 1px solid #dce8f0;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.notification-card.is-unread { padding-inline-start: 30px; }

.notification-dot {
  position: absolute;
  top: 19px;
  inset-inline-start: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-blue);
}

.notification-card h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.5;
}

.notification-card p {
  margin: 5px 0 0;
  color: var(--secondary);
  font-size: 0.79rem;
  font-weight: 400;
  line-height: 1.65;
}

.notification-footer {
  display: flex;
  min-height: 44px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 3px;
}

.notification-time {
  padding-bottom: 10px;
  color: var(--inactive);
  font-size: 0.71rem;
  font-weight: 500;
}

.notification-action {
  min-width: 68px;
  min-height: 44px;
  padding: 7px 14px;
  border: 0;
  border-radius: 12px;
  background: #eaf5fb;
  color: var(--brand-blue);
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
}

.empty-state {
  padding: 48px 20px;
  color: var(--secondary);
  text-align: center;
}

.empty-state p { margin: 0; font-size: 0.88rem; font-weight: 500; }

.employee-content {
  display: grid;
  min-height: calc(100dvh - 132px);
  place-items: center;
}

.employee-placeholder { padding: 24px 16px; text-align: center; }

.employee-placeholder h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 1.2rem;
  font-weight: 700;
}

.employee-placeholder p {
  margin: 7px 0 0;
  color: var(--secondary);
  font-size: 0.86rem;
  font-weight: 400;
}

.more-content { display: flex; flex-direction: column; gap: 18px; }

.more-section > h2 {
  margin: 0 4px 7px;
  color: var(--brand-navy);
  font-size: 0.86rem;
  font-weight: 700;
}

.more-list,
.about-section p {
  border: 1px solid #dce8f0;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.more-list { overflow: hidden; }

.more-row {
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: 36px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  padding: 7px 13px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}

.more-row + .more-row { border-top: 1px solid #e5edf2; }

.more-row-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: #eaf5fb;
  color: var(--brand-blue);
}

.more-row-icon svg { width: 20px; height: 20px; fill: currentColor; }
.whatsapp-icon svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.privacy-row-icon { fill: none !important; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.row-chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--inactive);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.about-section p {
  margin: 0;
  padding: 14px;
  color: var(--secondary);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.7;
}

.app-info {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 1px;
  margin-top: auto;
  padding: 22px 0 2px;
  color: var(--inactive);
  font-size: 0.73rem;
}

.app-info strong { color: var(--brand-navy); font-size: 0.82rem; font-weight: 700; }

/* Privacy & Usage View */
.privacy-view {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
}

.privacy-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  min-height: calc(56px + env(safe-area-inset-top, 0px));
  grid-template-columns: minmax(72px, 1fr) minmax(0, 2.2fr) minmax(72px, 1fr);
  align-items: center;
  padding: env(safe-area-inset-top, 0px) 10px 0;
  border-bottom: 1px solid #dde8ef;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 9px rgba(25, 58, 82, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.privacy-header h1 {
  margin: 0;
  overflow: hidden;
  color: var(--brand-navy);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.privacy-back-button {
  display: inline-flex;
  min-width: 72px;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  justify-self: start;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--brand-blue);
  cursor: pointer;
}

.privacy-back-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.privacy-back-button span { font-size: 0.86rem; font-weight: 600; }
.privacy-header-balance { min-width: 72px; }

.privacy-content {
  padding: 16px var(--page-padding) calc(28px + env(safe-area-inset-bottom, 0px));
}

.privacy-intro {
  margin: 0 0 6px;
  padding: 15px;
  border: 1px solid #d9e9f2;
  border-radius: 18px;
  background: #eef8fc;
  color: var(--secondary);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.8;
}

.privacy-section {
  padding: 16px 2px;
  border-bottom: 1px solid #dce7ee;
}

.privacy-section:last-child { border-bottom: 0; }

.privacy-section h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.5;
}

.privacy-section p {
  margin: 6px 0 0;
  color: var(--secondary);
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.85;
}

.privacy-section p + p { margin-top: 10px; }

.privacy-contact a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-top: 10px;
  padding: 8px 13px;
  border-radius: 12px;
  background: #e9f5fb;
  color: var(--brand-blue);
  direction: ltr;
  font-size: 0.84rem;
  font-weight: 700;
}

.notification-action:focus-visible,
.more-row:focus-visible,
.privacy-back-button:focus-visible,
.privacy-contact a:focus-visible {
  outline: 3px solid rgba(8, 104, 174, 0.25);
  outline-offset: 2px;
}

/* Tool View — iframe is the web prototype equivalent of a future WKWebView. */
body.tool-open { overflow: hidden; }

.tool-view {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin-inline: auto;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
}

.tool-view-header {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: calc(52px + env(safe-area-inset-top, 0px));
  grid-template-columns: minmax(72px, 1fr) minmax(0, 2fr) minmax(72px, 1fr);
  align-items: center;
  padding: env(safe-area-inset-top, 0px) 10px 0;
  border-bottom: 1px solid #e1e9ef;
  background: #ffffff;
  box-shadow: 0 2px 9px rgba(25, 58, 82, 0.045);
}

.tool-view-header h1 {
  margin: 0;
  overflow: hidden;
  color: var(--brand-navy);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-back-button {
  display: inline-flex;
  min-width: 72px;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  justify-self: start;
  margin: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--brand-blue);
  cursor: pointer;
}

.tool-back-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.tool-back-button span { font-size: 0.86rem; font-weight: 600; }
.tool-header-balance { min-width: 72px; }

.tool-view-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  flex: 1;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: #ffffff;
}

.tool-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.tool-loading,
.tool-error {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
  background: #ffffff;
  color: var(--secondary);
  text-align: center;
}

.tool-loading p {
  margin: 11px 0 0;
  font-size: 0.88rem;
  font-weight: 500;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #dceaf3;
  border-top-color: var(--brand-blue);
  border-radius: 50%;
  animation: tool-loading-spin 800ms linear infinite;
}

.tool-error-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  background: #eef7fc;
  color: var(--brand-blue);
  font-size: 1.3rem;
  font-weight: 700;
}

.tool-error h2 {
  max-width: 290px;
  margin: 13px 0 0;
  color: var(--brand-navy);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.55;
}

.tool-browser-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
  padding: 8px 18px;
  border-radius: 13px;
  background: var(--brand-blue);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 600;
}

.tool-back-button:focus-visible,
.tool-browser-link:focus-visible {
  outline: 3px solid rgba(8, 104, 174, 0.25);
  outline-offset: 2px;
}

@keyframes tool-loading-spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 349px) {
  :root { --page-padding: 13px; }
  .app-header { min-height: 73px; }
  .brand-logo { width: 142px; max-height: 70px; }
  .intro-card { min-height: 56px; padding: 1px 7px 11px; }
  .intro-card h1 { font-size: 1.26rem; }
  .home-tools { gap: 12px; }
  .home-section-header { min-height: 42px; gap: 6px; padding: 6px 2px; }
  .home-section-header h2 { font-size: 0.94rem; }
  .section-header-icon { width: 30px; height: 30px; }
  .section-header-icon svg { width: 20px; height: 20px; }
  .tools-grid { grid-auto-rows: 124px; gap: 8px; }
  .rights-tools-grid .tool-card[data-tool-id="insurance"] { width: 100%; }
  .tool-card { grid-template-columns: 38px minmax(0, 1fr) 14px; gap: 5px; padding: 9px 8px; border-radius: 14px; }
  .tool-icon { width: 38px; height: 38px; border-radius: 12px; }
  .tool-icon img { width: 35px; height: 35px; }
  .tool-card[data-tool-id="shifts"] .tool-icon img,
  .tool-card[data-tool-id="fingerprint"] .tool-icon img { width: 38px; height: 38px; }
  .tool-card-arrow { width: 14px; height: 14px; }
  .tool-card h2 { font-size: 0.75rem; }
  .tool-card p { font-size: 0.62rem; }
}

@media (min-width: 430px) {
  :root { --page-padding: 18px; }
  .tools-grid { gap: 12px; }
}

@media (min-width: 481px) {
  body { padding-block: 22px; }
  .app-shell {
    min-height: calc(100vh - 44px);
    min-height: calc(100dvh - 44px);
    border: 1px solid #d7e4ec;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(29, 70, 101, 0.11);
  }
}

@media (hover: hover) and (pointer: fine) {
  .tool-card:hover { border-color: #bdd7e6; transform: translateY(-1px); }
  .community-button:hover { background: #075a98; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .loading-spinner { animation-duration: 1.8s; }
}
