:root {
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --fg: #111827;
  --muted: #667085;
  --line: #d9e2ec;
  --line-strong: #b8c4d2;
  --primary: #0f9f6e;
  --primary-dark: #087a55;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success-soft: #ecfdf3;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, .10);
  --shadow-lg: 0 22px 60px rgba(15, 23, 42, .22);
  --radius: 18px;
  --radius-sm: 12px;
  --nav-height: 74px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background: #f4f7fb;
  color: var(--fg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button,
a,
input,
select {
  outline-color: rgba(37, 99, 235, .45);
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px calc(var(--nav-height) + 26px + env(safe-area-inset-bottom));
}

.auth-shell {
  display: grid;
  place-items: center;
  padding-bottom: 24px;
}

.auth-card {
  width: min(100%, 390px);
  display: grid;
  gap: 18px;
  text-align: center;
}

.auth-card::before {
  content: "";
  width: 54px;
  height: 54px;
  margin: 0 auto 2px;
  border-radius: 17px;
  background: #0f9f6e;
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.02;
  letter-spacing: 0;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
}

.page {
  width: min(100%, 520px);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.narrow {
  width: min(100%, 460px);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  font-weight: 850;
}

.underlined {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  text-align: left;
  font-size: clamp(26px, 7vw, 34px);
  line-height: 1.08;
  font-weight: 900;
}

.underlined::after {
  content: "";
  display: block;
  width: 46px;
  height: 4px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--primary);
}

.underlined.left {
  margin-left: 0;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .94);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.panel.form-stack {
  padding: 18px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  text-align: left;
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  color: var(--fg);
  font-size: 16px;
  font-weight: 650;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, .02);
}

input::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus {
  border-color: rgba(37, 99, 235, .58);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}

input[type="checkbox"] {
  min-height: 0;
  accent-color: var(--primary);
}

.search {
  border-radius: 999px;
  padding-left: 18px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--fg);
}

.check input {
  width: 20px;
  height: 20px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 88px auto;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--fg);
  background: #fff;
  font-weight: 850;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.btn:hover {
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(1px) scale(.99);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: var(--blue-soft);
  color: #1849a9;
}

.btn.blue {
  background: #1d4ed8;
  color: #fff;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.big {
  min-height: 56px;
  font-size: 17px;
}

.btn.huge {
  min-height: 64px;
  border-radius: 18px;
  font-size: 24px;
}

.btn.wide {
  width: 100%;
  margin: 0;
}

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

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .86);
  color: var(--fg);
  font-size: 24px;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: -4px -4px 2px;
  padding: 4px;
  background: rgba(248, 250, 252, .80);
  backdrop-filter: blur(16px);
}

.action-stack {
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.center {
  text-align: center;
}

.small {
  font-size: 13px;
  color: var(--muted);
}

.message {
  margin: 0;
  border-radius: 14px;
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
  font-weight: 750;
}

.message.error {
  color: #b42318;
  background: var(--danger-soft);
  border: 1px solid #fecaca;
}

.message.success {
  color: #027a48;
  background: var(--success-soft);
  border: 1px solid #abefc6;
}

.daily-summary {
  display: grid;
  gap: 12px;
}

.summary-grid,
.totals-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  border: 1px solid #e6edf5;
  border-radius: 16px;
  background: var(--surface-soft);
  padding: 14px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(19px, 5vw, 25px);
  line-height: 1;
  font-weight: 900;
}

.macro-row,
.list-row,
.table-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  font-weight: 780;
}

.macro-row {
  min-height: 48px;
  padding: 10px 2px 0;
  border-top: 1px solid #eef2f6;
  color: #344054;
}

.macro-row:first-child {
  border-top: 0;
}

.macro-row span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.list-panel {
  padding: 0;
  overflow: hidden;
}

.table-head {
  min-height: 42px;
  padding: 12px 14px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 850;
}

.list-row {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-bottom: 1px solid #edf2f7;
  padding: 13px 14px;
  background: #fff;
  color: var(--fg);
  text-align: left;
}

.list-row:hover {
  background: #f8fbff;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row button.linklike {
  border: 0;
  background: none;
  padding: 0;
  color: var(--fg);
  font-weight: 850;
  text-align: left;
}

.empty {
  padding: 26px 16px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.three-cols {
  grid-template-columns: minmax(0, 1.5fr) minmax(56px, .65fr) minmax(56px, .65fr);
}

.four-cols {
  grid-template-columns: 24px 58px minmax(0, 1fr) auto;
}

.admin-cols {
  grid-template-columns: minmax(0, 1fr) auto auto auto;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  background: #2563eb;
  color: #fff;
  vertical-align: middle;
}

.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown {
  position: relative;
  z-index: 5;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-md);
}

.dropdown button {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-bottom: 1px solid #edf2f7;
  background: #fff;
  color: var(--fg);
  padding: 12px 14px;
  text-align: left;
  font-weight: 760;
}

.dropdown button:hover {
  background: #f8fbff;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(700px, calc(100% - 20px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid rgba(217, 226, 236, .90);
  border-radius: 22px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.bottom-tab {
  min-height: 58px;
  border: 0;
  padding: 8px 6px;
  display: grid;
  place-items: center;
  background: transparent;
  color: #475467;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.12;
  text-align: center;
}

.bottom-tab.active {
  background: var(--blue-soft);
  color: #1849a9;
}

.modal-root:empty {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(8px);
}

.modal {
  width: min(100%, 430px);
  max-height: min(88vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.modal header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(14px);
}

.modal header h3 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  font-weight: 900;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 10px;
  font-size: 14px;
}

.detail-row span:first-child {
  color: var(--muted);
  font-weight: 750;
}

.detail-row span:last-child {
  font-weight: 850;
  text-align: right;
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 34px;
  }

  .modal-root {
    place-items: center;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

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

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

  .summary-grid,
  .totals-strip {
    grid-template-columns: 1fr 1fr;
  }

  .bottom-tab {
    font-size: 10px;
  }

  .four-cols {
    grid-template-columns: 22px 52px minmax(0, 1fr) auto;
  }
}

@media (max-width: 380px) {
  .summary-grid,
  .totals-strip {
    grid-template-columns: 1fr;
  }

  .three-cols {
    grid-template-columns: minmax(0, 1.4fr) 52px 52px;
  }

  .btn.huge {
    font-size: 22px;
  }
}
