:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #142033;
  --muted: #65758b;
  --line: #dce5f2;
  --blue: #0b4f9c;
  --blue-2: #0969c3;
  --cyan: #19a7ce;
  --gold: #f0b84a;
  --green: #168a4a;
  --red: #c24141;
  --orange: #c66a17;
  --shadow: 0 12px 28px rgba(22, 38, 61, .08);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #e8f5ff 0, #f3f6fb 38%, #eef3f9 100%);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, rgba(11, 79, 156, .12), rgba(25, 167, 206, .08)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cg fill='none' stroke='%230b4f9c' stroke-opacity='.07'%3E%3Cpath d='M110 12v196M12 110h196M36 36l148 148M184 36L36 184'/%3E%3Ccircle cx='110' cy='110' r='72'/%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
  width: min(460px, 100%);
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 26px;
  box-shadow: 0 28px 60px rgba(11, 79, 156, .18);
  padding: 28px;
  backdrop-filter: blur(12px);
}
.brand-row { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; }
.brand-logo { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 30px; }
h2 { margin-bottom: 2px; font-size: 23px; }
h3 { margin-bottom: 10px; font-size: 18px; }
.brand-row p, .topbar p { color: var(--muted); margin-bottom: 0; }
.stacked-form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; font-size: 13px; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
  outline: none;
  min-width: 0;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(9,105,195,.12); }
.primary-btn, .ghost-btn, .danger-btn, .success-btn, .warning-btn, .icon-btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 760;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.primary-btn { background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: white; box-shadow: 0 10px 20px rgba(9,105,195,.18); }
.success-btn { background: #e8f7ee; color: var(--green); border: 1px solid rgba(22,138,74,.16); }
.warning-btn { background: #fff5e4; color: var(--orange); border: 1px solid rgba(198,106,23,.16); }
.ghost-btn { background: #eef4fb; color: var(--blue); border: 1px solid #d8e6f6; }
.danger-btn { background: #fff0f0; color: var(--red); border: 1px solid #ffd4d4; }
.icon-btn { background: #eef4fb; color: var(--blue); width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center; }
.primary-btn:hover, .ghost-btn:hover, .danger-btn:hover, .success-btn:hover, .warning-btn:hover, .icon-btn:hover { transform: translateY(-1px); }
.login-help { color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 18px; background: #f5f8fd; border: 1px dashed var(--line); border-radius: 14px; padding: 12px; }
.app-shell { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  background: linear-gradient(180deg, #092f62, #0b4f9c 55%, #073569);
  color: white;
  box-shadow: 14px 0 26px rgba(12, 35, 72, .15);
  z-index: 20;
}
.sidebar.collapsed { width: 88px; }
.app-shell.collapsed { grid-template-columns: 88px minmax(0, 1fr); }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.18); margin-bottom: 12px; }
.sidebar-brand img { width: 44px; height: 44px; border-radius: 12px; }
.sidebar-brand small { display: block; opacity: .75; }
.sidebar.collapsed .sidebar-brand div, .sidebar.collapsed .menu-text, .sidebar.collapsed .sidebar-footer { display: none; }
.menu-toggle { width: 100%; margin-bottom: 10px; background: rgba(255,255,255,.12); color: white; }
.menu-list { display: grid; gap: 5px; }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.88);
  background: transparent;
  border-radius: 12px;
  padding: 10px 11px;
  text-align: left;
}
.menu-item.active, .menu-item:hover { background: rgba(255,255,255,.16); color: white; }
.menu-icon { width: 24px; text-align: center; }
.sidebar-footer { margin-top: 20px; color: rgba(255,255,255,.72); padding: 12px; border-top: 1px solid rgba(255,255,255,.16); }
.main-area { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-left { display: flex; gap: 12px; align-items: center; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
#globalSearch { width: min(340px, 28vw); }
.user-pill { display: grid; gap: 1px; background: #f5f8fd; border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; min-width: 160px; }
.user-pill span { font-size: 11px; color: var(--muted); }
.user-pill strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content-area { padding: 20px; }
.message-bar {
  margin: 14px 20px 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #eaf7ee;
  border: 1px solid #c7ebd0;
  color: #126536;
  font-weight: 650;
}
.message-bar.error { background: #fff1f1; border-color: #ffd0d0; color: #b73535; }
.message-bar.info { background: #eef6ff; border-color: #d5e9ff; color: #0b4f9c; }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.kpi-card { display: grid; gap: 6px; min-height: 124px; }
.kpi-card small { color: var(--muted); font-weight: 700; }
.kpi-card strong { font-size: 32px; letter-spacing: -.04em; }
.kpi-card span { color: var(--muted); font-size: 13px; line-height: 1.4; }
.kpi-card.priority { border-left: 5px solid var(--gold); }
.two-column { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.panel-header, .section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-title small { color: var(--muted); display: block; margin-top: 3px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: span 4; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { background: #f2f6fb; color: #2a405f; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tr:hover td { background: #fbfdff; }
.status-badge, .role-badge, .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}
.status-badge { background: #edf5ff; color: #0b4f9c; }
.status-badge.red { background: #fff0f0; color: var(--red); }
.status-badge.green { background: #e9f7ef; color: var(--green); }
.status-badge.orange { background: #fff6e9; color: var(--orange); }
.role-badge { background: #f0f4fb; color: #263d60; }
.tag { background: #f7f7fb; color: var(--muted); margin: 0 4px 4px 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 6px 9px; border-radius: 9px; font-size: 12px; }
.action-select {
  min-width: 132px;
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(22, 38, 61, .05);
}
.action-select:focus { outline: 3px solid rgba(9, 105, 195, .15); border-color: #9cc8f5; }
.ai-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; }
.ai-tool-list { display: grid; gap: 8px; }
.ai-tool { width: 100%; text-align: left; background: #f5f8fd; border: 1px solid var(--line); padding: 12px; border-radius: 12px; }
.ai-tool.active { background: #eaf4ff; border-color: #b9d9fb; color: var(--blue); }
.ai-output {
  background: #0d1f34;
  color: #edf7ff;
  border-radius: 14px;
  padding: 14px;
  min-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.52;
}
.ai-output table { color: var(--text); background: white; white-space: normal; }
.timeline { display: grid; gap: 10px; }
.timeline-item { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; padding: 12px; background: #f8fbff; border: 1px solid var(--line); border-radius: 12px; }
.timeline-item strong { color: var(--blue); }
.notice-list { display: grid; gap: 10px; }
.notice { border-left: 4px solid var(--blue-2); background: #f8fbff; border-radius: 12px; padding: 12px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.notice.warn { border-left-color: var(--orange); }
.notice.danger { border-left-color: var(--red); }
.notice.success { border-left-color: var(--green); }
.empty-state { text-align: center; color: var(--muted); padding: 34px 20px; }

.developer-credit {
  position: fixed;
  left: 10px;
  bottom: 8px;
  z-index: 1500;
  font-size: 11px;
  line-height: 1;
  color: #6b7890;
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(210, 219, 232, .85);
  border-radius: 999px;
  padding: 6px 9px;
  box-shadow: 0 6px 20px rgba(15, 33, 55, .08);
  backdrop-filter: blur(6px);
  user-select: none;
}
.developer-credit a {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.developer-credit a:hover { color: var(--blue); text-decoration: underline; }

.mobile-only { display: none; }
@media (max-width: 1160px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .three-column, .ai-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-4 { grid-column: span 2; }
}
@media (max-width: 820px) {
  .app-shell, .app-shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; transform: translateX(-105%); width: 290px; transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  #globalSearch { width: 100%; flex: 1 1 220px; }
  .card-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-4 { grid-column: span 1; }
  .content-area { padding: 14px; }
  .message-bar { margin: 10px 14px 0; }
  .login-card { padding: 22px; }
}
@media print {
  .sidebar, .topbar, .actions-row, .message-bar { display: none !important; }
  .app-shell { display: block; }
  body { background: #fff; }
  .content-area { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
