/* Apple-style mono palette — black primary, soft greys for accents */
:root {
  --apple-blue: #1d1d1f;
  --apple-blue-hover: #000000;
  --apple-blue-active: #2c2c2e;
  --apple-blue-soft: rgba(0, 0, 0, 0.06);
  --apple-blue-shadow: rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: fade-in 0.4s ease-out;
}

.error-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f5f5f7;
}
.error-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
  padding: 34px;
  text-align: center;
}
.error-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: #f5f5f7;
  color: #6e6e73;
  font-weight: 700;
  margin-bottom: 16px;
}
.error-card h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}
.error-card p {
  margin: 10px 0 0;
  color: #6e6e73;
}
.error-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.error-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid #1d1d1f;
  color: #1d1d1f;
  text-decoration: none;
  font-size: 14px;
}
.error-actions a {
  background: #1d1d1f;
  color: #fff;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ----- Top bar (Apple-style frosted glass) ----- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: #1d1d1f;
  padding: 0 28px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Hamburger menu button (hidden on desktop) */
.menu-btn {
  display: none;
  background: transparent;
  border: none;
  padding: 8px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.menu-btn:hover { background: rgba(0, 0, 0, 0.06); transform: none; box-shadow: none; }
.menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: #1d1d1f;
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s;
}
body.sidebar-open .menu-btn span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.sidebar-open .menu-btn span:nth-child(2) { opacity: 0; }
body.sidebar-open .menu-btn span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  height: 40px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.brand-logo:hover { transform: scale(1.04); }
.brand-name {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #1d1d1f;
}
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.current-user { color: #6e6e73; }
.link-btn {
  background: transparent;
  color: var(--apple-blue);
  border: 1px solid var(--apple-blue);
  padding: 6px 16px;
  border-radius: 980px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.link-btn:hover {
  background: var(--apple-blue);
  color: #fff;
  border-color: var(--apple-blue);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--apple-blue-shadow);
}

/* ----- Layout ----- */
.layout {
  display: flex;
  min-height: calc(100vh - 76px);
}

/* ----- Sidebar ----- */
.sidebar {
  position: relative;
  width: 240px;
  background: #fbfbfd;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  padding: 20px 12px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-collapse-btn { position:absolute; top:12px; right:-16px; z-index:5; width:32px; height:32px; padding:0; border:1px solid #d2d2d7; border-radius:50%; background:#fff; color:#515154; cursor:pointer; box-shadow:0 3px 10px rgba(0,0,0,.1); }
.sidebar-collapse-btn:hover { background:#f0f0f3; transform:none; box-shadow:0 3px 10px rgba(0,0,0,.14); }
body.sidebar-collapsed .sidebar { width:0; padding-left:0; padding-right:0; border-right:0; }
body.sidebar-collapsed .sidebar nav { overflow:hidden; opacity:0; pointer-events:none; }
body.sidebar-collapsed .sidebar-collapse-btn { right:-38px; transform:rotate(180deg); }
body.sidebar-collapsed .sidebar-collapse-btn:hover { transform:rotate(180deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 76px 0 0 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}
.sidebar nav ul { list-style: none; padding: 0; margin: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  line-height: 20px;
  border-radius: 8px;
  color: #424245;
  margin-bottom: 4px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item:hover { background: rgba(0, 0, 0, 0.04); color: #1d1d1f; }
.nav-item.active {
  background: var(--apple-blue-soft);
  color: var(--apple-blue);
  font-weight: 500;
}
.nav-icon {
  width: 22px;
  min-width: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}
.nav-label {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  line-height: 20px;
}

/* ----- Main content ----- */
.content {
  flex: 1;
  padding: 32px 40px;
  min-width: 0;
  animation: slide-up 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.view { display: none; }
.view.active { display: block; }
.view-header { margin-bottom: 24px; }
.view-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #1d1d1f;
}
.view-desc { margin: 6px 0 0; font-size: 14px; color: #6e6e73; }

/* ----- Home ----- */
.home-shell { min-height:calc(100vh - 140px); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:34px; text-align:center; }
.home-clock { width:100%; }
.home-date { color:#6e6e73; font-size:clamp(17px,2vw,24px); letter-spacing:.08em; }
.home-time { display:block; margin:8px 0 0; font-size:clamp(64px,12vw,168px); font-weight:650; line-height:1; letter-spacing:-.055em; font-variant-numeric:tabular-nums; }
.home-timezone { margin-top:14px; color:#86868b; font-size:13px; letter-spacing:.06em; }
.home-holiday-countdown { margin-top:13px; color:#515154; font-size:16px; font-weight:500; }
.home-facts { width:min(760px,100%); display:flex; align-items:stretch; gap:12px; }
#home-fun-facts { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; }
.home-fact { flex:1; margin:0; min-height:142px; padding:24px 26px; background:#fff; border:1px solid rgba(0,0,0,.06); border-radius:18px; box-shadow:0 8px 24px rgba(0,0,0,.04); text-align:left; }
.home-fact span { color:#86868b; font-size:12px; letter-spacing:.08em; }
.home-fact p { margin:13px 0 0; color:#1d1d1f; font-size:18px; line-height:1.75; white-space:pre-line; }
.home-fact .home-fact-english { font-size:19px; line-height:1.65; }
.home-fact .home-fact-chinese { margin-top:10px; color:#515154; font-size:17px; line-height:1.7; }
.home-fact-arrow { align-self:center; flex:0 0 auto; padding:10px; border:0; background:transparent; color:#86868b; font-size:30px; font-weight:400; line-height:1; box-shadow:none; }
.home-fact-arrow:hover { background:transparent; color:#515154; transform:scale(1.08); }
.home-fact-arrow:disabled { color:#d2d2d7; }
.home-fact-source { color:#86868b; font-size:12px; text-decoration:none; }
.home-fact-source:hover { color:#1d1d1f; text-decoration:underline; }

/* ----- Cards (floating, Apple-style) ----- */
.card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04),
              0 8px 24px rgba(0, 0, 0, 0.04);
  padding: 28px 32px;
  margin-bottom: 24px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04),
              0 16px 40px rgba(0, 0, 0, 0.08);
}
.card h2 {
  margin: 0 0 18px;
  font-size: 17px;
  font-weight: 600;
  color: #1d1d1f;
  letter-spacing: -0.01em;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-header h2 { margin: 0; }

.export-btn {
  background: #fff;
  color: var(--apple-blue);
  border: 1px solid var(--apple-blue);
  padding: 7px 16px;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.export-btn:hover:not(:disabled) {
  background: var(--apple-blue);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--apple-blue-shadow);
}
.export-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.export-icon { font-size: 14px; line-height: 1; }

.upload-card .file-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  transition: padding 0.2s ease;
}
.upload-card .file-row:last-of-type { border-bottom: none; }
.upload-card label { flex: 1; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.lbl-title { font-weight: 500; color: #1d1d1f; font-size: 14px; }
.lbl-hint { font-size: 12px; color: #86868b; }
input[type=file] {
  font-size: 13px;
  font-family: inherit;
  color: #424245;
}

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

button {
  font-family: inherit;
  font-size: 14px;
  border: none;
  cursor: pointer;
  padding: 10px 22px;
  border-radius: 980px;
  background: var(--apple-blue);
  color: #fff;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
button:hover:not(:disabled) {
  background: var(--apple-blue-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--apple-blue-shadow);
}
button:active:not(:disabled) {
  background: var(--apple-blue-active);
  transform: translateY(0);
}
button:disabled { background: #d2d2d7; cursor: not-allowed; color: #86868b; }

.status { font-size: 13px; color: #86868b; transition: color 0.2s; }
.status.error { color: #e30000; }
.status.success { color: #00a76f; }

.hidden { display: none; }

/* ----- Summary cards ----- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.summary-card {
  background: #f5f5f7;
  border-radius: 14px;
  padding: 16px 18px;
  border-left: 3px solid #c7c7cc;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: slide-up 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.summary-card:nth-child(1) { animation-delay: 0.02s; }
.summary-card:nth-child(2) { animation-delay: 0.06s; }
.summary-card:nth-child(3) { animation-delay: 0.10s; }
.summary-card:nth-child(4) { animation-delay: 0.14s; }
.summary-card:nth-child(5) { animation-delay: 0.18s; }
.summary-card:nth-child(6) { animation-delay: 0.22s; }
.summary-card:nth-child(7) { animation-delay: 0.26s; }
.summary-card:nth-child(8) { animation-delay: 0.30s; }
.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  background: #fff;
}
.summary-card.ok { border-left-color: #34c759; }
.summary-card.warn { border-left-color: #ff9500; }
.summary-card.bad { border-left-color: #ff3b30; }
.summary-card .label { font-size: 12px; color: #6e6e73; }
.summary-card .value {
  font-size: 28px;
  font-weight: 600;
  color: #1d1d1f;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

/* ----- Tabs ----- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  color: #6e6e73;
  border-radius: 0;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.tab:hover:not(.active) {
  color: #1d1d1f;
  background: transparent;
  transform: none;
  box-shadow: none;
}
.tab.active {
  color: var(--apple-blue);
  background: transparent;
  border-bottom-color: var(--apple-blue);
}
.badge {
  display: inline-block;
  background: rgba(0, 0, 0, 0.06);
  color: #424245;
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 9px;
  margin-left: 6px;
  font-weight: 600;
  transition: all 0.2s;
}
.tab.active .badge { background: rgba(0, 0, 0, 0.08); color: var(--apple-blue); }

.tab-panel { display: none; animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.tab-panel.active { display: block; }
.panel-hint { font-size: 13px; color: #6e6e73; margin: 0 0 14px; }

/* ----- Tables ----- */
.table-wrap {
  overflow-x: auto;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}
th {
  background: #fbfbfd;
  color: #424245;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  letter-spacing: -0.01em;
}
tbody tr {
  transition: background 0.15s;
}
tbody tr:hover { background: #fbfbfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.diff-pos { color: #00a76f; }
td.diff-neg { color: #e30000; }
tr.name-mismatch td { background: #fff1f0; }
tr.name-mismatch:hover td { background: #ffe6e3; }

.empty { text-align: center; color: #a1a1a6; padding: 32px; font-size: 13px; }

/* ----- Login page ----- */
.login-body {
  background: linear-gradient(180deg, #f5f5f7 0%, #fbfbfd 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}
.login-body::before, .login-body::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 8s ease-in-out infinite;
  pointer-events: none;
}
.login-body::before {
  width: 380px; height: 380px;
  background: radial-gradient(circle, #c7d2ff, transparent);
  top: -120px; left: -120px;
}
.login-body::after {
  width: 460px; height: 460px;
  background: radial-gradient(circle, #d6f1ff, transparent);
  bottom: -160px; right: -160px;
  animation-delay: 4s;
}
.login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  width: 380px;
  padding: 40px 36px 32px;
  border-radius: 24px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04),
              0 24px 60px rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.6);
  animation: slide-up 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo {
  height: 96px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-logo:hover { transform: scale(1.04); }
.login-title { font-size: 18px; font-weight: 600; color: #1d1d1f; letter-spacing: -0.01em; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #424245;
}
.login-form input {
  padding: 11px 14px;
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: rgba(255, 255, 255, 0.8);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-form input:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
  background: #fff;
}
.login-form button {
  margin-top: 8px;
  padding: 11px;
  font-size: 15px;
  font-weight: 500;
}
.login-error { color: #e30000; font-size: 13px; min-height: 18px; }
.login-link {
  color: #1d1d1f;
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}
.login-link:hover { text-decoration: underline; }

.admin-card .table-wrap { margin-top: 8px; }
.admin-card + .admin-card { margin-top: 20px; }
.muted { color: #86868b; font-size: 12px; }
.user-state { display: inline-block; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.user-state.active { color: #087f5b; background: #e6fcf5; }
.user-state.pending { color: #9c6500; background: #fff4d6; }
.user-state.inactive { color: #c9342b; background: #fff1f0; }
.user-reset-btn { white-space: nowrap; padding: 7px 10px; font-size: 12px; }
.user-permission-btn { white-space: nowrap; padding: 7px 10px; font-size: 12px; color: #2457a6; border-color: #9bb7df; background: #fff; }
.user-permission-btn:hover:not(:disabled) { color: #fff; background: #2457a6; border-color: #2457a6; }
.user-row-actions { display: flex; gap: 6px; white-space: nowrap; }
.user-status-btn { white-space: nowrap; padding: 7px 10px; border: 1px solid; font-size: 12px; }
.user-status-btn.activate { color: #087f5b; border-color: #83ccb4; }
.user-status-btn.deactivate { color: #c9342b; border-color: #eca19d; background: #fff; }
.user-status-btn.activate:hover:not(:disabled) { color: #fff; background: #087f5b; border-color: #087f5b; }
.user-status-btn.deactivate:hover:not(:disabled) { color: #fff; background: #c9342b; border-color: #c9342b; }
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #6e6e73;
}
.admin-form input {
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  min-height: 40px;
  padding: 8px 10px;
  font: inherit;
}
.admin-field-wide { grid-column: 1 / -1; }
.admin-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #6e6e73;
}
.role-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}
.role-options .role-option {
  flex-direction: row;
  align-items: center;
  color: #1d1d1f;
  border: 1px solid #d2d2d7;
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfbfd;
}
.role-option input { width: auto; min-height: auto; }
.admin-actions { display: flex; align-items: center; gap: 12px; }
.invite-link {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f5f5f7;
  border: 1px solid #d2d2d7;
  word-break: break-all;
  font-size: 13px;
}
.user-permission-modal { width: min(720px, 100%); }
.user-permission-body { padding: 16px; }
.user-permission-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; }

.asset-ledger-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.asset-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.asset-toolbar button,
.asset-modal button {
  border: 1px solid #d2d2d7;
  background: #fff;
  color: #1d1d1f;
  border-radius: 8px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}
.asset-toolbar button.primary,
.asset-modal button.primary {
  background: #1d1d1f;
  border-color: #1d1d1f;
  color: #fff;
}
.asset-modal button.green {
  background: #218838;
  border-color: #218838;
  color: #fff;
}
.asset-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.asset-stat {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 14px;
}
.asset-stat label {
  display: block;
  color: #6e6e73;
  font-size: 12px;
  margin-bottom: 6px;
}
.asset-stat strong {
  font-size: 24px;
  line-height: 1;
}
.asset-ledger-card { padding: 18px; }
.asset-filters {
  display: grid;
  grid-template-columns: 1.35fr repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.asset-filters input,
.asset-filters select,
.asset-modal input,
.asset-modal select,
.asset-modal textarea {
  width: 100%;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  min-height: 36px;
  padding: 7px 9px;
  background: #fff;
  color: #1d1d1f;
  font: inherit;
}
.asset-modal textarea { resize: vertical; min-height: 72px; }
.asset-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
}
.asset-tag.normal { color: #218838; background: #eef8f1; border-color: #b7dec0; }
.asset-tag.repair { color: #9a6700; background: #fff7e6; border-color: #e8c87a; }
.asset-tag.idle { color: #0f766e; background: #e9f7f5; border-color: #9bd4ce; }
.asset-tag.scrap { color: #c9342b; background: #fff1f0; border-color: #eca19d; }
.asset-tag.pending { color: #59636e; background: #f1f3f5; border-color: #cfd6de; }
.asset-row-actions { display: flex; gap: 6px; }
.asset-row-actions button {
  border: 1px solid #1d1d1f;
  background: #1d1d1f;
  color: #fff;
  border-radius: 8px;
  min-height: 30px;
  padding: 0 10px;
}
.asset-row-actions button:hover {
  background: #000;
  border-color: #000;
  color: #fff;
}
.asset-timeline {
  display: grid;
  gap: 10px;
}
.asset-history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: #6e6e73;
  font-size: 13px;
}
.asset-history-page-buttons {
  display: flex;
  gap: 8px;
}
.asset-history-page-buttons button {
  border: 1px solid #d2d2d7;
  background: #fff;
  color: #1d1d1f;
  border-radius: 8px;
  min-height: 32px;
  padding: 0 12px;
}
.asset-history-page-buttons button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.asset-event {
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.asset-event strong { display: block; margin-bottom: 5px; }
.asset-event p { margin: 0; color: #6e6e73; line-height: 1.5; }
.asset-notice {
  border-left: 4px solid #1d1d1f;
  background: #f5f5f7;
  padding: 10px 12px;
  color: #424245;
}
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 23, 0.42);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 200;
}
.modal-mask.active { display: flex; }
.asset-modal {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.24);
  border: 1px solid #d2d2d7;
}
.asset-modal h3 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e5ea;
  font-size: 18px;
}

/* ===== Stock order tracking ===== */
.stock-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
.stock-actions { display:flex; gap:8px; }
.stock-actions button, .stock-filters button, .stock-open-btn, .stock-module-head button, .stock-form-footer button, .stock-history-filters button {
  border:1px solid #d2d2d7; background:#fff; color:#1d1d1f; border-radius:8px; padding:9px 14px; cursor:pointer; font-weight:500;
}
.stock-actions .primary, .stock-form-footer .primary { color:#fff; background:#0071e3; border-color:#0071e3; }
.stock-actions button:hover:not(:disabled), .stock-filters button:hover:not(:disabled), .stock-open-btn:hover:not(:disabled), .stock-form-footer button:hover:not(:disabled), .stock-history-filters button:hover:not(:disabled) {
  color:#1d1d1f; background:#f0f0f3; border-color:#b8b8bd; box-shadow:none;
}
.stock-actions .primary:hover:not(:disabled), .stock-form-footer .primary:hover:not(:disabled) {
  color:#fff; background:#0077ed; border-color:#0077ed;
}
.stock-form-footer .danger:hover:not(:disabled) { color:#fff; background:#c9342b; border-color:#c9342b; }
.stock-filter-card { margin-bottom:16px; padding:16px; }
.stock-filters { display:grid; grid-template-columns:minmax(250px,2fr) repeat(4,minmax(125px,1fr)) auto; gap:10px; }
.stock-filters input, .stock-filters select, .stock-history-filters input {
  min-width:0; border:1px solid #d2d2d7; border-radius:8px; padding:10px 11px; background:#fff; color:#1d1d1f;
}
.stock-filters input.stock-date-required { border-color:#e30000; box-shadow:0 0 0 2px rgba(227,0,0,.12); }
.stock-list-card { padding:0; overflow:hidden; }
.stock-table { min-width:1180px; }
.stock-order-action { width:auto; min-width:76px; padding:6px 8px; border:1px solid #d2d2d7; border-radius:8px; background:#fff; font:inherit; cursor:pointer; }
.stock-table th:nth-child(4), .stock-table td:nth-child(4),
.stock-table th:nth-child(5), .stock-table td:nth-child(5) {
  width:1px;
}
.stock-customer-content, .stock-product-content {
  width:max-content;
  max-width:15em;
  white-space:normal;
  overflow-wrap:anywhere;
  word-break:break-all;
}
.stock-sort { display:inline-flex; align-items:center; gap:4px; padding:0; border:0; border-radius:0; background:transparent; color:inherit; font:inherit; font-weight:inherit; cursor:pointer; }
.stock-sort:hover:not(:disabled), .stock-sort.active { background:transparent; color:#0071e3; box-shadow:none; transform:none; }
.stock-sort span { min-width:12px; color:#86868b; }
.stock-state { display:inline-block; border-radius:999px; padding:4px 8px; font-size:12px; white-space:nowrap; border:1px solid transparent; }
.stock-state.done { color:#087f5b; background:#e6fcf5; border-color:#b7decf; }
.stock-state.pending { color:#9c6500; background:#fff4d6; border-color:#ead28d; }
.stock-state.unfilled { color:#59636e; background:#eef1f4; border-color:#cbd1d8; }
.stock-state.late, .stock-state.cancelled { color:#c9342b; background:#fff1f0; border-color:#eca19d; }
.stock-state.muted-state { color:#59636e; background:#f1f3f5; border-color:#d7dce1; }
.stock-modal { width:min(1100px,96vw); max-height:92vh; overflow:auto; background:#f5f5f7; border-radius:14px; box-shadow:0 24px 80px rgba(0,0,0,.24); }
.stock-modal-head { position:sticky; top:0; z-index:3; display:flex; justify-content:space-between; align-items:center; padding:18px 22px; background:rgba(255,255,255,.96); border-bottom:1px solid #e5e5ea; }
.stock-modal-head h3 { margin:0 0 3px; }.stock-modal-head span { color:#86868b; font-size:13px; }
.stock-modal-head > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #e9e9ed;
  cursor: pointer;
  color: #86868b;
  font-size: 20px;
  font-family: Arial, sans-serif;
  font-weight: 400;
  line-height: 1;
}
.stock-modal-head > button:hover:not(:disabled) {
  color:#515154;
  background:#d9d9de;
  box-shadow:none;
  transform:none;
}
#stock-order-form { padding:18px; }
.stock-modules { display:grid; gap:14px; }
.stock-module { background:#fff; border:1px solid #e5e5ea; border-radius:12px; padding:17px; }
.stock-module-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:14px; }
.stock-module-head h4 { margin:0; font-size:16px; }.stock-module-head button { padding:7px 11px; color:#087f5b; border-color:#83ccb4; }
.stock-module-head button:hover:not(:disabled) { color:#fff; background:#087f5b; border-color:#087f5b; box-shadow:none; }
.stock-form-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:13px; }
.stock-form-grid label, .stock-reason { display:flex; flex-direction:column; gap:6px; color:#515154; font-size:13px; }
.stock-form-grid label.wide { grid-column:span 3; }.stock-form-grid .stock-check { flex-direction:row; align-items:center; justify-content:flex-start; padding-top:23px; }
.stock-form-grid .stock-check input[type="checkbox"] { width:auto; flex:0 0 auto; margin:0 8px 0 0; }
.stock-form-grid input, .stock-form-grid select, .stock-form-grid textarea, .stock-reason input {
  width:100%; border:1px solid #d2d2d7; border-radius:8px; padding:9px 10px; background:#fff; color:#1d1d1f; font:inherit; box-sizing:border-box;
}
.stock-form-grid textarea { resize:vertical; min-height:68px; }.stock-form-grid input:disabled, .stock-form-grid textarea:disabled, .stock-form-grid select:disabled { background:#f3f3f5; color:#777; }
.stock-view-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
.stock-view-field { display:flex; min-height:64px; border:1px solid #e5e5ea; border-radius:8px; overflow:hidden; }
.stock-view-field strong { flex:0 0 110px; padding:10px; background:#f5f5f7; color:#515154; }
.stock-view-field span { padding:10px; white-space:pre-wrap; overflow-wrap:anywhere; }
.stock-purchase-items { grid-column:span 3; }
.stock-purchase-row { display:grid; grid-template-columns:38px 1fr 2fr 1fr auto auto; gap:8px; margin:7px 0; }
.stock-received-check { display:flex; align-items:center; gap:5px; white-space:nowrap; }
.stock-form-grid .stock-received-check input[type="checkbox"] { width:auto; margin:0; }
.stock-delivery-items { grid-column:span 3; }
.stock-delivery-row { display:grid; grid-template-columns:38px 1fr 1fr 2fr auto; gap:8px; margin:7px 0; }
.stock-production-expected-items, .stock-production-actual-items { grid-column:span 3; }
.stock-production-row { display:grid; grid-template-columns:38px 1fr 1fr 2fr auto; gap:8px; margin:7px 0; }
.stock-qc-expected-items, .stock-qc-actual-items { grid-column:span 3; }
.stock-qc-row { display:grid; grid-template-columns:38px 1fr 3fr auto; gap:8px; margin:7px 0; }
.stock-item-id { display:flex; align-items:center; justify-content:center; min-height:37px; border-radius:8px; background:#f3f3f5; color:#515154; font-weight:600; }
.stock-form-grid input.stock-item-missing { border-color:#d92d20; background:#fff1f0; box-shadow:0 0 0 1px rgba(217,45,32,.12); }
.stock-quantity-control { display:grid; grid-template-columns:minmax(80px,1fr) 72px; gap:6px; }
.stock-quantity-control input, .stock-quantity-control select { min-width:0; }
.stock-cancelled-row { background:#fff5f5; color:#777; }
.stock-delivery-late { color:#c9342b; background:#fff1f0; font-weight:600; }
.stock-form-grid em { color:#9c6500; font-style:normal; font-size:11px; }.stock-reason { margin-top:14px; }
.stock-form-footer { display:flex; justify-content:space-between; gap:10px; margin-top:16px; }.stock-form-footer > div { display:flex; gap:8px; }.stock-form-footer .danger { color:#c9342b; border-color:#eca19d; }
.stock-history-modal { width:min(1200px,96vw); padding-bottom:18px; }.stock-history-filters { display:flex; gap:9px; padding:16px 18px; }.stock-history-modal .table-wrap { margin:0 18px; max-height:65vh; }.stock-log-detail { max-width:420px; white-space:pre-wrap; }
.stock-pagination { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 18px; border-top:1px solid #e5e5ea; color:#6e6e73; font-size:13px; }
.stock-pagination div { display:flex; gap:8px; }
.stock-pagination .stock-page-summary { align-items:center; gap:16px; }
.stock-page-summary label { display:flex; align-items:center; gap:6px; }
.stock-page-summary select { border:1px solid #d2d2d7; border-radius:7px; padding:6px 24px 6px 8px; background:#fff; color:#1d1d1f; }
.stock-pagination button { border:1px solid #d2d2d7; background:#fff; color:#1d1d1f; border-radius:8px; padding:7px 12px; cursor:pointer; }
.stock-pagination button:hover:not(:disabled) { border-color:#a8a8ad; background:#f5f5f7; color:#1d1d1f; box-shadow:none; transform:none; }
.stock-pagination button:disabled { opacity:.45; cursor:not-allowed; }
.stock-module-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.stock-module-save { color:#0071e3 !important; border-color:#8dbce8 !important; }
.stock-save-result { width:min(720px,100%); margin:0 auto; padding:30px 24px 26px; }
.stock-save-success { display:flex; align-items:center; gap:14px; margin-bottom:18px; padding:18px 20px; border:1px solid #a8dec8; border-radius:14px; background:linear-gradient(135deg,#effaf5,#e7f7ef); color:#075f45; }
.stock-save-check { display:inline-flex; align-items:center; justify-content:center; flex:0 0 42px; width:42px; height:42px; border-radius:50%; background:#0a8f65; color:#fff; font-size:23px; font-weight:700; box-shadow:0 7px 18px rgba(10,143,101,.2); }
.stock-save-success strong { display:block; margin-bottom:2px; font-size:18px; }
.stock-save-success p { margin:0; color:#3d715f; font-size:13px; }
.stock-save-summary { overflow:hidden; border:1px solid #dedee3; border-radius:14px; background:#fff; box-shadow:0 8px 28px rgba(0,0,0,.055); }
.stock-save-summary-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:15px 18px; border-bottom:1px solid #e8e8ed; background:#fbfbfc; }
.stock-save-summary-head > div { display:flex; flex-direction:column; gap:2px; }
.stock-save-summary-head strong { font-size:15px; }
.stock-save-summary-head span { color:#86868b; font-size:12px; }
.stock-save-summary-head button { padding:8px 14px; border:1px solid #0a8f65; border-radius:8px; background:#fff; color:#087f5b; font-weight:600; }
.stock-save-summary-head button:hover:not(:disabled) { border-color:#087f5b; background:#087f5b; color:#fff; box-shadow:0 5px 14px rgba(8,127,91,.18); }
.stock-save-summary pre { margin:0; padding:19px 20px 21px; color:#2c2c2e; font:14px/1.72 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC",sans-serif; white-space:pre-wrap; overflow-wrap:anywhere; }
.stock-save-result-actions { display:flex; justify-content:flex-end; margin-top:18px; }
.stock-save-result-actions button { padding:9px 17px; border:1px solid #d2d2d7; border-radius:9px; background:#fff; color:#3a3a3c; }
.stock-save-result-actions button:hover:not(:disabled) { border-color:#aaaab0; background:#f5f5f7; color:#1d1d1f; box-shadow:none; transform:none; }
.asset-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  padding: 14px;
}
.asset-form-grid .wide { grid-column: 1 / -1; }
.asset-field label {
  display: block;
  color: #6e6e73;
  font-size: 12px;
  margin-bottom: 5px;
}
.asset-form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e5e5ea;
  background: #fbfbfd;
}

/* ===== Tablet (≤ 900px) ===== */
@media (max-width: 900px) {
  .stock-filters { grid-template-columns:repeat(2,minmax(0,1fr)); }.stock-filters > :first-child { grid-column:span 2; }
  .stock-form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }.stock-form-grid label.wide { grid-column:span 2; }
  .content { padding: 24px 20px; }
  .card { padding: 22px 20px; border-radius: 14px; }
  .topbar { padding: 0 16px; }
  .brand-name { font-size: 17px; }
}

/* ===== Phone (≤ 640px) ===== */
@media (max-width: 640px) {
  .sidebar-collapse-btn { display:none; }
  body.sidebar-collapsed .sidebar { width:240px; padding:20px 12px; border-right:1px solid rgba(0,0,0,.06); }
  body.sidebar-collapsed .sidebar nav { opacity:1; pointer-events:auto; }
  .stock-head { flex-direction:column; }.stock-actions { width:100%; }.stock-actions button { flex:1; }
  .stock-filters, .stock-form-grid { grid-template-columns:1fr; }.stock-filters > :first-child, .stock-form-grid label.wide { grid-column:span 1; }
  .stock-history-filters { flex-wrap:wrap; }.stock-history-filters input { flex:1 1 140px; }
  /* Topbar tightens, hamburger appears */
  .topbar {
    padding: 0 12px;
    height: 64px;
    gap: 8px;
  }
  .menu-btn { display: flex; }
  .brand { gap: 10px; flex: 1; min-width: 0; }
  .brand-logo { height: 32px; max-width: 120px; }
  .brand-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-right { gap: 8px; }
  .current-user { display: none; }
  .link-btn { padding: 5px 12px; font-size: 12px; }

  /* Off-canvas sidebar */
  .layout { min-height: calc(100vh - 64px); }
  .sidebar-overlay { inset: 64px 0 0 0; display: block; }
  .sidebar {
    position: fixed;
    top: 64px;
    bottom: 0;
    left: 0;
    z-index: 95;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.10);
    width: 260px;
    max-width: 80vw;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }

  /* Content */
  .content { padding: 16px 14px; }
  .home-shell { min-height:calc(100vh - 96px); gap:26px; }
  .home-time { font-size:clamp(54px,18vw,90px); }
  .home-facts { flex-direction:column; gap:12px; }
  .home-fact { min-height:0; padding:19px 20px; }
  .home-fact p { font-size:16px; }
  .home-fact-arrow { align-self:center; }
  .view-header h1 { font-size: 22px; }
  .view-desc { font-size: 13px; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .card h2 { font-size: 15px; margin-bottom: 14px; }

  /* Stack file upload rows */
  .upload-card .file-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 0;
  }
  input[type=file] { font-size: 12px; }
  .actions { flex-wrap: wrap; gap: 10px; }

  /* Card header (export button) */
  .card-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .card-header h2 { margin: 0; }
  .export-btn { align-self: stretch; justify-content: center; }

  /* Summary cards: tighter min */
  .summary-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .summary-card { padding: 12px 14px; }
  .summary-card .value { font-size: 22px; }

  /* Tabs scroll horizontally instead of wrapping awkwardly */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; padding: 9px 12px; font-size: 12px; }
  .badge { padding: 1px 7px; font-size: 10px; }

  /* Tables: keep horizontal scroll, tighten cells */
  th, td { padding: 8px 10px; font-size: 12px; }
  .table-wrap { max-height: 60vh; }

  /* Login page */
  .login-card {
    width: calc(100vw - 24px);
    max-width: 380px;
    padding: 30px 22px 24px;
    border-radius: 18px;
  }
  .login-logo { height: 76px; }
  .login-body::before { width: 260px; height: 260px; top: -80px; left: -80px; }
  .login-body::after { width: 320px; height: 320px; bottom: -120px; right: -120px; }
}

/* ===== Tiny phones (≤ 380px) ===== */
@media (max-width: 380px) {
  .brand-name { display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
