:root {
  --ink: #151821;
  --muted: #707887;
  --paper: #f2f0ea;
  --panel: #ffffff;
  --line: #ded7ca;
  --line-soft: #eee8dc;
  --accent: #0f6b5f;
  --accent-dark: #0a5148;
  --gold: #c9a25d;
  --gold-soft: #f4ead8;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
  --shadow: 0 24px 70px rgba(21, 24, 33, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background:
    linear-gradient(180deg, #f8f5ef 0, var(--paper) 420px),
    var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}

body:not(.is-authenticated) .topbar,
body:not(.is-authenticated) .app-shell,
body:not(.is-authenticated) .app-footer {
  display: none;
}

body.is-authenticated:not(.is-admin) .panel[data-requires="admin"] {
  display: none;
}

body.is-authenticated:not(.is-superadmin) [data-requires="superadmin"],
body.is-authenticated:not(.is-superadmin) [data-super-only] {
  display: none;
}

body.is-viewer [data-requires="export"] {
  display: none;
}

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

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid rgba(201, 162, 93, 0.22);
  background: rgba(255, 252, 246, 0.88);
  backdrop-filter: blur(18px);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 14% 18%, rgba(201, 162, 93, 0.34), transparent 28%),
    linear-gradient(135deg, rgba(6, 31, 31, 0.9), rgba(21, 24, 33, 0.96)),
    url("../assets/hotel-hero-pool-20260701.jpg") center / cover;
}

.login-screen.is-hidden {
  display: none;
}

.login-stage {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(20px);
}

.login-cover {
  position: relative;
  min-height: 620px;
  margin: 0;
  overflow: hidden;
}

.login-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.login-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 38%, rgba(0, 0, 0, 0.7));
}

.login-cover figcaption {
  position: absolute;
  right: 28px;
  bottom: 26px;
  left: 28px;
  z-index: 1;
  color: #ffffff;
}

.login-cover span,
.hotel-cover-card span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 800;
}

.login-cover strong,
.hotel-cover-card strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

.login-card {
  display: grid;
  gap: 16px;
  align-content: center;
  padding: clamp(26px, 4vw, 42px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(250, 247, 240, 0.97));
}

.login-card h1 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: clamp(28px, 7vw, 42px);
}

.login-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-hint {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  color: var(--muted);
  background: #f8f3e9;
  font-size: 13px;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #1b1e27, #0f6b5f);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  color: var(--gold);
  font-size: 11px;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.site-nav a {
  padding: 8px 0;
}

.site-nav a:hover {
  color: var(--accent);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--ink);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 48px) 42px;
}

.hero-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 28px;
  align-items: center;
  min-height: 360px;
  padding: clamp(26px, 5vw, 56px);
  border-radius: 8px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(7, 34, 34, 0.96), rgba(21, 24, 33, 0.88)),
    url("../assets/hotel-hero-pool-20260701.jpg") center / cover;
  box-shadow: var(--shadow);
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(201, 162, 93, 0.34);
  border-radius: 8px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-panel .eyebrow {
  color: var(--gold);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 14px;
  font-size: clamp(34px, 4.4vw, 54px);
  line-height: 1.04;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.hero-panel p:last-child {
  max-width: 760px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
}

.quick-actions,
.hero-panel > div:first-child,
.hotel-cover-card {
  position: relative;
  z-index: 1;
}

.quick-actions {
  grid-column: 1;
}

.hotel-cover-card {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: stretch;
  min-height: 260px;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.hotel-cover-card img {
  width: 100%;
  height: 100%;
  min-height: 260px;
  display: block;
  object-fit: cover;
}

.hotel-cover-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 48%, rgba(0, 0, 0, 0.72));
}

.hotel-cover-card figcaption {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  z-index: 1;
  color: #ffffff;
}

.quick-actions {
  display: flex;
  gap: 10px;
}

.primary-action,
.secondary-action,
.text-action {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 800;
}

.primary-action {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), #124f49);
  box-shadow: 0 10px 24px rgba(15, 107, 95, 0.24);
}

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

.secondary-action.dark {
  color: #ffffff;
  border-color: var(--ink);
  background: var(--ink);
}

.secondary-action.danger {
  color: #ffffff;
  border-color: #7f1d1d;
  background: #991b1b;
}

.secondary-action {
  color: #ffffff;
  border-color: rgba(201, 162, 93, 0.58);
  background: rgba(255, 255, 255, 0.1);
}

.text-action {
  color: var(--accent);
  background: #f2eadb;
}

.text-action.danger {
  color: var(--red);
  background: #fee2e2;
}

.is-disabled {
  opacity: 0.56;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

.full {
  width: 100%;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric-grid article,
.panel {
  border: 1px solid rgba(222, 215, 202, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 44px rgba(21, 24, 33, 0.08);
}

.metric-grid article {
  padding: 20px;
  background:
    linear-gradient(180deg, #ffffff, #fbf8f1);
}

.metric-grid span,
.metric-grid small {
  display: block;
  color: var(--muted);
}

.metric-grid strong {
  display: block;
  margin: 8px 0 2px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
  color: #141821;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  gap: 18px;
  align-items: start;
}

.main-column,
.side-column {
  display: grid;
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #ffffff, #fcfaf5);
}

.panel-heading.compact {
  align-items: center;
}

.table-tools {
  display: flex;
  gap: 10px;
  align-items: end;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fffefa;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 93, 0.16);
}

.stock-table-wrap {
  overflow-x: auto;
}

.stock-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 14px;
}

.stock-table th,
.stock-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
}

.stock-table th {
  color: #6d5a35;
  background: #fbf6ea;
  font-size: 12px;
  text-transform: uppercase;
}

.stock-table td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stock-table b {
  margin-right: 3px;
  font-size: 18px;
}

.stock-bar {
  width: 86px;
  height: 6px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.stock-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.status {
  display: inline-flex;
  min-width: 58px;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 800;
}

.status.ok {
  color: var(--accent-dark);
  background: #dff6ee;
}

.status.warning {
  color: var(--amber);
  background: #fef3c7;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 18px 20px 0;
  padding: 5px;
  border-radius: 8px;
  background: #eee7da;
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segmented-control button.is-active {
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 5px 18px rgba(23, 32, 42, 0.08);
}

.movement-form,
.item-form,
.account-form,
.data-maintenance {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.movement-form label,
.item-form label,
.account-form label,
.data-maintenance label,
.password-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-row {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
}

.form-message {
  min-height: 21px;
  margin: 0;
  color: var(--accent);
  font-weight: 800;
}

.form-message.is-error {
  color: var(--red);
}

.purchase-list,
.activity-list,
.audit-list {
  display: grid;
  gap: 10px;
  padding: 20px;
}

.purchase-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid rgba(201, 162, 93, 0.46);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffaf0, #fff6df);
}

.purchase-item strong,
.purchase-item span {
  display: block;
}

.purchase-item span,
.activity-list small,
.empty-state,
.empty-cell {
  color: var(--muted);
}

.purchase-item b {
  color: var(--amber);
  white-space: nowrap;
}

.activity-list {
  margin: 0;
  list-style: none;
  counter-reset: activity;
}

.activity-list li,
.audit-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.activity-list li:last-child,
.audit-list li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.activity-type {
  display: inline-flex;
  min-width: 42px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.activity-type.in {
  background: var(--blue);
}

.activity-type.out {
  background: var(--accent);
}

.activity-list strong,
.activity-list small,
.audit-list strong,
.audit-list small {
  display: block;
}

.audit-list {
  margin: 0;
  list-style: none;
}

.audit-time {
  min-width: 138px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.account-list,
.device-list {
  display: grid;
  gap: 8px;
  padding: 0 20px 20px;
}

.account-row,
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fffefa;
}

.account-row strong,
.account-row span,
.device-row strong,
.device-row span {
  display: block;
}

.account-row span,
.device-row span {
  color: var(--muted);
  font-size: 12px;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-pill {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  color: #6d5a35;
  background: var(--gold-soft);
  font-size: 12px;
  font-weight: 800;
}

.role-pill.superadmin {
  color: #ffffff;
  background: linear-gradient(135deg, #151821, #8a6a2f);
}

.role-pill.admin {
  color: #0a5148;
  background: #dff6ee;
}

.role-pill.keeper {
  color: #6d5a35;
  background: var(--gold-soft);
}

.role-pill.viewer {
  color: #344054;
  background: #edf1f4;
}

.text-action.compact {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.device-group {
  display: grid;
  gap: 8px;
}

.device-group > strong {
  color: var(--muted);
  font-size: 12px;
}

.clear-data-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}

.clear-data-box strong,
.clear-data-box span {
  display: block;
}

.clear-data-box strong {
  color: #7f1d1d;
}

.clear-data-box span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state.compact {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.password-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid rgba(222, 215, 202, 0.9);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.password-dialog::backdrop {
  background: rgba(15, 24, 28, 0.58);
  backdrop-filter: blur(7px);
}

.password-card {
  margin: 0;
}

.password-fields {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.empty-state,
.empty-cell {
  padding: 22px;
  text-align: center;
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px) 34px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1050px) {
  .workspace-grid,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .hotel-cover-card {
    grid-row: auto;
    grid-column: 1;
    min-height: 240px;
  }

  .quick-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 760px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    position: absolute;
    top: 64px;
    right: 84px;
    display: none;
    width: min(260px, calc(100vw - 32px));
    flex-direction: column;
    gap: 0;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
  }

  .site-nav.is-open {
    display: flex;
  }

  .site-nav a {
    padding: 12px;
  }

  .app-shell {
    padding-top: 16px;
  }

  .hero-panel {
    padding: 24px;
    min-height: 0;
  }

  .hero-panel::before {
    inset: 12px;
  }

  .hero-panel p:last-child {
    font-size: 15px;
  }

  .quick-actions,
  .panel-heading,
  .table-tools,
  .app-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-actions {
    display: grid;
  }

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

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

  .account-row,
  .device-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-actions {
    width: 100%;
    justify-content: space-between;
  }

  .purchase-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .purchase-item b {
    white-space: normal;
  }

  .user-actions {
    margin-left: auto;
  }

  .user-actions span {
    display: none;
  }

  .login-stage {
    grid-template-columns: 1fr;
  }

  .login-cover {
    min-height: 230px;
  }

  .login-cover strong,
  .hotel-cover-card strong {
    font-size: 20px;
  }
}

@media (max-width: 640px) {
  .topbar {
    min-height: 58px;
    padding-inline: 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 14px;
  }

  .brand small {
    display: none;
  }

  .app-shell {
    padding-inline: 12px;
  }

  h1 {
    font-size: 32px;
  }

  .metric-grid article,
  .panel-heading,
  .movement-form,
  .item-form,
  .purchase-list,
  .activity-list {
    padding: 16px;
  }

  .stock-table {
    min-width: 0;
  }

  .stock-table thead {
    display: none;
  }

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

  .stock-table tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-soft);
  }

  .stock-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 8px 0;
    border-bottom: 0;
    text-align: right;
  }

  .stock-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
  }

  .stock-table td:first-child {
    display: block;
    text-align: left;
  }

  .stock-table td:first-child::before {
    display: none;
  }

  .stock-bar {
    margin-left: auto;
  }

  .login-card {
    padding: 22px;
  }

  .hotel-cover-card,
  .hotel-cover-card img {
    min-height: 210px;
  }
}
