:root {
  --app-bg: #eef3f1;
  --surface: #ffffff;
  --surface-subtle: #f7faf9;
  --surface-hover: #f0f7f5;
  --border-subtle: #edf2f0;
  --border-default: #d9e4e0;
  --text-primary: #071614;
  --text-secondary: #43534f;
  --text-muted: #697976;
  --brand: #009989;
  --brand-hover: #007e72;
  --brand-soft: #dff8f3;
  --success: #168044;
  --success-soft: #e4f7eb;
  --warning: #a96b00;
  --warning-soft: #fff3d8;
  --danger: #b3362d;
  --danger-soft: #ffe7e2;
  --info: #175f95;
  --info-soft: #e5f1ff;
  --purple: #6652ad;
  --purple-soft: #eee9ff;
  --neutral-soft: #eef2f1;
  --vertical-care: #0f4c81;
  --vertical-home: #009b8e;
  --vertical-market: #e57933;
  --vertical-mobi: #7157b8;
  --vertical-park: #dca018;
  --vertical-work: #2878c8;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-xs: 0 1px 2px rgba(7, 22, 20, .05);
  --shadow-sm: 0 12px 28px rgba(7, 22, 20, .07);
  --shadow-md: 0 24px 60px rgba(7, 22, 20, .12);
  --sidebar-width: 248px;
  --header-height: 104px;
  font-family: "Aptos Display", Aptos, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--app-bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--app-bg); }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 14% 8%, rgba(0, 153, 137, .12), transparent 28rem),
    radial-gradient(circle at 92% 0, rgba(229, 121, 51, .10), transparent 24rem),
    linear-gradient(180deg, #f9fbfa 0, var(--app-bg) 42rem);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid rgba(0, 153, 137, .28); outline-offset: 2px; }

.bewiki-ribbon { height: 5px; background: linear-gradient(90deg, var(--vertical-care), var(--vertical-home), var(--vertical-market), var(--vertical-mobi), var(--vertical-park), var(--vertical-work)); }
.screen-loader { min-height: 100vh; display: grid; place-items: center; color: var(--text-muted); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(7, 27, 26, .90), rgba(0, 126, 114, .82)),
    radial-gradient(circle at top left, rgba(255,255,255,.28), transparent 30rem);
}

.login-card {
  width: min(460px, 100%);
  overflow: hidden;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 34px;
}

.login-brand, .brand-block { display: flex; align-items: center; gap: 12px; }
.login-brand { margin: 0 0 22px; color: var(--text-secondary); font-weight: 800; letter-spacing: .01em; }

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), #00685f);
  box-shadow: 0 12px 26px rgba(0, 153, 137, .28);
  color: white;
  font-size: 0;
  font-weight: 900;
  text-transform: uppercase;
}

.brand-mark::before { content: "b"; font-size: 18px; letter-spacing: -.03em; }
.login-card h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 36px); letter-spacing: -.04em; }
.login-card p { margin: 0 0 26px; color: var(--text-muted); line-height: 1.55; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: 5px 1fr;
}

.app-shell > .bewiki-ribbon { grid-column: 1 / -1; }

.sidebar {
  grid-row: 2;
  position: sticky;
  top: 0;
  height: calc(100vh - 5px);
  overflow: hidden;
  background: rgba(255,255,255,.88);
  border-right: 1px solid var(--border-default);
  box-shadow: 12px 0 38px rgba(7, 22, 20, .05);
  backdrop-filter: blur(18px);
  padding: 22px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand-block { padding: 0 6px 18px; border-bottom: 1px solid var(--border-default); }
.brand-block strong, .sidebar-profile strong, .topbar-profile strong { display: block; font-weight: 900; letter-spacing: -.02em; }
.brand-block strong { font-size: 15px; }
.brand-block span, .breadcrumb, .muted { color: var(--text-muted); font-size: 13px; line-height: 1.45; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-group { display: grid; gap: 5px; }
.nav-label { padding: 0 10px 4px; color: var(--text-muted); text-transform: uppercase; font-size: 10px; font-weight: 900; letter-spacing: .08em; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--text-secondary);
  font-weight: 700;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}

.nav-item:hover { background: var(--surface-hover); color: var(--text-primary); transform: translateX(2px); }

.nav-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--brand-hover);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active {
  background: linear-gradient(135deg, var(--brand-soft), rgba(255,255,255,.8));
  color: var(--brand-hover);
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(0, 153, 137, .08);
}
.nav-item.active::before { background: var(--brand); }
.nav-item.active .nav-icon { background: #fff; color: var(--brand); box-shadow: var(--shadow-xs); }

.sidebar-profile {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-default);
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, var(--surface-subtle));
  box-shadow: var(--shadow-xs);
}

.sidebar-profile-info, .topbar-profile-text { min-width: 0; }
.sidebar-profile-info strong, .topbar-profile-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile-info span, .topbar-profile-text span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; font-weight: 700; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #061d1a, #0d3934);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -.04em;
}
.avatar.large { width: 72px; height: 72px; font-size: 24px; }
.sidebar-profile .ghost-button { grid-column: 1 / -1; min-height: 36px; }

.icon-button {
  border: 1px solid var(--border-default);
  background: var(--surface);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
}

.main-panel { grid-row: 2; min-width: 0; }

.topbar {
  min-height: var(--header-height);
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  position: sticky;
  top: 5px;
  z-index: 3;
  backdrop-filter: blur(18px);
}

.topbar h1 { margin: 3px 0 0; font-size: clamp(28px, 3vw, 38px); line-height: 1; letter-spacing: -.05em; }
.topbar .muted { max-width: 680px; margin: 9px 0 0; }
.topbar-action { margin-top: 14px; }

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  border-radius: 18px;
  padding: 9px 12px 9px 9px;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow-xs);
}

.page-content { padding: 28px; }
.stack { display: grid; gap: 18px; }

.panel, .table-card, .kpi-card, .pagination {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel { padding: 20px; }
.panel h2 { margin: 0 0 16px; font-size: 19px; letter-spacing: -.03em; }
.error-panel, .form-error { color: var(--danger); background: var(--danger-soft); border: 1px solid #ffc9c0; }
.form-error { border-radius: var(--radius-sm); padding: 10px 12px; font-weight: 800; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-card { position: relative; overflow: hidden; padding: 18px; display: grid; gap: 7px; min-height: 122px; }
.kpi-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--brand); }
.kpi-card::after { content: ""; position: absolute; right: -38px; top: -42px; width: 112px; height: 112px; border-radius: 50%; background: rgba(0,153,137,.09); }
.kpi-card span { color: var(--text-secondary); font-size: 13px; font-weight: 800; }
.kpi-card strong { font-size: 36px; line-height: 1; letter-spacing: -.05em; }
.kpi-card small { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.accent-care::before { background: var(--vertical-care); }
.accent-home::before { background: var(--vertical-home); }
.accent-market::before { background: var(--vertical-market); }
.accent-mobi::before { background: var(--vertical-mobi); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, .9fr); gap: 18px; }
.chart-box { min-height: 0; }
.svg-chart { width: 100%; height: 260px; display: block; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label, .search-field { display: grid; gap: 7px; color: var(--text-secondary); font-size: 13px; font-weight: 850; }

.form-grid input, .form-grid select, .form-grid textarea, .search-field input, .filter-controls select {
  width: 100%;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: #fff;
  color: var(--text-primary);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .search-field input:focus, .filter-controls select:focus {
  border-color: rgba(0, 153, 137, .65);
  box-shadow: 0 0 0 4px rgba(0, 153, 137, .10);
  outline: 0;
}

.form-grid textarea { resize: vertical; min-height: 140px; }
.full-span { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.primary-button, .ghost-button, .status-actions button {
  border-radius: var(--radius-sm);
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  border: 1px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.primary-button { background: linear-gradient(135deg, var(--brand), var(--brand-hover)); color: white; box-shadow: 0 12px 28px rgba(0, 153, 137, .20); }
.primary-button:hover { background: linear-gradient(135deg, #00a997, var(--brand-hover)); transform: translateY(-1px); }
.ghost-button, .status-actions button { border-color: var(--border-default); background: #fff; color: var(--text-primary); }
.ghost-button:hover, .status-actions button:hover { background: var(--surface-hover); border-color: rgba(0, 153, 137, .30); }
.form-grid > .primary-button,
.form-grid > .ghost-button {
  align-self: end;
  justify-self: start;
  min-width: 180px;
}
.form-grid > .primary-button.full-span,
.form-grid > .ghost-button.full-span {
  justify-self: stretch;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: end;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.84);
  box-shadow: var(--shadow-xs);
}

.filter-controls { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.filter-controls select { min-height: 42px; min-width: 190px; }

.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { text-align: left; padding: 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
th { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: linear-gradient(180deg, #fff, var(--surface-subtle)); }
td { color: var(--text-primary); }
td strong { font-weight: 900; }
td span { display: block; color: var(--text-muted); font-size: 12px; margin-top: 4px; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid transparent;
  text-transform: none;
  white-space: nowrap;
}

.badge-default { background: var(--neutral-soft); border-color: var(--border-default); color: var(--text-secondary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--neutral-soft); color: var(--text-muted); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }

.empty-state {
  background:
    linear-gradient(135deg, rgba(255,255,255,.92), rgba(247,250,249,.92)),
    radial-gradient(circle at 50% 0, rgba(0,153,137,.08), transparent 18rem);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-lg);
  min-height: 170px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  text-align: center;
  color: var(--text-muted);
  padding: 22px;
}

.empty-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-hover);
  font-weight: 900;
  font-style: italic;
}
.empty-state strong { color: var(--text-primary); font-size: 18px; letter-spacing: -.02em; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.comments-panel { grid-column: 1 / -1; }
.record-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.record-heading h2 { margin-top: 7px; }
.record-code { color: var(--brand-hover); font-weight: 900; letter-spacing: .02em; }
.description-text { color: var(--text-secondary); line-height: 1.65; white-space: pre-wrap; }

.meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0 0; }
dt { color: var(--text-muted); font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
dd { margin: 5px 0 0; color: var(--text-primary); }

.status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.comment, .attachment-link { border-top: 1px solid var(--border-subtle); padding: 12px 0; }
.attachment-link { display: block; color: var(--brand-hover); font-weight: 800; }
.comment p { margin: 8px 0; line-height: 1.5; white-space: pre-wrap; }
.comment time { color: var(--text-muted); font-size: 12px; }
.internal-note { margin-left: 8px; color: var(--purple); font-size: 12px; font-weight: 900; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 22, 20, .48);
  backdrop-filter: blur(6px);
}

.confirm-dialog {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.danger-button { background: var(--danger); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}
.toast-error { background: var(--danger); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px;
  box-shadow: var(--shadow-xs);
}

.chart-bars, .number-list { display: grid; gap: 12px; }
.chart-row, .number-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-weight: 750;
}
.chart-track { height: 12px; overflow: hidden; background: var(--neutral-soft); border-radius: 999px; }
.chart-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--vertical-work)); border-radius: inherit; }
.number-row { grid-template-columns: minmax(0, 1fr) auto; padding: 11px 0; border-bottom: 1px solid var(--border-subtle); }
.number-row:last-child { border-bottom: 0; }
