/* =========================================================
   越州国际 · 桌面端财务软件
   应用框架：左侧导航 + 顶部栏 + 工作区
   ========================================================= */

:root {
  --brand: #2563b8;
  --brand-dark: #1c4d92;
  --brand-soft: #eaf1fb;
  --sidebar-bg: #14243a;
  --sidebar-bg-2: #1a2e48;
  --sidebar-text: #c2cedf;
  --sidebar-muted: #7f91a8;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e4e9f0;
  --border-strong: #d3dbe6;
  --text: #1f2937;
  --muted: #667085;
  --faint: #98a2b3;
  --success: #1f7a47;
  --success-soft: #edf8f2;
  --danger: #b42318;
  --danger-soft: #fdf1f0;
  --warn: #9a6a1d;
  --warn-soft: #fbf4e6;
  --sidebar-width: 224px;
  --topbar-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

svg {
  display: block;
}

/* ---------------- 框架 ---------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex: none;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  overflow: hidden;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.sidebar-brand {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.brand-text span {
  display: block;
  margin-top: 2px;
  color: var(--sidebar-muted);
  font-size: 11px;
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0 10px;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}

.nav-group {
  margin-top: 6px;
}

.nav-group-label {
  padding: 3px 20px 2px;
  color: var(--sidebar-muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 1px 8px;
  padding: 5px 12px;
  border-radius: 4px;
  color: var(--sidebar-text);
  font-size: 13px;
  line-height: 1.4;
}

.nav-item .nav-icon {
  flex: none;
  width: 16px;
  height: 16px;
  opacity: 0.75;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.active {
  background: var(--brand);
  color: #ffffff;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-foot {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--sidebar-muted);
  font-size: 11px;
}

.sidebar-foot a {
  color: var(--sidebar-muted);
}

.sidebar-foot a:hover {
  color: #ffffff;
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
}

.sidebar-backdrop {
  display: none;
}

.main-col {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex: none;
  align-items: center;
  gap: 14px;
  height: var(--topbar-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--brand);
}

.breadcrumb-sep {
  color: var(--faint);
}

.breadcrumb-current {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  min-width: 0;
}

.company-chip {
  max-width: 260px;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.period-chip {
  padding: 3px 9px;
  border-radius: 3px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  white-space: nowrap;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-menu summary:hover {
  background: #f2f5f9;
}

.user-menu summary::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.user-menu-panel a,
.user-menu-panel button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.user-menu-panel a:hover,
.user-menu-panel button:hover {
  background: #f4f7fb;
}

.user-menu-panel form {
  margin: 0;
}

.user-menu-divider {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

/* ---------------- 工作区 ---------------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 18px 22px 32px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.page-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

.page-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------------- 消息条 ---------------- */
.flash-list {
  margin-bottom: 12px;
}

.flash {
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
}

.flash:last-child {
  margin-bottom: 0;
}

.flash-success {
  border-color: #cbe5d6;
  background: var(--success-soft);
  color: var(--success);
}

.flash-error {
  border-color: #f1d1cd;
  background: var(--danger-soft);
  color: var(--danger);
}

.flash-info {
  border-color: #d7e4f5;
  background: #f3f8fe;
  color: #215a8f;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.16s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(15, 23, 42, 0.38);
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .main-col {
    width: 100%;
  }

  .content {
    padding: 14px 14px 28px;
  }

  .topbar {
    padding: 0 14px;
  }

  .company-chip {
    max-width: 160px;
  }

  .period-chip {
    display: none;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 12px 10px 24px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .company-chip {
    display: none;
  }
}

/* ---------------- 打印 ---------------- */
@media print {
  @page {
    margin: 12mm;
  }

  body {
    background: #ffffff;
  }

  .sidebar,
  .sidebar-backdrop,
  .topbar,
  .page-actions,
  .toolbar,
  .flash-list,
  .btn,
  .pagination {
    display: none !important;
  }

  .app-shell,
  .main-col,
  .content {
    display: block;
    padding: 0;
    margin: 0;
    width: 100%;
  }

  .content {
    padding: 0;
  }

  .panel {
    border: 0;
    border-radius: 0;
  }

  .table-scroll {
    overflow: visible;
  }
}
