:root {
  color-scheme: light;
  --navy: #0b2545;
  --navy-2: #123a65;
  --blue: #246bfd;
  --blue-2: #4f8cff;
  --blue-soft: #edf4ff;
  --cyan: #12a8a0;
  --green: #168a5b;
  --green-soft: #eaf8f2;
  --gold: #b36b00;
  --gold-soft: #fff7e6;
  --red: #c63b48;
  --red-soft: #fff0f1;
  --ink: #17253d;
  --muted: #6f7d91;
  --line: #e3e9f1;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --shadow: 0 8px 30px rgba(22, 43, 78, .08);
  --shadow-lg: 0 24px 60px rgba(10, 34, 67, .16);
  --radius: 14px;
  --sidebar: 248px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
body { min-width: 1180px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: #eef3f9;
}

.login-brand {
  position: relative;
  overflow: hidden;
  padding: 76px 9vw;
  color: white;
  background:
    radial-gradient(circle at 74% 22%, rgba(84, 158, 255, .34), transparent 28%),
    radial-gradient(circle at 18% 80%, rgba(25, 187, 174, .2), transparent 31%),
    linear-gradient(145deg, #081e3a 0%, #103c69 58%, #125c79 100%);
}

.login-brand::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  right: -210px;
  bottom: -250px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 50%;
  box-shadow: 0 0 0 52px rgba(255,255,255,.03), 0 0 0 108px rgba(255,255,255,.025);
}

.brand-mark { display: flex; align-items: center; gap: 14px; font-size: 18px; font-weight: 700; letter-spacing: .08em; }
.brand-logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: linear-gradient(145deg, #4c8dff, #18b9a9); box-shadow: 0 10px 24px rgba(0,0,0,.2); }
.brand-logo svg { width: 26px; height: 26px; }
.login-copy { max-width: 620px; margin-top: 17vh; position: relative; z-index: 1; }
.login-kicker { color: #8ec8ff; font-size: 13px; letter-spacing: .2em; font-weight: 700; }
.login-copy h1 { font-size: 46px; line-height: 1.18; margin: 15px 0 22px; letter-spacing: -.04em; }
.login-copy p { max-width: 540px; color: rgba(255,255,255,.72); font-size: 17px; line-height: 1.85; }
.login-features { margin-top: 42px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 26px; }
.login-feature { color: rgba(255,255,255,.86); display: flex; align-items: center; gap: 10px; font-size: 14px; }
.login-feature::before { content: "✓"; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center; background: rgba(39, 206, 177, .18); color: #62e4c8; font-size: 12px; }

.login-panel { display: grid; place-items: center; padding: 50px; }
.login-card { width: 430px; background: white; padding: 44px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.login-card h2 { margin: 0; font-size: 27px; color: var(--navy); }
.login-card form > p { color: var(--muted); margin: 10px 0 26px; }
.auth-tabs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; padding: 4px; margin: -18px 0 28px; border-radius: 11px; background: #f1f5fa; }
.auth-tab { border: 0; border-radius: 8px; padding: 9px 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; }
.auth-tab.active { color: var(--blue); background: white; box-shadow: 0 3px 10px rgba(24,55,92,.08); }
.optional-label { margin-left: 5px; color: var(--muted); font-size: 10px; font-weight: 500; }
.form-group { display: grid; gap: 8px; margin-bottom: 18px; }
.form-group label { font-size: 13px; color: #46556b; font-weight: 650; }
.field, .form-group input, .form-group select, .form-group textarea {
  width: 100%; border: 1px solid #d8e0eb; border-radius: 10px; padding: 11px 13px; color: var(--ink); background: white; outline: none; transition: .2s;
}
.field:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,107,253,.11); }
.form-group textarea { min-height: 88px; resize: vertical; }
.login-button, .primary-button {
  border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--blue), #3f7eff); color: white; font-weight: 700; padding: 11px 18px; box-shadow: 0 7px 16px rgba(36,107,253,.2); transition: .2s;
}
.login-button { width: 100%; margin-top: 4px; padding: 13px; }
.login-button:hover, .primary-button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(36,107,253,.26); }
.forgot-password-row { display: flex; justify-content: flex-end; margin: -8px 0 12px; }
.text-button { border: 0; padding: 4px 0; color: var(--blue); background: transparent; font: inherit; font-size: 12px; font-weight: 700; }
.text-button:hover { text-decoration: underline; }
.reset-back-button { display: block; margin: 13px auto 0; }
.login-hint { margin-top: 20px; padding: 13px 15px; border-radius: 10px; background: var(--blue-soft); color: #3a587d; font-size: 12px; line-height: 1.65; }
.login-error { min-height: 22px; color: var(--red); font-size: 13px; margin-top: 8px; }

.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); color: #dae7f5; padding: 22px 14px; z-index: 20; overflow-y: auto;
  background: linear-gradient(180deg, #0a233f 0%, #0d3155 56%, #0b2847 100%);
}
.sidebar .brand-mark { padding: 0 8px 22px; color: white; font-size: 15px; letter-spacing: .02em; }
.sidebar .brand-logo { width: 36px; height: 36px; border-radius: 10px; }
.sidebar .brand-logo svg { width: 22px; height: 22px; }
.nav-section { margin: 12px 8px 7px; color: #7893ae; font-size: 10px; letter-spacing: .16em; font-weight: 800; }
.nav-item { width: 100%; border: 0; background: transparent; color: #bcd0e3; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; margin: 2px 0; text-align: left; font-size: 13px; transition: .18s; }
.nav-item:hover { color: white; background: rgba(255,255,255,.07); }
.nav-item.active { color: white; background: linear-gradient(90deg, rgba(67,133,255,.32), rgba(42,170,180,.13)); box-shadow: inset 3px 0 #5b95ff; }
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; color: currentColor; }
.nav-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge { margin-left: auto; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #bcd0e3; font-size: 10px; }

.topbar { position: fixed; left: var(--sidebar); right: 0; top: 0; height: 66px; background: rgba(255,255,255,.95); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); z-index: 15; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.company-pill { display: flex; gap: 8px; align-items: center; background: #f2f6fb; border: 1px solid #e4eaf1; border-radius: 9px; padding: 8px 11px; font-size: 12px; color: #4d5c71; }
.company-pill .dot { width: 7px; height: 7px; background: #24b878; border-radius: 50%; box-shadow: 0 0 0 3px rgba(36,184,120,.12); }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid var(--line); background: white; color: #596980; }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notification-button { position: relative; }
.notification-indicator { position: absolute; width: 6px; height: 6px; right: 7px; top: 6px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px white; }
.nav-unread { min-width: 19px; height: 19px; margin-left: auto; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--red); font-size: 9px; font-weight: 800; }
.nav-unread[hidden], .notification-indicator[hidden] { display: none; }
.user-menu { display: flex; align-items: center; gap: 10px; border-left: 1px solid var(--line); padding-left: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: white; font-weight: 800; background: linear-gradient(145deg, #246bfd, #19a99d); }
.user-meta { display: grid; gap: 2px; }
.user-meta strong { font-size: 12px; }
.user-meta span { font-size: 10px; color: var(--muted); }
.logout-link { border: 0; background: none; color: var(--muted); padding: 4px; font-size: 12px; }
.logout-link:hover { color: var(--red); }

.main { margin-left: var(--sidebar); padding: 92px 30px 36px; min-height: 100vh; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-title h1 { margin: 0; color: var(--navy); font-size: 24px; letter-spacing: -.03em; }
.page-title p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.head-actions { display: flex; align-items: center; gap: 9px; }
.secondary-button, .ghost-button, .danger-button { border-radius: 9px; padding: 9px 13px; font-weight: 650; font-size: 12px; }
.secondary-button { background: white; border: 1px solid #d6deea; color: #40516a; }
.ghost-button { border: 0; color: var(--blue); background: var(--blue-soft); }
.danger-button { border: 1px solid #f1c8cc; color: var(--red); background: var(--red-soft); }
.small-button { padding: 6px 9px; border-radius: 7px; font-size: 11px; border: 1px solid #dbe3ed; background: white; color: #40516a; }
.small-button.primary { color: var(--blue); border-color: #bfd2ff; background: #f3f7ff; }
.small-button.danger { color: var(--red); background: var(--red-soft); border-color: #f1c8cc; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid #e6ebf2; border-radius: var(--radius); padding: 18px 19px; box-shadow: 0 5px 18px rgba(29,54,86,.04); }
.metric-card.interactive-card { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.metric-card.interactive-card:hover, .grade-card.interactive-card:hover, .summary-item:hover { transform: translateY(-2px); border-color: #b9cdf5; box-shadow: 0 9px 24px rgba(36,107,253,.11); }
.metric-card.interactive-card:focus-visible, .todo-item:focus-visible, .bar-group:focus-visible, .grade-card:focus-visible, .summary-item:focus-visible { outline: 3px solid rgba(36,107,253,.22); outline-offset: 2px; }
.metric-card::after { content: ""; position: absolute; width: 76px; height: 76px; border-radius: 50%; right: -20px; top: -28px; background: var(--tone, #edf4ff); }
.metric-top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-icon { width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center; color: var(--accent, var(--blue)); background: var(--tone, var(--blue-soft)); }
.metric-value { margin-top: 12px; font-size: 25px; line-height: 1.1; font-weight: 780; letter-spacing: -.03em; color: var(--navy); }
.metric-foot { margin-top: 8px; font-size: 11px; color: var(--muted); }
.drill-hint { float: right; color: var(--blue); font-weight: 700; }
.trend-up { color: var(--green); font-weight: 700; }
.trend-warn { color: var(--gold); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(300px,.8fr); gap: 18px; margin-bottom: 18px; }
.panel { min-width: 0; background: white; border: 1px solid #e5ebf2; border-radius: var(--radius); box-shadow: 0 5px 18px rgba(29,54,86,.04); }
.panel-head { padding: 17px 19px 12px; display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-size: 14px; color: var(--navy); }
.panel-subtitle { color: var(--muted); font-size: 11px; }
.panel-body { padding: 4px 19px 19px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 4px 19px 0; }
.detail-grid > div { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8faff; }
.detail-grid span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.detail-grid strong { display: block; color: var(--navy); font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.company-categories { margin: 18px 19px; }
.chart { height: 232px; display: flex; align-items: stretch; gap: 13px; padding-top: 22px; border-bottom: 1px solid #dfe6ef; }
.bar-group { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; min-width: 34px; }
.bar-group { border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit; }
.bar-group:hover .bar { filter: brightness(.9); box-shadow: 0 0 0 2px rgba(36,107,253,.13); }
.bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 4px; }
.bar { width: 10px; min-height: 3px; border-radius: 4px 4px 1px 1px; background: linear-gradient(180deg, #4d86fb, #246bfd); }
.bar.expense { background: linear-gradient(180deg, #3fc4b5, #168f83); }
.bar-label { color: var(--muted); font-size: 9px; white-space: nowrap; }
.chart-legend { display: flex; gap: 18px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 14px; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; margin-right: 5px; background: var(--blue); }
.legend-dot.expense { background: var(--cyan); }

.todo-list { display: grid; gap: 2px; }
.todo-item { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 11px; padding: 12px 1px; border-bottom: 1px solid #edf1f5; }
.todo-item { width: 100%; border-width: 0 0 1px; background: transparent; text-align: left; font: inherit; cursor: pointer; border-radius: 6px; }
.todo-item:hover { background: #f7faff; padding-left: 8px; padding-right: 8px; }
.todo-item:last-child { border-bottom: 0; }
.todo-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.todo-dot.warn { background: #e49a2d; }
.todo-dot.risk { background: var(--red); }
.todo-text strong { display: block; font-size: 12px; font-weight: 680; }
.todo-text span { color: var(--muted); font-size: 10px; }
.todo-count { font-weight: 800; color: var(--navy); font-size: 13px; }

.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.summary-item { padding: 15px 18px; background: #fbfcfe; }
.summary-item { border: 0; text-align: left; font: inherit; cursor: pointer; transition: transform .16s ease, background .16s ease; }
.summary-item span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.summary-item strong { color: var(--navy); font-size: 15px; }

.toolbar { display: flex; align-items: center; gap: 9px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.search { position: relative; width: 260px; }
.search input { width: 100%; border: 1px solid #dbe2ec; border-radius: 9px; padding: 9px 11px 9px 34px; outline: none; font-size: 12px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 6px; color: #8592a4; font-size: 17px; }
.search-button { min-width: 66px; padding-left: 16px; padding-right: 16px; }
.filter-select { border: 1px solid #dbe2ec; border-radius: 9px; padding: 8px 30px 8px 10px; background: white; color: #536176; font-size: 12px; }
.toolbar-spacer { flex: 1; }
.record-count { color: var(--muted); font-size: 11px; }
.user-directory-toolbar { background: #fbfcfe; }
.user-pager, .list-pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.user-pager > span, .list-pager > span { margin-right: 4px; color: var(--muted); font-size: 10px; }
.user-pager button:disabled, .list-pager button:disabled { opacity: .45; cursor: not-allowed; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.data-table th { text-align: left; padding: 11px 14px; color: #6f7d91; font-size: 10px; letter-spacing: .03em; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #edf1f5; color: #35445a; font-size: 11px; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8faff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.clickable-row { cursor: pointer; }
.data-table tbody tr.clickable-row:hover { background: #edf4ff; }
.data-table tbody tr.clickable-row:focus { outline: 2px solid #246bfd; outline-offset: -2px; background: #edf4ff; }
.row-action-hint { display: block; margin-top: 4px; color: #246bfd; font-size: 10px; font-weight: 600; }
.main-cell { display: grid; gap: 3px; min-width: 150px; }
.main-cell strong { color: var(--navy); font-size: 11.5px; }
.main-cell span { color: var(--muted); font-size: 9.5px; }
.money { color: var(--navy); font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 12px; padding: 4px 8px; font-size: 9.5px; font-weight: 700; white-space: nowrap; background: #eef2f7; color: #57677d; }
.tag.blue { background: var(--blue-soft); color: #2d64c6; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.gold { background: var(--gold-soft); color: var(--gold); }
.tag.red { background: var(--red-soft); color: var(--red); }
.tag.navy { background: #eaf0f6; color: var(--navy); }
.table-actions { display: flex; gap: 6px; white-space: nowrap; }
.empty { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: #526177; margin-bottom: 7px; }

.grade-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.grade-card { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }
.grade-card.interactive-card { width: 100%; font: inherit; cursor: pointer; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.grade-card .grade { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-weight: 850; background: var(--blue-soft); color: var(--blue); }
.grade-card strong { color: var(--navy); font-size: 18px; }
.grade-card span { display: block; font-size: 10px; color: var(--muted); text-align: right; }

.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.product-card { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: white; position: relative; overflow: hidden; }
.product-card::before { content: ""; position: absolute; width: 4px; left: 0; top: 0; bottom: 0; background: linear-gradient(var(--blue), var(--cyan)); }
.product-card h3 { margin: 0 0 5px; font-size: 14px; color: var(--navy); }
.product-card .institution { color: var(--muted); font-size: 10px; }
.product-amount { margin: 18px 0 5px; color: var(--blue); font-size: 19px; font-weight: 780; }
.product-meta { display: flex; justify-content: space-between; color: #617085; font-size: 10px; margin-top: 11px; }
.product-note { color: var(--muted); font-size: 9px; line-height: 1.55; margin: 12px 0 0; }

.asset-summary { display: grid; grid-template-columns: 1.2fr .8fr .8fr; gap: 14px; margin-bottom: 18px; }
.asset-hero { color: white; background: linear-gradient(135deg, #0c2e54, #185d7c); border: 0; }
.asset-hero .metric-label, .asset-hero .metric-foot { color: rgba(255,255,255,.68); }
.asset-hero .metric-value { color: white; }
.credit-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; margin-bottom: 18px; }
.credit-card { min-height: 184px; color: white; border-radius: 17px; padding: 20px; background: linear-gradient(135deg, #102e54, #265e94 64%, #178d8a); box-shadow: 0 14px 28px rgba(18,53,91,.18); }
.credit-card:nth-child(even) { background: linear-gradient(135deg, #27324f, #5d4f86 66%, #916f76); }
.credit-top { display: flex; justify-content: space-between; font-size: 11px; color: rgba(255,255,255,.72); }
.credit-number { margin: 27px 0 22px; font-size: 19px; letter-spacing: .12em; font-weight: 650; }
.credit-foot { display: flex; justify-content: space-between; align-items: flex-end; }
.credit-limit span { display: block; color: rgba(255,255,255,.62); font-size: 9px; margin-bottom: 4px; }
.credit-limit strong { font-size: 14px; }

.tabs { display: flex; align-items: center; gap: 5px; border-bottom: 1px solid var(--line); padding: 0 16px; }
.tab { border: 0; background: transparent; padding: 13px 12px 11px; color: var(--muted); font-size: 12px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }
.system-section { margin-bottom: 18px; }
.permission-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; padding: 16px; }
.role-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; transition: border-color .2s ease, box-shadow .2s ease; }
.role-card:has(.role-detail-toggle[aria-expanded="true"]) { border-color: #b8cdf7; box-shadow: 0 10px 24px rgba(40,89,164,.08); }
.role-card-summary { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 12px; align-items: center; min-height: 70px; padding: 14px 15px; }
.role-card-actions { display: flex; align-items: center; gap: 8px; }
.permission-editor-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; max-height: 52vh; overflow-y: auto; padding: 2px; }
.permission-editor-item { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 4px 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #f8fbff; cursor: pointer; }
.permission-editor-item input { grid-row: 1 / span 2; }
.permission-editor-item code { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.role-card-main { min-width: 0; }
.role-card-main h3 { margin: 0; color: var(--navy); font-size: 14px; line-height: 1.35; }
.role-card-main > span { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.role-symbol { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--blue); background: var(--blue-soft); font-size: 15px; font-weight: 800; }
.role-detail-toggle { display: inline-flex; align-items: center; gap: 5px; min-width: 58px; height: 32px; padding: 0 11px; border: 1px solid #d8e2ef; border-radius: 9px; color: #426087; background: #fff; font-size: 10px; font-weight: 650; }
.role-detail-toggle:hover { color: var(--blue); border-color: #b8cdf7; background: #f7faff; }
.role-detail-toggle span { display: inline-block; font-size: 13px; transition: transform .2s ease; }
.role-detail-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
.role-inline-detail { padding: 0 15px 16px; border-top: 1px solid var(--line); }
.role-inline-detail > p { margin: 14px 0; padding: 11px 12px; color: #5e6f86; background: #f6f9fd; border-radius: 9px; font-size: 10px; line-height: 1.65; }
.permission-detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.permission-detail-list > div { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.permission-detail-list span { flex: 0 0 22px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; color: var(--blue); background: var(--blue-soft); font-size: 9px; }
.permission-detail-list strong { color: #40516a; font-size: 10px; font-weight: 650; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(8,25,47,.52); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 30px; }
.modal { width: min(680px, 90vw); max-height: 88vh; overflow-y: auto; background: white; border-radius: 17px; box-shadow: var(--shadow-lg); }
.modal.wide-modal { width: min(1280px, calc(100vw - 36px)); }
.wide-modal .modal-table { overflow-x: auto; }
.wide-modal .data-table { min-width: 960px; }
.wide-modal .data-table th, .wide-modal .data-table td { white-space: nowrap; }
.wide-modal .data-table td:nth-child(6) { white-space: normal; min-width: 150px; }
.modal-head { position: sticky; top: 0; z-index: 2; background: white; display: flex; align-items: center; justify-content: space-between; padding: 18px 21px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; color: var(--navy); }
.modal-close { border: 0; background: #f1f4f8; color: #637287; width: 30px; height: 30px; border-radius: 8px; }
.modal-form { padding: 20px 21px; }
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 0 14px; }
.form-group.full { grid-column: 1 / -1; }
.field-help { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.5; }
.calculated-field input[readonly] { color: #24466f; background: #f2f7fd; font-weight: 700; cursor: default; }
.file-field { padding: 13px 14px; border: 1px dashed #cad6e5; border-radius: 11px; background: #f9fbfe; }
.file-drop-zone { position: relative; display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: center; min-height: 52px; padding: 9px 12px; border: 1px solid #d6e0ed; border-radius: 10px; background: white; cursor: pointer; transition: border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.file-drop-zone:hover, .file-drop-zone:focus-within { border-color: #8eb0ef; box-shadow: 0 0 0 3px rgba(36,107,253,.07); }
.file-drop-zone.is-dragging { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 3px rgba(36,107,253,.12); }
.file-drop-zone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-drop-action { padding: 8px 12px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.file-drop-name { min-width: 0; color: #52647c; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop-name.selected { color: var(--navy); font-weight: 700; }
.file-drop-hint { color: var(--muted); font-size: 9px; white-space: nowrap; }
.dashboard-company-filter { display: flex; align-items: center; gap: 8px; min-width: 280px; color: var(--muted); font-size: 10px; }
.dashboard-company-filter select { min-width: 210px; height: 38px; padding: 0 34px 0 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--navy); background: white; font: inherit; }
.dashboard-company-scope { color: var(--muted); font-size: 10px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; height: 42px; }
.checkbox-field input { width: auto; }
.modal-actions { position: sticky; bottom: 0; margin: 10px -21px -20px; padding: 14px 21px; background: white; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.order-workbench-actions { flex-wrap: wrap; }
.compact-loading { min-height: 240px; }
.detail-summary { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; padding: 18px 21px 12px; }
.detail-summary > div { padding: 13px 15px; border-radius: 10px; background: #f6f9fd; border: 1px solid var(--line); }
.detail-summary span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.detail-summary strong { color: var(--navy); font-size: 17px; }
.modal-table { padding: 0 21px 18px; overflow-x: auto; }
.modal-table .table-wrap { border: 1px solid var(--line); border-radius: 10px; }
.modal-footer { position: sticky; bottom: 0; padding: 14px 21px; background: white; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.notification-list { margin-top: 12px; }

.toast { position: fixed; right: 24px; top: 82px; z-index: 200; min-width: 280px; max-width: 420px; border-radius: 11px; padding: 13px 15px; color: white; background: #243a57; box-shadow: var(--shadow-lg); font-size: 12px; animation: toast-in .25s ease; }
.toast.success { background: #177454; }
.toast.error { background: #b93845; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.loading { padding: 100px 20px; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #dbe5f1; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { padding: 13px 15px; border-radius: 10px; font-size: 11px; line-height: 1.65; margin-bottom: 16px; border: 1px solid #f0d39b; background: #fff9ed; color: #795a24; }
.danger-notice { border-color: #efc4c9; background: var(--red-soft); color: #8c3440; }
.report-summary-strip { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.report-summary-strip span { padding: 10px 12px; border-radius: 9px; background: #f7f9fc; color: var(--muted); font-size: 11px; }
.report-summary-strip strong { display: block; margin-top: 5px; color: var(--navy); font-size: 14px; }
.report-range-toolbar { display: flex; align-items: end; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.report-range-toolbar label { display: grid; gap: 5px; color: var(--muted); font-size: 9px; }
.report-range-toolbar input { height: 34px; padding: 0 9px; border: 1px solid #dbe2ec; border-radius: 8px; color: var(--navy); background: white; font: inherit; }
.import-guide { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-bottom: 14px; }
.import-guide span { padding: 9px 11px; border-radius: 8px; color: #52647c; background: #f4f7fb; font-size: 10px; }
.import-preview { max-height: 48vh; margin-top: 14px; overflow: auto; border: 1px solid var(--line); border-radius: 11px; }
.import-preview .table-wrap { overflow: visible; }
.import-preview-summary { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; gap: 16px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: white; color: var(--muted); font-size: 10px; }
.import-preview-summary strong { color: var(--navy); }
.compact-empty { padding: 32px 20px; }
.compact-empty span { display: block; font-size: 10px; }
.text-danger { color: var(--red) !important; }
.text-warning { color: var(--gold) !important; }
@media print {
  .sidebar, .topbar, .head-actions, .notice, .tabs, .report-range-toolbar, .no-print, .data-table button { display: none !important; }
  .app-shell, .main, .content { display: block !important; margin: 0 !important; padding: 0 !important; background: white !important; }
  .panel { box-shadow: none !important; border: 1px solid #ddd !important; }
}

.chat-layout { display: grid; grid-template-columns: 320px minmax(0,1fr); height: calc(100vh - 196px); min-height: 520px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: var(--shadow); }
.chat-directory { min-width: 0; border-right: 1px solid var(--line); background: #fbfcfe; }
.chat-search { padding: 14px; border-bottom: 1px solid var(--line); }
.chat-search input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid #dbe2ec; border-radius: 9px; outline: none; background: white; font-size: 11px; }
.chat-search input:focus { border-color: #94b6fb; box-shadow: 0 0 0 3px rgba(36,107,253,.08); }
.chat-contacts { height: calc(100% - 67px); overflow-y: auto; }
.chat-contact { position: relative; display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 82px; padding: 12px 14px; border: 0; border-bottom: 1px solid #edf1f5; background: transparent; text-align: left; cursor: pointer; }
.chat-contact:hover, .chat-contact.active { background: #edf4ff; }
.chat-contact.active { box-shadow: inset 3px 0 var(--blue); }
.chat-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: white; background: linear-gradient(135deg, var(--blue), var(--cyan)); font-weight: 800; }
.chat-contact-main { min-width: 0; display: grid; gap: 3px; }
.chat-contact-main strong { color: var(--navy); font-size: 12px; }
.chat-contact-main small, .chat-contact-main em { overflow: hidden; color: var(--muted); font-size: 9px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.chat-contact-main em { color: #64758c; }
.chat-unread { min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--red); font-size: 9px; }
.chat-thread { min-width: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; background: #f5f8fc; }
.chat-thread-head { display: flex; align-items: center; min-height: 67px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: white; }
.chat-thread-head strong { display: block; color: var(--navy); font-size: 14px; }
.chat-thread-head span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.chat-messages { min-height: 0; overflow-y: auto; padding: 20px; }
.chat-history-loader { display: flex; justify-content: center; padding: 0 0 16px; }
.chat-history-loader .secondary-button { min-width: 128px; height: 32px; padding: 0 14px; font-size: 10px; }
.chat-message { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 14px; }
.chat-message.mine { align-items: flex-end; }
.chat-bubble { max-width: min(72%, 680px); padding: 10px 13px; border: 1px solid #dce5ef; border-radius: 4px 14px 14px; color: #32445c; background: white; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; box-shadow: 0 3px 10px rgba(28,55,85,.04); }
.chat-message.mine .chat-bubble { border-color: var(--blue); border-radius: 14px 4px 14px 14px; color: white; background: var(--blue); }
.chat-message > span { margin-top: 4px; color: #8895a7; font-size: 8.5px; }
.chat-compose { padding: 13px 16px; border-top: 1px solid var(--line); background: white; }
.chat-drop-zone { position: relative; border-radius: 10px; }
.chat-drop-zone.dragging { outline: 2px dashed var(--blue); outline-offset: 3px; background: var(--blue-soft); }
.chat-compose textarea { width: 100%; min-height: 66px; max-height: 150px; resize: vertical; padding: 10px 12px; border: 1px solid #dbe2ec; border-radius: 10px; outline: none; font: inherit; font-size: 11px; line-height: 1.55; }
.chat-compose textarea:focus { border-color: #94b6fb; box-shadow: 0 0 0 3px rgba(36,107,253,.08); }
.chat-drop-hint { position: absolute; inset: 0; display: none; place-items: center; border-radius: 10px; color: var(--blue); background: rgba(237,244,255,.94); font-size: 12px; font-weight: 700; pointer-events: none; }
.chat-drop-zone.dragging .chat-drop-hint { display: grid; }
.chat-compose-tools { position: relative; display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.chat-compose-tools > div { display: flex; gap: 6px; }
.chat-compose-tools > span { flex: 1; color: var(--muted); font-size: 9px; text-align: right; }
.chat-tool-button { height: 32px; padding: 0 10px; border: 1px solid #dbe2ec; border-radius: 8px; color: #52647c; background: white; font-size: 10px; }
.chat-tool-button:hover { border-color: #9bb8e9; color: var(--blue); background: var(--blue-soft); }
.chat-emoji-panel { position: absolute; z-index: 4; left: 0; bottom: 40px; width: 250px; display: grid; grid-template-columns: repeat(5,1fr); gap: 4px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.chat-emoji-panel[hidden] { display: none; }
.chat-emoji-panel button { padding: 6px; border: 0; border-radius: 7px; background: transparent; font-size: 20px; }
.chat-emoji-panel button:hover { background: var(--blue-soft); }
.chat-file-attachment { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; align-items: center; width: min(360px,72%); padding: 11px 12px; border: 1px solid #dce5ef; border-radius: 13px; color: #32445c; background: white; text-align: left; box-shadow: 0 3px 10px rgba(28,55,85,.04); }
.chat-message.mine .chat-file-attachment { border-color: #a8c2f6; background: #eef4ff; }
.chat-file-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-weight: 800; }
.chat-file-attachment > span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.chat-file-attachment strong { overflow: hidden; color: var(--navy); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-attachment small { color: var(--muted); font-size: 9px; }
.chat-file-attachment em { color: var(--blue); font-size: 9px; font-style: normal; }
.chat-image-attachment { position: relative; width: min(360px,72%); min-height: 120px; padding: 0; overflow: hidden; border: 1px solid #dce5ef; border-radius: 14px; color: var(--muted); background: white; }
.chat-image-attachment img { display: none; width: 100%; max-height: 360px; object-fit: contain; background: #edf1f6; }
.chat-image-attachment.loaded img { display: block; }
.chat-image-attachment.loaded > span { display: none; }
.chat-empty { display: grid; place-items: center; align-content: center; gap: 6px; min-height: 180px; padding: 20px; color: var(--muted); text-align: center; }
.chat-empty strong { color: #526177; }
.chat-empty span { font-size: 10px; }
.chat-thread-placeholder { place-items: center; text-align: center; }
.chat-thread-placeholder > div { display: grid; justify-items: center; gap: 8px; color: var(--muted); }
.chat-thread-placeholder strong { color: var(--navy); font-size: 15px; }
.chat-thread-placeholder p { margin: 0; font-size: 10px; }
.chat-placeholder-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; color: var(--blue); background: var(--blue-soft); }
.chat-placeholder-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; }

@media (max-width: 1280px) {
  :root { --sidebar: 222px; }
  .main { padding-left: 22px; padding-right: 22px; }
  .metric-grid { gap: 12px; }
  .permission-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  :root { --sidebar: 72px; }
  body { min-width: 0; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 24px; }
  .login-card { width: min(430px, 100%); padding: 30px; }
  .sidebar { padding: 16px 8px; overflow-x: hidden; }
  .sidebar .brand-mark { justify-content: center; padding: 0 0 18px; }
  .sidebar .brand-mark > span:last-child, .nav-item > span:last-child { display: none; }
  .nav-section { height: 1px; margin: 11px 8px; background: rgba(255,255,255,.13); font-size: 0; }
  .nav-item { justify-content: center; padding: 11px 8px; }
  .topbar { padding: 0 14px; }
  .company-pill, .user-meta { display: none; }
  .main { padding: 84px 16px 28px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0,1fr); }
  .product-grid, .asset-summary, .credit-grid { grid-template-columns: 1fr; }
  .grade-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .permission-grid { grid-template-columns: 1fr; padding: 12px; }
  .permission-editor-list { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-wrap: wrap; }
  .toolbar { flex-wrap: wrap; }
  .user-directory-toolbar .search { width: 100%; }
  .user-directory-toolbar .toolbar-spacer { display: none; }
  .user-directory-toolbar .record-count { margin-left: auto; }
  .search { width: min(100%, 280px); }
  .modal { width: min(760px, 96vw); }
  .modal.wide-modal { width: calc(100vw - 20px); }
  .chat-layout { grid-template-columns: 250px minmax(0,1fr); }
}

@media (max-width: 650px) {
  :root { --sidebar: 62px; }
  .metric-grid { grid-template-columns: 1fr; }
  .report-summary-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .summary-strip { grid-template-columns: repeat(2,1fr); }
  .topbar { height: 58px; padding: 0 9px; }
  .breadcrumb span { display: none; }
  .breadcrumb { font-size: 11px; }
  .top-actions { gap: 6px; }
  .user-menu { gap: 5px; padding-left: 7px; }
  .avatar { display: none; }
  .main { padding: 74px 10px 24px; }
  .page-title h1 { font-size: 21px; }
  .head-actions { width: 100%; flex-wrap: wrap; }
  .dashboard-company-filter { width: 100%; min-width: 0; }
  .dashboard-company-filter select { flex: 1; min-width: 0; }
  .report-range-toolbar { align-items: stretch; flex-direction: column; }
  .report-range-toolbar .small-button { align-self: flex-start; }
  .import-guide { grid-template-columns: 1fr; }
  .file-drop-zone { grid-template-columns: auto minmax(0,1fr); }
  .file-drop-hint { grid-column: 1 / -1; }
  .permission-grid, .form-grid, .detail-summary { grid-template-columns: 1fr; }
  .role-card-summary { grid-template-columns: 38px minmax(0,1fr) auto; gap: 10px; min-height: 64px; padding: 12px; }
  .role-symbol { width: 38px; height: 38px; border-radius: 11px; }
  .role-detail-toggle { min-width: 54px; padding: 0 9px; }
  .role-inline-detail { padding: 0 12px 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .company-categories { margin: 14px 12px; }
  .permission-detail-list { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 8px; }
  .modal { width: 100%; max-height: 96vh; }
  .modal.wide-modal { width: 100%; }
  .chat-layout { grid-template-columns: 1fr; height: auto; min-height: 0; overflow: visible; }
  .chat-directory { border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-contacts { max-height: 260px; }
  .chat-thread { min-height: 520px; }
  .chat-bubble { max-width: 88%; }
  .chat-file-attachment, .chat-image-attachment { width: 88%; }
  .chat-compose-tools { flex-wrap: wrap; }
  .chat-compose-tools > span { order: 3; flex-basis: 100%; text-align: left; }
}
