:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #13212f;
  --muted: #64748b;
  --line: #dbe4ee;
  --teal: #0f766e;
  --cyan: #0891b2;
  --amber: #d97706;
  --rose: #e11d48;
  --indigo: #4f46e5;
  --green: #16a34a;
  --orange: #f97316;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.11);
  --soft-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  --deep-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
  --tap: 52px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.15), transparent 32%),
    linear-gradient(180deg, #f7fbff 0%, var(--bg) 48%, #fffaf2 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 18px 14px;
}

.brand-card,
.panel {
  width: min(100%, 460px);
  margin-inline: auto;
  border: 1px solid rgba(219, 228, 238, 0.86);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-card {
  min-height: 190px;
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 20px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(8, 145, 178, 0.9), rgba(15, 118, 110, 0.95) 55%, rgba(217, 119, 6, 0.82)),
    url("layerx-icon.svg") center / 180px no-repeat;
}

.brand-mark,
.avatar {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  font-weight: 950;
  font-size: 1.25rem;
}

.brand-card p,
.hero p,
.panel-title span,
.role-badge,
.metric span,
.report-grid span,
.entry-card small {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.brand-card p {
  color: rgba(255, 255, 255, 0.82);
}

.developer-credit {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: none;
}

.brand-card h1,
.topbar h1,
.hero h2,
.panel-title h2,
.profile h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-card h1 {
  font-size: 2rem;
  line-height: 1;
}

.login-form,
.mobile-form {
  display: grid;
  gap: 15px;
  padding: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid #d9e6ef;
  border-radius: 8px;
  padding: 12px 13px;
  background: linear-gradient(180deg, #ffffff, #f8fbfe);
  color: var(--ink);
  outline: none;
  font-size: 1rem;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.13);
}

.login-form button,
.mobile-form button,
.hero button,
.quick-grid button,
.secondary {
  min-height: var(--tap);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(8, 145, 178, 0.2);
}

.message {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 750;
}

.message.success {
  color: var(--green);
}

.message.error {
  color: var(--rose);
}

.app-credit {
  width: min(100%, 460px);
  margin: 12px auto 76px;
  color: var(--muted);
  text-align: center;
}

.app-screen {
  min-height: 100vh;
  padding: 82px 12px 112px;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: calc(env(safe-area-inset-top) + 9px) 12px 9px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid rgba(219, 228, 238, 0.74);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  backdrop-filter: blur(18px);
}

.hamburger-button,
.icon-button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f3fafc);
  color: var(--teal);
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.hamburger-button {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 10px;
}

.hamburger-button span {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: #155e75;
}

.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  background: rgba(15, 23, 42, 0.42);
}

.mobile-drawer.open {
  display: block;
}

.drawer-panel {
  width: min(66vw, 252px);
  height: fit-content;
  max-height: calc(100vh - env(safe-area-inset-top) - 18px);
  display: grid;
  align-content: start;
  gap: 7px;
  padding: calc(env(safe-area-inset-top) + 10px) 9px 14px;
  border-radius: 0 0 12px 0;
  background:
    linear-gradient(180deg, rgba(16, 32, 51, 0.98), rgba(15, 76, 129, 0.96)),
    #102033;
  color: #ffffff;
  overflow: auto;
  box-shadow: 18px 0 42px rgba(15, 23, 42, 0.32);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0 8px;
}

.drawer-head span,
.drawer-route-list span {
  display: block;
  color: #9fb4c8;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.drawer-head strong {
  display: block;
  margin-top: 2px;
  font-size: 1.02rem;
}

.drawer-session {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid rgba(148, 211, 220, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #9fb4c8;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.drawer-session select {
  min-height: 26px;
  padding: 3px 7px;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 900;
}

.drawer-panel > button,
.drawer-group summary,
.drawer-group > button,
.drawer-route-list button {
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(148, 211, 220, 0.13);
  background: rgba(255, 255, 255, 0.06);
  color: #dbeafe;
  text-align: left;
  font-weight: 900;
}

.drawer-group {
  display: grid;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(148, 211, 220, 0.26);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.drawer-group summary {
  list-style: none;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.64), rgba(8, 145, 178, 0.64));
}

.drawer-group summary::-webkit-details-marker {
  display: none;
}

.drawer-route-list {
  display: grid;
  gap: 6px;
}

.drawer-group > button {
  border-left: 3px solid rgba(148, 211, 220, 0.36);
  background: rgba(255, 255, 255, 0.045);
}

.drawer-route-list button {
  border-left: 3px solid rgba(34, 211, 238, 0.46);
  background: rgba(255, 255, 255, 0.04);
}

.drawer-route-list strong {
  display: block;
  color: #ffffff;
}

.drawer-empty {
  margin: 0;
  padding: 10px;
  color: #9fb4c8;
  font-weight: 800;
}

.topbar h1 {
  font-size: 1.12rem;
  line-height: 1.1;
}

.role-badge {
  color: var(--cyan);
}

.icon-button {
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  font-weight: 900;
}

.view {
  display: none;
  width: min(100%, 460px);
  margin-inline: auto;
}

.view.active {
  display: grid;
  gap: 12px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  min-height: 118px;
  padding: 16px;
  border-radius: 8px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(21, 94, 117, 0.98) 0%, rgba(8, 145, 178, 0.96) 48%, rgba(245, 158, 11, 0.9) 100%);
  box-shadow: var(--deep-shadow);
}

.hero p {
  color: rgba(255, 255, 255, 0.82);
}

.hero h2 {
  font-size: 1.55rem;
}

.hero button {
  min-height: 42px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.metric-grid,
.quick-grid,
.report-grid,
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.metric,
.report-grid article {
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-content: space-between;
  padding: 12px;
  border-radius: 8px;
  color: #ffffff;
  box-shadow: var(--soft-shadow);
}

.metric span,
.report-grid span {
  color: rgba(255, 255, 255, 0.78);
}

.metric strong,
.report-grid strong {
  font-size: 1.34rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.teal {
  background: linear-gradient(135deg, var(--teal), #14b8a6);
}

.amber {
  background: linear-gradient(135deg, var(--amber), #f59e0b);
}

.rose {
  background: linear-gradient(135deg, var(--rose), #fb7185);
}

.indigo {
  background: linear-gradient(135deg, var(--indigo), #818cf8);
}

.panel {
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
}

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

.panel-title h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.quick-grid button {
  min-height: 64px;
  border: 1px solid rgba(8, 145, 178, 0.1);
  background: linear-gradient(180deg, #f0fbff, #e8f7f5);
  color: #155e75;
  box-shadow: var(--soft-shadow);
}

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

.empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  font-weight: 750;
}

.entry-card {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid rgba(219, 228, 238, 0.9);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.055);
}

.entry-card h3 {
  margin: 0;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.entry-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.master-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.entry-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.entry-actions button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--indigo);
  font-size: 1.05rem;
  font-weight: 900;
}

.entry-actions button[data-master-action="delete"] {
  background: #ffe4e6;
  color: #be123c;
}

.card-row,
.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--indigo);
  font-size: 0.72rem;
  font-weight: 900;
}

.pill.pending {
  background: #fef3c7;
  color: #a16207;
}

.pill.accepted {
  background: #dcfce7;
  color: #15803d;
}

.pill.rejected {
  background: #ffe4e6;
  color: #be123c;
}

.action-row button,
.tabbar button,
.segmented button,
.permission-row button {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--indigo);
  font-weight: 900;
}

.action-row .accept {
  background: #dcfce7;
  color: #15803d;
}

.action-row .reject {
  background: #ffe4e6;
  color: #be123c;
}

.action-row img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: zoom-in;
}

.photo-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(15, 23, 42, 0.82);
}

.photo-preview-modal.open {
  display: flex;
}

.photo-preview-panel {
  display: grid;
  gap: 10px;
  width: min(100%, 760px);
  max-height: 94vh;
}

.photo-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
}

.photo-preview-head button {
  min-height: 38px;
  border-radius: 8px;
  background: #fff;
  color: #111827;
  font-weight: 900;
}

.photo-preview-panel img {
  max-width: 100%;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.expiry-popup-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(15, 23, 42, 0.82);
}

.expiry-popup-modal.open {
  display: flex;
}

.expiry-popup-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 560px);
  max-height: 88vh;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
  overflow: auto;
}

.expiry-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.expiry-popup-head strong {
  color: #be123c;
  font-size: 1.05rem;
}

.expiry-popup-head button {
  min-height: 38px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 900;
}

.expiry-popup-list {
  display: grid;
  gap: 8px;
}

.expiry-popup-list article {
  padding: 10px;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  background: #fff1f2;
  color: #7f1d1d;
  font-weight: 800;
  line-height: 1.35;
}

.segmented,
.tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow-x: auto;
}

.tabbar {
  grid-template-columns: repeat(4, 1fr);
}

.segmented button,
.tabbar button {
  background: transparent;
  color: var(--muted);
}

.segmented button.active,
.tabbar button.active {
  background: #155e75;
  color: #ffffff;
}

.report-grid article {
  background: linear-gradient(135deg, #334155, #0f766e);
}

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

.permission-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-row strong {
  font-size: 0.92rem;
}

.permission-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.permission-row button.active {
  background: #155e75;
  color: #ffffff;
}

.profile {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.profile-credit {
  color: var(--muted);
}

.avatar {
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  color: #ffffff;
}

.secondary {
  width: 100%;
  background: #334155;
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 9px);
  border-top: 1px solid rgba(219, 228, 238, 0.82);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  min-height: 50px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.bottom-nav button.active {
  background: linear-gradient(180deg, #e0f2fe, #ccfbf1);
  color: #155e75;
}

@media (min-width: 760px) {
  .app-screen {
    padding-inline: 24px;
  }

  .view,
  .panel,
  .brand-card {
    width: min(100%, 720px);
  }

  .metric-grid,
  .report-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .app-screen {
    padding-inline: 10px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .brand-card {
    min-height: 168px;
    padding: 18px;
  }

  .brand-card h1 {
    font-size: 1.75rem;
  }

  .hero {
    align-items: start;
    flex-direction: column;
  }

  .hero button {
    width: 100%;
  }

  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-grid button {
    min-height: 58px;
    padding: 8px 6px;
    font-size: 0.86rem;
  }

  .tabbar {
    grid-template-columns: repeat(3, minmax(90px, 1fr));
  }

  .metric span,
  .report-grid span {
    font-size: 0.68rem;
  }
}

@media (max-width: 340px) {
  .metric-grid,
  .report-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    gap: 3px;
    padding-inline: 5px;
  }

  .bottom-nav button {
    font-size: 0.66rem;
    min-height: 46px;
  }
}
