/* Decora x District — light theme. Shared by all templates. */
:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --soft: #F0F0F4;
  --line: #E6E6EC;
  --nitro: #FF4500;
  --nitro-hi: #FF5A1F;
  --tint: #FFF1EB;
  --teal: #00A896;
  --danger: #D92D20;
  --danger-hi: #B42318;
  --fg: #111114;
  --mut: #6B7280;
  --r: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sh: 0 1px 2px rgba(17, 17, 20, .04), 0 6px 20px rgba(17, 17, 20, .06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Space Grotesk", "SF Pro Display", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--mut);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--nitro);
  text-decoration: none;
  transition: color .2s;
}

a:hover {
  text-decoration: none;
  color: var(--nitro-hi);
}

:focus-visible {
  outline: 2px solid var(--nitro);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  color: var(--fg);
  font-weight: 700;
  letter-spacing: -.02em;
}

button,
.btn,
.btn-cancel,
.action-btn {
  touch-action: manipulation;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header & Navigation */
header {
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  padding-top: calc(8px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 20;
  height: auto;
}

.header-container,
.hdr-wrap {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--fg);
}

.brand-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 36px;
  height: 36px;
  background: var(--nitro);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -.03em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 10px;
  color: var(--mut);
  line-height: 1;
  font-weight: 600;
}

.header-links a,
.hdr-nav a {
  color: var(--mut);
  font-weight: 600;
  margin-left: 14px;
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  transition: color .2s;
}

.hdr-nav a {
  margin-left: 0;
}

.header-links a:hover,
.hdr-nav a:hover {
  color: var(--fg);
}

.portal-badge {
  color: var(--nitro);
  background: var(--tint);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}

/* Containers */
.main-container {
  width: min(760px, 100% - 24px);
  margin: 20px auto 40px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--sh);
}

.page-header,
.welcome-box {
  background: var(--soft);
  border-radius: var(--r);
  padding: 16px 16px 4px;
  margin-bottom: 18px;
}

.welcome-box {
  padding-bottom: 16px;
}

.page-header h1,
.welcome-box h1 {
  font-size: 24px;
  margin-bottom: 12px;
}

.welcome-box h1 {
  margin: 0;
}

.section-header,
.box-hdr {
  background: none;
  color: var(--fg);
  font-weight: 700;
  font-size: 15px;
  padding: 0 0 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

/* Spacing between dashboard sections */
.section-gap {
  margin-top: 24px;
}

/* Minimal Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, #111114 0%, #1c1c24 100%);
  color: #fff;
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(255, 69, 0, 0.25) 0%, rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
}

.hero-banner h1 {
  color: #fff;
  font-size: clamp(24px, 5vw, 32px);
  margin: 0;
}

/* Status Inside Card Component */
.status-summary-box {
  background: var(--soft);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.status-label {
  color: var(--mut);
  font-weight: 500;
}

.status-val {
  color: var(--fg);
  font-weight: 700;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.val-online {
  color: #10B981;
}

/* Action Cards Grid */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.action-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--sh);
  transition: transform .3s var(--ease), border-color .3s, box-shadow .3s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.action-card-clickable {
  cursor: pointer;
}

.action-card:hover {
  transform: translateY(-3px);
  border-color: var(--nitro);
  box-shadow: 0 0 0 3px rgba(255, 69, 0, .1), 0 12px 28px rgba(17, 17, 20, .1);
}

.action-card h3 {
  font-size: 17px;
  margin-bottom: 6px;
  border: 0;
  padding: 0;
}

.action-card p {
  color: var(--mut);
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.4;
}

.card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--fg);
}

.action-card:hover .card-icon {
  background: var(--nitro);
  color: #fff;
}

/* Buttons */
.btn,
.btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  padding: 0 24px;
  background: var(--nitro);
  border: 0;
  border-radius: 999px;
  color: #fff;
  font: 700 14px "Space Grotesk", system-ui, sans-serif;
  cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s, background .2s;
}

.btn:hover,
.btn-submit:hover {
  background: var(--nitro-hi);
  color: #fff;
  transform: scale(1.03);
  box-shadow: 0 8px 20px rgba(255, 69, 0, .35);
}

.btn:active,
.btn-submit:active {
  transform: scale(.97);
}

.btn-full {
  width: 100%;
}

.action-card .btn {
  background: var(--tint);
  color: var(--nitro);
}

.action-card:hover .btn,
.action-card .btn:hover {
  background: var(--nitro);
  color: #fff;
}

.btn-cancel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  margin-left: 8px;
  color: var(--fg);
  background: var(--soft);
  border: 0;
  border-radius: 999px;
  font: 600 14px "Space Grotesk", system-ui, sans-serif;
  cursor: pointer;
  transition: all .2s;
}

.btn-cancel:hover {
  background: var(--line);
  color: var(--fg);
}

.btn-logout {
  min-height: 38px;
  padding: 0 16px;
  font-size: 13px;
}

/* Destructive buttons */
.btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  background: transparent;
  color: var(--danger);
  border: 1.5px solid #F4C7C3;
  border-radius: 999px;
  font: 700 14px "Space Grotesk", system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .2s, color .2s, border-color .2s;
}

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

.btn-danger-outline:focus-visible {
  outline-color: var(--danger);
}

.btn-danger-outline:disabled {
  opacity: .45;
  pointer-events: none;
}

/* Forms & Login Box */
.form-box,
.login-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  width: min(400px, 100%);
  margin: 10px 0;
  box-shadow: var(--sh);
}

.login-box {
  width: 100%;
  padding: 0;
  border-radius: 20px;
}

.box-hdr {
  margin: 0;
  padding: 16px 18px;
  font-size: 16px;
}

.box-body {
  padding: 20px 18px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label,
.row label {
  display: block;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
}

/* 16px font size stops iOS Safari zooming the page on focus */
input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  background: var(--soft);
  color: var(--fg);
  border: 1.5px solid transparent;
  border-radius: 12px;
  font: 500 16px "Space Grotesk", system-ui, sans-serif;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

input:focus {
  outline: 0;
  background: #fff;
  border-color: var(--nitro);
  box-shadow: 0 0 0 4px rgba(255, 69, 0, .12);
}

/* Date inputs render consistently on iOS Safari */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 48px;
}

.field-help {
  font-size: 12px;
  color: var(--mut);
  margin-top: 6px;
}

.row {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
}

.row label {
  width: 90px;
  text-align: right;
  margin: 0;
  color: var(--mut);
  flex: none;
}

.row input {
  flex: 1;
  width: auto;
}

.login-box .btn {
  margin-left: 100px;
}

/* Add / Edit Expense form inside the main container */
.main-container .form-box {
  width: 100%;
  margin: 0;
  box-shadow: none;
  background: transparent;
  border: 0;
  padding: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.form-actions .btn-cancel {
  margin-left: 0;
}

/* Login Page Body Layout */
.page-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 15px;
}

body:has(.page-body) {
  display: flex;
  flex-direction: column;
}

.center-container {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-col {
  width: min(320px, 100%);
  margin-bottom: 22px;
}

.brand-col text {
  fill: var(--fg);
}

.brand-col text+text {
  fill: var(--mut);
}

footer {
  text-align: center;
  padding: 16px 0 28px;
  color: var(--mut);
  font-size: 12px;
}

/* Flash Messages */
.flash-msg {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 13px;
}

.flash-danger,
.flash-error,
.flash-warning {
  background: #FFECE6;
  color: #C23400;
}

.flash-success {
  background: #E3F7F4;
  color: #007A6C;
}

.flash-info,
.flash-message {
  background: var(--soft);
  color: var(--mut);
}

/* Table */
.user-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.user-table th {
  color: var(--mut);
  font-weight: 600;
  text-align: left;
  padding: 4px 14px;
  font-size: 12px;
  border: 0;
  background: none;
}

.user-table td {
  padding: 6px 14px;
  background: var(--soft);
  color: var(--fg);
  vertical-align: middle;
  transition: background .2s;
}

.user-table td:first-child {
  border-radius: 12px 0 0 12px;
}

.user-table td:last-child {
  border-radius: 0 12px 12px 0;
}

.user-table tr:hover td {
  background: var(--tint);
}

.user-table td a,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 48px;
  color: var(--teal);
  background: none;
  border: 0;
  cursor: pointer;
  font: 600 14px "Space Grotesk", system-ui, sans-serif;
}

.user-table td a:hover,
.action-btn:hover {
  text-decoration: underline;
}

.delete-btn {
  color: var(--danger);
}

/* View Expenses */
.total-box {
  margin: 0 0 14px;
}

.total-val {
  color: var(--nitro);
  font-size: 16px;
}

.total-val,
.expense-table .num {
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.user-table .num {
  text-align: right;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.user-table .empty-cell {
  text-align: center;
  padding: 28px 14px;
  border-radius: 12px;
  color: var(--mut);
}

.empty-cell p {
  margin-bottom: 12px;
}

/* Buttons inside the empty state must beat the ".user-table td a" link style */
.user-table .empty-cell .btn {
  color: #fff;
  background: var(--nitro);
  min-height: 48px;
  min-width: 48px;
}

.user-table .empty-cell .btn:hover {
  background: var(--nitro-hi);
  text-decoration: none;
}

.user-table .empty-cell .btn-cancel {
  color: var(--fg);
  background: var(--line);
  margin-left: 0;
}

.user-table .empty-cell .btn-cancel:hover {
  text-decoration: none;
}

/* Toolbar */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.page-actions .btn-cancel {
  margin-left: 0;
}

.page-actions .spacer {
  flex: 1 1 auto;
}

.toolbar-form {
  display: flex;
}

/* The expenses toolbar sits above the content, so it needs bottom space instead of top */
.page-actions.toolbar {
  margin: 0 0 16px;
}

/* Date filter */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
}

.filter-form .status-label {
  margin-right: 2px;
}

.filter-form input[type="date"] {
  width: auto;
  flex: 1 1 160px;
  max-width: 220px;
}

.filter-form .btn-cancel {
  margin-left: 0;
}

.inline-form {
  display: inline;
}

/* Summary: two side-by-side stats */
.total-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 0;
  padding: 14px 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.stat .status-val {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.stat .total-val {
  font-size: 20px;
}

/* Expense table: desktop actions column */
.expense-table th.act-col {
  width: 1%;
}

.expense-table .c-act {
  white-space: nowrap;
  text-align: right;
}

.expense-table .action-btn {
  min-height: 44px;
  padding: 0 10px;
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

.expense-table .delete-btn {
  color: var(--danger);
}

/* Mobile & Touch Responsive Adaptation */
@media (max-width: 768px) {
  .action-grid {
    grid-template-columns: 1fr;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row label {
    width: auto;
    text-align: left;
  }

  .login-box .btn {
    margin-left: 0;
    width: 100%;
  }

  .form-box {
    width: 100%;
  }

  /* Room for the sticky action bar, only on pages that have one */
  .main-container:has(.form-actions) {
    padding-bottom: 96px;
  }

  .form-box form>div:last-child {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    gap: 8px;
    margin: 0 !important;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }

  .form-box form>div:last-child .btn-submit {
    flex: 1;
  }

  .btn-cancel {
    margin-left: 0 !important;
  }

  .page-actions .btn,
  .page-actions .btn-cancel,
  .page-actions .toolbar-form {
    flex: 1 1 100%;
  }

  .toolbar-form .btn-danger-outline {
    width: 100%;
  }

  .page-actions .spacer {
    display: none;
  }

  .filter-form input[type="date"] {
    max-width: none;
    flex: 1 1 100%;
  }

  .filter-form .btn,
  .filter-form .btn-cancel {
    flex: 1 1 auto;
  }
}

/* Phones: expense table becomes stacked cards (no sideways scrolling) */
@media (max-width: 640px) {
  .table-wrap {
    overflow: visible;
  }

  .expense-table,
  .expense-table tbody,
  .expense-table tr,
  .expense-table td {
    display: block;
    width: 100%;
  }

  .expense-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .expense-table {
    border-spacing: 0;
  }

  .expense-table tr:not(.empty-row) {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: baseline;
    background: var(--soft);
    border-radius: var(--r);
    padding: 12px 14px 4px;
    margin-bottom: 10px;
  }

  .expense-table td,
  .expense-table td:first-child,
  .expense-table td:last-child {
    background: none;
    border-radius: 0;
    padding: 0;
  }

  .expense-table tr:hover td {
    background: none;
  }

  .expense-table .c-date {
    grid-column: 1;
    grid-row: 1;
    font-size: 12px;
    color: var(--mut);
  }

  .expense-table .c-amt {
    grid-column: 2;
    grid-row: 1;
    font-weight: 700;
    color: var(--nitro);
    font-size: 16px;
  }

  .expense-table .c-name {
    grid-column: 1 / -1;
    grid-row: 2;
    font-weight: 600;
    font-size: 15px;
    overflow-wrap: anywhere;
  }

  .expense-table .c-act {
    grid-column: 1 / -1;
    grid-row: 3;
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 6px;
    padding-top: 2px;
    border-top: 1px solid var(--line);
  }

  .expense-table .action-btn {
    min-width: 64px;
  }

  /* Empty state is a single row, keep it as a normal block */
  .expense-table .empty-row,
  .expense-table .empty-cell {
    display: block;
    background: var(--soft);
    border-radius: var(--r);
    padding: 24px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}