@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap");

:root {
  --bg: #fff3e8;
  --surface: #fffaf5;
  --surface-strong: #d96c1f;
  --surface-soft: #ffe2c7;
  --surface-soft-strong: #ffd0a6;
  --border: #f0c7a2;
  --border-strong: #e7a46f;
  --text: #412312;
  --muted: #8a5c42;
  --primary: #e97824;
  --primary-deep: #cc6113;
  --primary-contrast: #fff8f2;
  --secondary: #b84e08;
  --shadow: 0 18px 40px rgba(217, 108, 31, 0.18);
  --shadow-soft: 0 10px 24px rgba(176, 97, 34, 0.1);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Roboto", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(233, 120, 36, 0.18), transparent 24%),
    linear-gradient(180deg, #fff7ef 0%, #ffe9d5 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.auth-body,
.offline-body {
  display: grid;
  padding: 24px;
}

.auth-body {
  min-height: 100vh;
  place-items: start center;
}

.offline-body {
  min-height: 100vh;
  place-items: center;
}

.auth-layout {
  width: min(520px, 100%);
}

.auth-card,
.offline-card,
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 250, 245, 0.96) 100%);
  border: 1px solid rgba(240, 199, 162, 0.78);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(176, 97, 34, 0.08);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  width: fit-content;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.auth-lockup {
  margin-bottom: 28px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex: 0 0 auto;
}

.login-brand-logo {
  width: 88px;
  height: 88px;
}

.brand-copy {
  display: grid;
  gap: 4px;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #8b3c0d;
}

.brand-tagline {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.auth-card h2,
.offline-card h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0;
}

.auth-card,
.offline-card {
  padding: 36px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--secondary);
  font-weight: 700;
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 168, 94, 0.18) 0%, rgba(255, 168, 94, 0) 18%),
    linear-gradient(180deg, #d96c1f 0%, #c95f16 100%);
  color: var(--primary-contrast);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: inset -1px 0 0 rgba(255, 248, 242, 0.12);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  min-height: 88px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 248, 242, 0.14);
}

.sidebar-heading {
  display: grid;
  gap: 8px;
}

.menu {
  display: grid;
  gap: 10px;
  padding: 10px;
  border-radius: 22px;
  background: rgba(255, 248, 242, 0.08);
  border: 1px solid rgba(255, 248, 242, 0.08);
  backdrop-filter: blur(6px);
}

.sidebar-greeting {
  margin: 8px 0 0;
  color: rgba(255, 248, 242, 0.94);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.35;
}

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

.sidebar-brand h1 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.05;
}

.sidebar-brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 22px rgba(115, 47, 4, 0.18);
  flex: 0 0 auto;
}

.sidebar-brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.menu a {
  position: relative;
  padding: 14px 16px;
  border-radius: 16px;
  color: rgba(255, 248, 242, 0.82);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.menu a:hover,
.menu a.active {
  background: rgba(255, 248, 242, 0.16);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 242, 0.12);
}

.menu a.active::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #fff7ef;
  transform: translateY(-50%);
}

.menu a.active {
  padding-left: 28px;
}

.menu a:hover {
  transform: translateY(-1px);
}

.content {
  padding: 28px;
  display: grid;
  gap: 24px;
  align-content: start;
}

.page-header,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.page-toolbar {
  min-height: 72px;
  padding: 6px 0 0;
}

.page-toolbar h2,
.page-toolbar .eyebrow {
  margin-top: 0;
  margin-bottom: 0;
}

.page-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.filter-actions {
  display: flex;
  align-items: end;
}

.card {
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, rgba(233, 120, 36, 0.8), rgba(255, 201, 156, 0.2));
  pointer-events: none;
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

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

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
  color: #532c14;
  letter-spacing: 0.01em;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 248, 242, 0.9);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

input::placeholder {
  color: #8d7a6f;
}

input:hover,
select:hover {
  border-color: var(--border-strong);
  background: #fff;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(233, 120, 36, 0.14),
    inset 0 1px 0 rgba(255, 248, 242, 0.96);
  transform: translateY(-1px);
}

#client-form input:not([type="hidden"]),
#client-form select {
  text-transform: uppercase;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.btn-primary {
  background: linear-gradient(180deg, #f48a33 0%, var(--primary) 100%);
  color: var(--primary-contrast);
  box-shadow: 0 12px 24px rgba(233, 120, 36, 0.22);
}

.btn-secondary {
  background: linear-gradient(180deg, #ffe6ce 0%, var(--surface-soft) 100%);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.btn-ghost {
  background: rgba(255, 248, 242, 0.12);
  color: rgba(255, 248, 242, 0.92);
  border: 1px solid rgba(255, 248, 242, 0.12);
}

.sidebar-logout {
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 242, 0.06);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #ff9543 0%, var(--primary-deep) 100%);
  box-shadow: 0 14px 28px rgba(233, 120, 36, 0.28);
}

.btn-secondary:hover,
.btn-ghost:hover {
  box-shadow: 0 12px 22px rgba(176, 97, 34, 0.14);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(233, 120, 36, 0.3);
  outline-offset: 2px;
}

.message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--secondary);
  font-weight: 700;
  line-height: 1.45;
}

.debug-box {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.45;
  max-height: 220px;
  overflow: auto;
}

.table-wrapper {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--surface-soft);
  text-align: left;
}

th {
  color: #8b4c20;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.clickable-row {
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.clickable-row:hover {
  background: rgba(233, 120, 36, 0.08);
  transform: translateX(2px);
}

.items-list {
  display: grid;
  gap: 12px;
}

.item-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #fff;
}

.address-builder {
  display: grid;
  gap: 16px;
}

.address-row {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 248, 242, 0.95) 100%);
  box-shadow: var(--shadow-soft);
}

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

.address-row .section-title h4,
.address-builder .section-title h3,
.address-builder .section-title p {
  margin: 0;
}

.hidden {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(65, 35, 18, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1000;
}

.modal-card {
  width: min(920px, 100%);
  max-height: min(80vh, 900px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid rgba(240, 199, 162, 0.7);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.table-wrapper table {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  overflow: hidden;
}

.modal-overlay.hidden {
  display: none;
}

@media (max-width: 900px) {
  .auth-layout,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .auth-body {
    place-items: start center;
    padding: 0;
  }

  .auth-layout,
  .content {
    width: 100%;
  }

  .offline-card,
  .card {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .content,
  .offline-card {
    padding-left: 0;
    padding-right: 0;
  }

  .content,
  .sidebar {
    padding-top: 0;
    padding-bottom: 0;
  }

  .sidebar {
    gap: 10px;
    padding-left: 28px;
    padding-right: 28px;
    padding-bottom: 0;
    min-height: 0;
    height: auto;
  }

  .sidebar-header {
    min-height: 102px;
    padding-bottom: 10px;
  }

  .auth-card {
    border: 1px solid rgba(240, 199, 162, 0.7);
    border-radius: var(--radius);
    margin: 24px;
  }

  .menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 8px;
    border-radius: 18px 18px 0 0;
    background: rgba(255, 248, 242, 0.1);
  }

  .two-columns,
  .item-row,
  .address-row-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .section-title {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-toolbar {
    width: 100%;
    min-height: 88px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(240, 199, 162, 0.85);
  }

  .page-toolbar-actions-only {
    min-height: 92px;
  }

  .page-toolbar .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-toolbar-actions-only .page-actions .btn {
    border-left: 4px solid rgba(184, 78, 8, 0.65);
  }
}
