:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #16202a;
  --muted: #667085;
  --line: #d6dde6;
  --green: #14614f;
  --green-2: #0f766e;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2563a8;
  --shadow: 0 14px 34px rgba(20, 31, 43, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 270px 1fr;
  background: var(--bg);
}

.login-shell {
  display: block;
  max-width: 560px;
  min-height: 100vh;
}

.login-panel {
  margin: 44px auto;
  box-shadow: 0 20px 54px rgba(20, 31, 43, 0.12);
}

.login-brand {
  color: var(--ink);
}

.rail {
  min-height: 100vh;
  padding: 22px 16px;
  background: #101820;
  color: white;
  position: sticky;
  top: 0;
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d7a640;
  color: #101820;
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.05;
}

.brand p {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.mobile-tabs button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 14px;
  font-weight: 750;
}

.nav button.active {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 3px 0 #d7a640;
}

.rail-footer {
  margin-top: 14px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  line-height: 1.35;
}

.main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 0;
  font-size: clamp(23px, 3vw, 32px);
  line-height: 1.08;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.role-select {
  display: grid;
  gap: 6px;
  min-width: 208px;
}

.role-select label,
.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.label-hi {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.voice-btn {
  min-height: 28px;
  margin-left: 6px;
  padding: 5px 9px;
  border-radius: var(--radius);
  background: var(--blue);
  color: white;
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

.voice-btn.listening {
  background: var(--red);
}

.role-select select,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  background: white;
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.field select,
.role-select select {
  min-height: 46px;
  padding-right: 34px;
  line-height: 1.35;
}

.role-select select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.field textarea {
  min-height: 76px;
  resize: vertical;
}

.mobile-tabs {
  display: none;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.stat,
.panel,
.row,
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat {
  padding: 14px;
  min-height: 96px;
  border-top: 3px solid rgba(15, 118, 110, 0.22);
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 9px;
  font-size: 24px;
  line-height: 1;
}

.stat small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.layout {
  grid-template-columns: minmax(0, 1.18fr) minmax(330px, 0.82fr);
  align-items: start;
  margin-top: 14px;
}

.panel {
  padding: 16px;
  overflow-x: auto;
  max-width: 100%;
}

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

.panel h3 {
  margin: 0;
  font-size: 18px;
}

.panel-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.compact-form {
  margin-bottom: 12px;
}

.field.full {
  grid-column: 1 / -1;
}

.photo-drop {
  position: relative;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px dashed #93a9a4;
  border-radius: var(--radius);
  padding: 10px;
  background: linear-gradient(0deg, #ffffff, var(--surface-soft));
  min-height: 94px;
  overflow: hidden;
}

.clickable-photo {
  cursor: pointer;
}

.photo-drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.photo-meta {
  align-self: center;
  color: #365349;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.camera-action {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  margin-bottom: 6px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

.photo-preview {
  width: 72px;
  height: 72px;
  border-radius: 7px;
  background: #ffffff;
  object-fit: cover;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 900;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  border-radius: 7px;
  object-fit: cover;
}

.invoice-preview {
  padding: 6px;
  overflow: hidden;
  word-break: break-word;
  font-size: 10px;
  line-height: 1.15;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: var(--radius);
  background: var(--green);
  color: white;
  font-size: 14px;
  font-weight: 850;
  box-shadow: 0 8px 16px rgba(20, 97, 79, 0.14);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
  white-space: normal;
  text-align: center;
}

.btn.secondary {
  background: #eef2f6;
  color: var(--green);
  box-shadow: none;
}

.btn.warn {
  background: var(--amber);
}

.btn.danger {
  background: var(--red);
}

.btn:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:not(:disabled):active {
  transform: translateY(1px);
}

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

.row {
  padding: 12px;
}

.photo-review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.photo-review {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: #fbfcfd;
}

.photo-review img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.photo-review-title {
  margin-bottom: 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.check-line {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

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

.row-title {
  font-weight: 900;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.amount {
  white-space: nowrap;
  font-weight: 950;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.tag.pending {
  background: #fff1d9;
  color: #8a560e;
}

.tag.ok {
  background: #ddf3ec;
  color: var(--green);
}

.tag.info {
  background: #e7eef8;
  color: var(--blue);
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mini-actions .btn {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 12px;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 680px;
}

.ledger-table th,
.ledger-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 6px;
  text-align: left;
  vertical-align: top;
}

.ledger-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  background: #f7f9fb;
  font-weight: 900;
}

.ledger-table td:last-child,
.ledger-table th:last-child {
  text-align: right;
}

.table-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.rights-table .btn {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.channel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px;
  background: #fbfcfd;
  font-size: 12px;
}

.website-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.website-hero h3 {
  margin: 10px 0 8px;
  font-size: 24px;
  line-height: 1.12;
}

.website-hero p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.website-status {
  min-width: 210px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid #ecd39a;
  border-radius: var(--radius);
  background: #fff8ea;
}

.website-status strong {
  color: #8a560e;
  font-size: 16px;
  line-height: 1.2;
}

.website-status span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.contact-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--green);
  background: #fbfcfd;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

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

.gallery-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fbfcfd;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.gallery-card div {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.gallery-card strong {
  font-size: 13px;
  line-height: 1.2;
}

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

.policy-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.42;
}

.policy-list strong {
  color: var(--green);
}

.otp-box {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: #fff8ea;
  border: 1px solid #ecd39a;
}

.otp-preview {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #ecd39a;
  border-radius: var(--radius);
  background: #fff8ea;
}

.otp-preview span {
  color: #8a560e;
  font-size: 12px;
  font-weight: 900;
}

.otp-preview strong {
  color: var(--ink);
  font-size: 28px;
  letter-spacing: 0;
}

.otp-preview small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.otp-line {
  display: flex;
  gap: 8px;
}

.otp-line input {
  min-width: 0;
  flex: 1;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 12px 14px;
  max-width: 320px;
  font-size: 13px;
  transform: translateY(120%);
  opacity: 0;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  font-size: 13px;
}

@media (min-width: 881px) {
  .app-shell:not(.login-shell) {
    min-height: 100vh;
  }

  .main {
    width: 100%;
    overflow: hidden;
  }

  .panel-head .btn,
  .mini-actions .btn {
    flex: 0 0 auto;
  }

  .screen.active {
    animation: screenFade 130ms ease-out;
  }
}

@keyframes screenFade {
  from {
    opacity: 0.82;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 880px) {
  body {
    background: #eef3f1;
  }

  .app-shell {
    display: block;
    max-width: 100%;
  }

  .rail {
    display: none;
  }

  .main {
    padding: 9px 10px calc(82px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    position: sticky;
    top: 0;
    z-index: 8;
    gap: 7px;
    margin: -9px -10px 8px;
    padding: 8px 10px 7px;
    background: rgba(238, 243, 241, 0.96);
    border-bottom: 1px solid rgba(214, 221, 230, 0.9);
    backdrop-filter: blur(14px);
    transition: transform 150ms ease, opacity 150ms ease;
    will-change: transform;
  }

  .topbar.header-hidden {
    transform: translateY(calc(-100% - 9px));
    opacity: 0;
    pointer-events: none;
  }

  .topbar h2 {
    font-size: 18px;
    line-height: 1.08;
  }

  .topbar p {
    font-size: 11px;
    line-height: 1.25;
    margin-top: 3px;
  }

  .topbar > div:first-child {
    display: none;
  }

  .role-select {
    min-width: 0;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 7px;
  }

  .role-select label {
    display: none;
  }

  .role-select .tag {
    display: none;
  }

  .role-select .btn {
    grid-column: 1 / -1;
    min-height: 42px;
  }

  .field select,
  .field input,
  .field textarea,
  .role-select select {
    min-height: 48px;
    font-size: 16px;
  }

  .field select,
  .role-select select {
    min-height: 52px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .actions {
    padding-bottom: 22px;
    gap: 8px;
  }

  .actions .btn {
    width: 100%;
  }

  .screen {
    padding-bottom: 28px;
  }

  .mobile-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    padding: 5px max(7px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
    box-shadow: 0 -12px 28px rgba(20, 31, 43, 0.1);
    backdrop-filter: blur(14px);
    scrollbar-width: none;
  }

  .mobile-tabs::-webkit-scrollbar {
    display: none;
  }

  .mobile-tabs button {
    flex: 0 0 76px;
    min-height: 42px;
    justify-content: center;
    padding: 5px 3px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.1;
    display: grid;
    gap: 2px;
    text-align: center;
  }

  .mobile-tabs button.active {
    color: var(--green);
    background: #eaf4f1;
  }

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

  .layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    gap: 14px;
  }

  .panel {
    padding: 13px;
    border-radius: 7px;
    box-shadow: 0 8px 22px rgba(20, 31, 43, 0.07);
  }

  .panel-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .panel-head h3 {
    font-size: 16px;
    line-height: 1.25;
  }

  .panel-head .btn,
  .panel-head .tag,
  .panel-head .panel-sub {
    max-width: 100%;
  }

  .btn {
    min-height: 46px;
    padding: 10px 11px;
  }

  .mini-actions .btn {
    flex: 1 1 132px;
  }

  .photo-drop {
    grid-template-columns: 64px 1fr;
    min-height: 86px;
  }

  .photo-preview {
    width: 64px;
    height: 64px;
  }

  .ledger-table {
    min-width: 760px;
  }

  .row-top {
    display: grid;
  }

  .amount {
    white-space: normal;
  }

  .website-hero {
    display: grid;
    padding: 14px;
  }

  .website-status {
    min-width: 0;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }
}

@media (max-width: 430px) {
  .stats {
    gap: 9px;
  }

  .main {
    padding-inline: 8px;
  }

  .stat {
    padding: 12px;
    min-height: 88px;
  }

  .stat strong {
    font-size: 21px;
  }

  .panel {
    padding: 13px;
  }

  .topbar h2 {
    font-size: 17px;
  }

  .channel-grid {
    grid-template-columns: 1fr;
  }

  .photo-review-grid {
    grid-template-columns: 1fr;
  }

  .otp-line {
    display: grid;
    grid-template-columns: 1fr;
  }

  .otp-line input,
  .otp-line .btn {
    width: 100%;
  }

  .mobile-tabs button {
    flex-basis: 68px;
    font-size: 10.5px;
  }
}
