:root {
  --bg: #f3f0ea;
  --sidebar: #111719;
  --panel: #ffffff;
  --ink: #172024;
  --muted: #667075;
  --line: rgba(23, 32, 36, .12);
  --copper: #a86b2d;
  --copper-2: #c8843e;
  --green: #2f7740;
  --blue: #315d7a;
  --red: #9a3526;
  --shadow: 0 18px 55px rgba(22, 23, 24, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

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

.admin-sidebar {
  background:
    radial-gradient(circle at 20% 0%, rgba(168,107,45,.18), transparent 34%),
    var(--sidebar);
  color: white;
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-brand {
  display: grid;
  gap: 12px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.admin-brand img {
  width: 190px;
  display: block;
}

.admin-brand span {
  color: rgba(255,255,255,.64);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
}

.admin-nav {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.admin-nav a,
.admin-sidebar-foot a {
  display: block;
  padding: 13px 14px;
  border-radius: 12px;
  color: rgba(255,255,255,.72);
  font-weight: 800;
}

.admin-nav a:hover,
.admin-nav a.is-active {
  background: rgba(255,255,255,.08);
  color: white;
}

.admin-nav a.is-active {
  box-shadow: inset 3px 0 0 var(--copper-2);
}

.admin-sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,.12);
}

.admin-main-wrap {
  min-width: 0;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 30px 34px;
  background: rgba(255,255,255,.62);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 2;
}

.admin-topbar span {
  color: var(--copper);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 12px;
  font-weight: 900;
}

.admin-topbar h1 {
  margin: 6px 0 0;
  font-size: 30px;
  letter-spacing: -.04em;
}

.admin-user {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 800;
}

.admin-main {
  padding: 34px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stats-grid article,
.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-grid article {
  padding: 22px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}

.stats-grid strong {
  display: block;
  margin-top: 12px;
  font-size: 44px;
  letter-spacing: -.06em;
}

.admin-grid {
  display: grid;
  gap: 20px;
}

.admin-grid.two-col {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr);
}

.admin-grid.detail-grid {
  grid-template-columns: minmax(0, 1fr) 380px;
}

.admin-card {
  padding: 24px;
}

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

.card-title-row h2,
.admin-card h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -.03em;
}

.card-title-row a,
.small-button,
.admin-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f3eee6;
  color: var(--copper);
  font-weight: 900;
  border: 1px solid rgba(168,107,45,.18);
  cursor: pointer;
}

.admin-button {
  min-height: 46px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--copper), var(--copper-2));
  color: #fff;
  border: 0;
  border-radius: 12px;
}

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

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

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 15px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

td span {
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 900;
  text-transform: capitalize;
  font-size: 12px;
  background: #eceff0;
  color: var(--muted);
}

.status-new { background: #f6e7d8; color: var(--copper); }
.status-contacted { background: #e4eef4; color: var(--blue); }
.status-quoted { background: #e6f1e7; color: var(--green); }
.status-closed { background: #e8e8e8; color: #555; }
.status-archived { background: #f0e2df; color: var(--red); }

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

.simple-list a {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.simple-list a:hover {
  border-color: rgba(168,107,45,.35);
}

.simple-list span {
  color: var(--muted);
  font-size: 13px;
}

.details-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 26px;
}

.details-list div {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
  margin-bottom: 7px;
}

dd {
  margin: 0;
  font-weight: 800;
}

.message-box {
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: 14px;
  padding: 16px;
  color: var(--ink);
  line-height: 1.65;
}

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

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

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

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 900;
  font-size: 14px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
}

.checkbox-label input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: 12px;
  padding: 13px 14px;
  font: inherit;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(168,107,45,.22);
  border-color: rgba(168,107,45,.55);
}

.editor-card {
  max-width: 980px;
}

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

.media-item {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.media-item img {
  width: 84px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #eee;
}

.media-item div {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.media-item code {
  background: #f2eee7;
  border-radius: 8px;
  padding: 6px 8px;
  overflow-x: auto;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 0%, rgba(168,107,45,.24), transparent 34%),
    #111719;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 34px;
  box-shadow: 0 30px 90px rgba(0,0,0,.26);
}

.login-card img {
  width: 220px;
  display: block;
  margin-bottom: 26px;
}

.login-card h1 {
  margin: 0 0 8px;
  letter-spacing: -.04em;
}

.login-card p,
.admin-card p {
  color: var(--muted);
  line-height: 1.55;
}

.error-box {
  padding: 13px 14px;
  border-radius: 12px;
  background: #f4e1dc;
  color: var(--red);
  border: 1px solid rgba(154,53,38,.2);
  font-weight: 900;
  margin: 14px 0;
}

@media (max-width: 1050px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-nav,
  .admin-sidebar-foot {
    display: flex;
    flex-wrap: wrap;
  }

  .admin-grid.two-col,
  .admin-grid.detail-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .admin-main,
  .admin-topbar,
  .admin-sidebar {
    padding: 20px;
  }

  .form-row.two,
  .details-list {
    grid-template-columns: 1fr;
  }

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

/* Staff/admin expansion */
.admin-nav hr {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(255,255,255,.12);
  margin: 10px 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}

.narrow-card {
  max-width: 860px;
}

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

.compact-table td,
.compact-table th {
  padding: 10px 8px;
}

.check-label {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.check-label input {
  width: auto;
}

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

.help-text {
  color: var(--muted);
  line-height: 1.6;
}

.status-approved,
.status-scheduled {
  background: #e4eef4;
  color: var(--blue);
}

.status-in_progress {
  background: #f6e7d8;
  color: var(--copper);
}

.status-completed {
  background: #e6f1e7;
  color: var(--green);
}

.status-cancelled {
  background: #f0e2df;
  color: var(--red);
}

@media (max-width: 980px) {
  .permission-grid,
  .filter-row {
    grid-template-columns: 1fr;
  }
}


/* Role editor polish */
.role-editor-grid {
  grid-template-columns: minmax(0, 1fr);
}

.role-editor-main {
  padding: 28px;
}

.role-card-title {
  align-items: flex-start;
  margin-bottom: 24px;
}

.role-card-title p,
.permissions-header-row p,
.permission-section-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.role-summary-chip {
  min-width: 160px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(168,107,45,.08), rgba(200,132,62,.18));
  border: 1px solid rgba(168,107,45,.16);
  text-align: right;
}

.role-summary-chip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 900;
}

.role-summary-chip strong {
  display: block;
  margin-top: 8px;
  font-size: 36px;
  letter-spacing: -.05em;
}

.role-editor-form {
  gap: 22px;
}

.info-banner {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(168,107,45,.2);
  background: #faf4eb;
  color: var(--copper);
  font-weight: 800;
}

.role-meta-grid {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(0, 1.2fr);
  gap: 18px;
}

.role-description-field textarea {
  min-height: 132px;
}

.permissions-header-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-top: 6px;
}

.permissions-header-row h3,
.permission-section-head h4 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -.03em;
}

.permission-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.permission-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #fff, #fbfaf7);
  box-shadow: 0 10px 28px rgba(22, 23, 24, .04);
}

.permission-section-head {
  margin-bottom: 16px;
}

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

.permission-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.permission-item:hover {
  border-color: rgba(168,107,45,.28);
  box-shadow: 0 8px 24px rgba(168,107,45,.08);
  transform: translateY(-1px);
}

.permission-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.permission-item-box {
  display: grid;
  gap: 4px;
}

.permission-item-box strong {
  font-size: 15px;
  line-height: 1.35;
}

.permission-item-box small {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.form-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--copper), var(--copper-2));
  color: white;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(168,107,45,.24);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(168,107,45,.28);
}

@media (max-width: 1080px) {
  .permission-group-grid,
  .role-meta-grid {
    grid-template-columns: 1fr;
  }

  .role-card-title,
  .form-actions-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .role-summary-chip {
    text-align: left;
  }
}


/* Admin button reactivity polish */
.card-title-row a,
.small-button,
.admin-button,
.primary-button,
.footer-button {
  position: relative;
  overflow: hidden;
  transform: translateY(0);
  transition:
    transform .18s ease,
    box-shadow .18s ease,
    border-color .18s ease,
    background .18s ease,
    color .18s ease,
    opacity .18s ease;
}

.card-title-row a::before,
.small-button::before,
.admin-button::before,
.primary-button::before,
.footer-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255,255,255,.38) 45%, transparent 70%);
  transform: translateX(-120%);
  transition: transform .42s ease;
  pointer-events: none;
}

.card-title-row a:hover,
.small-button:hover {
  transform: translateY(-2px);
  border-color: rgba(168,107,45,.42);
  background: #fff7ed;
  box-shadow: 0 14px 30px rgba(168,107,45,.14);
  color: var(--copper);
}

.admin-button:hover,
.primary-button:hover,
.footer-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(168,107,45,.28);
}

.card-title-row a:hover::before,
.small-button:hover::before,
.admin-button:hover::before,
.primary-button:hover::before,
.footer-button:hover::before {
  transform: translateX(120%);
}

.card-title-row a:active,
.small-button:active,
.admin-button:active,
.primary-button:active,
.footer-button:active {
  transform: translateY(0) scale(.985);
  box-shadow: 0 8px 18px rgba(168,107,45,.16);
}

.card-title-row a:focus-visible,
.small-button:focus-visible,
.admin-button:focus-visible,
.primary-button:focus-visible,
.footer-button:focus-visible {
  outline: 3px solid rgba(168,107,45,.28);
  outline-offset: 3px;
}

.small-button[disabled],
.admin-button[disabled],
.primary-button[disabled] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .card-title-row a,
  .small-button,
  .admin-button,
  .primary-button,
  .footer-button,
  .card-title-row a::before,
  .small-button::before,
  .admin-button::before,
  .primary-button::before,
  .footer-button::before {
    transition: none;
  }
}


/* Password reset / account setup */
.login-help-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--copper);
  font-weight: 900;
}

.success-box,
.info-banner {
  padding: 13px 14px;
  border-radius: 12px;
  font-weight: 900;
  margin: 14px 0;
}

.success-box {
  background: #e6f1e7;
  color: var(--green);
  border: 1px solid rgba(47,119,64,.2);
}

.info-banner {
  background: #faf4eb;
  color: var(--copper);
  border: 1px solid rgba(168,107,45,.2);
}


/* Login mobile-friendly controls */
html,
body {
  max-width: 100%;
}

body.login-page-body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(168,107,45,.24), transparent 34%),
    #111719;
}

.login-screen {
  min-height: 100svh;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3.5vh, 32px);
  overflow: hidden;
}

.login-card {
  box-sizing: border-box;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
}

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

.password-field {
  position: relative !important;
  display: block !important;
  width: 100%;
}

.password-field input {
  width: 100%;
  padding-right: 54px !important;
}

.password-toggle {
  position: absolute !important;
  right: 8px !important;
  top: 50% !important;
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
  max-width: 42px !important;
  max-height: 42px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: transparent !important;
  color: #667482 !important;
  cursor: pointer;
  transform: translateY(-50%) !important;
  display: grid !important;
  place-items: center !important;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden !important;
  font-size: 0 !important;
  line-height: 1 !important;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: rgba(168,107,45,.12) !important;
  color: var(--copper) !important;
  box-shadow: 0 8px 18px rgba(168,107,45,.12);
  outline: none;
}

.password-toggle .eye-icon {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  display: block;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2.1 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.password-toggle .eye-open circle {
  fill: currentColor !important;
  stroke: none !important;
}

.password-toggle .eye-off {
  display: none !important;
}

.password-toggle.is-visible .eye-open {
  display: none !important;
}

.password-toggle.is-visible .eye-off {
  display: block !important;
}

.password-toggle-text {
  display: none;
}

.remember-row {
  display: grid !important;
  grid-template-columns: 24px minmax(0, 1fr) !important;
  align-items: center !important;
  column-gap: 12px !important;
  margin: 2px 0 8px !important;
  padding: 13px 15px !important;
  border: 1px solid rgba(168,107,45,.22) !important;
  border-radius: 14px !important;
  background: linear-gradient(180deg, #fffaf3, #f8f3ea) !important;
  color: var(--ink) !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(40,28,16,.05);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.remember-row input {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.remember-check {
  width: 22px !important;
  height: 22px !important;
  border: 2px solid rgba(168,107,45,.38) !important;
  border-radius: 7px !important;
  background: #fff !important;
  display: grid !important;
  place-items: center !important;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.remember-check::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg) scale(0);
  margin-top: -2px;
  transition: transform .16s ease;
}

.remember-row input:checked + .remember-check {
  background: var(--copper) !important;
  border-color: var(--copper) !important;
  box-shadow: 0 8px 18px rgba(168,107,45,.22);
}

.remember-row input:checked + .remember-check::after {
  transform: rotate(-45deg) scale(1);
}

.remember-row span:last-child {
  line-height: 1.3;
  min-width: 0;
}

@media (max-width: 520px) {
  body.login-page-body {
    overflow-x: hidden !important;
  }

  .login-screen {
    min-height: 100svh;
    padding: 10px;
    align-items: start;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .login-card {
    width: min(100%, 420px) !important;
    max-height: none;
    overflow: visible;
    border-radius: 20px;
    padding: 24px;
    margin: 10px auto;
  }

  .login-card img {
    width: min(190px, 78%);
    margin-bottom: 20px;
  }

  .password-field {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .password-field input {
    padding-right: 16px !important;
  }

  .password-toggle {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 42px !important;
    max-height: none !important;
    transform: none !important;
    border: 1px solid rgba(168,107,45,.24) !important;
    border-radius: 12px !important;
    background: #fffaf3 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 9px !important;
    color: var(--copper) !important;
    font-weight: 900 !important;
    font-size: 13px !important;
    overflow: hidden !important;
  }

  .password-toggle .eye-icon {
    display: none !important;
  }

  .password-toggle-text {
    display: inline !important;
    font-size: 13px !important;
  }

  .remember-row {
    grid-template-columns: 22px minmax(0, 1fr) !important;
    padding: 12px !important;
    font-size: 13px !important;
  }

  .remember-check {
    width: 20px !important;
    height: 20px !important;
  }
}
