:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1c2430;
  --text-muted: #667085;
  --primary: #1f5f8b;
  --primary-dark: #164a6d;
  --primary-light: #e7f0f7;
  --accent: #2f9e6e;
  --warn: #c8871a;
  --danger: #c0392b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #16344d 0%, #1f5f8b 55%, #2f9e6e 130%);
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand h1 { margin: 12px 0 4px; font-size: 22px; }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 13px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary); color: white; font-weight: 700; font-size: 15px;
  margin: 0 auto;
}
#login-form label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--text-muted); }
#login-form input {
  width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.form-error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.login-hint { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.login-hint table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.login-hint td { padding: 3px 0; }
.login-hint code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0; background: #16273a; color: #cfd9e3;
  display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px; color: white; font-weight: 700; font-size: 16px; }
.sidebar-brand .brand-mark { width: 32px; height: 32px; font-size: 13px; border-radius: 9px; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: #cfd9e3; text-decoration: none; font-size: 13.5px; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: #6f8199; margin: 14px 10px 4px; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 12px; margin-top: 12px; }
.user-name { color: white; font-size: 13.5px; font-weight: 600; }
.user-role { color: #8ea2b8; font-size: 12px; text-transform: capitalize; margin-bottom: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.cycle-badge { font-size: 12px; background: var(--primary-light); color: var(--primary-dark); padding: 5px 12px; border-radius: 999px; font-weight: 600; }
.view-content { padding: 24px 28px 60px; overflow-y: auto; }

.notif-wrap { position: relative; }
.notif-badge {
  display: inline-block; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 6px;
  border-radius: 999px; background: #d64545; color: white; font-size: 10.5px; font-weight: 700;
  line-height: 16px; text-align: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 420px;
  overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.15); z-index: 150;
}
.notif-panel-header {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.notif-list { padding: 6px; }
.notif-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
  border: none; background: none; font-size: 12.5px; line-height: 1.4; cursor: pointer;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-time { display: block; margin-top: 3px; font-size: 11px; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 600;
  transition: background 0.15s;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f0d3ce; }
.btn-danger:hover { background: #fbeceb; }
.btn-ghost { background: transparent; color: #cfd9e3; border-color: rgba(255,255,255,0.15); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 4px 8px; font-size: 18px; line-height: 1; border: none; background: none; color: var(--text-muted); }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
table.data-table { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data-table th, table.data-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.data-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); font-weight: 700; background: #fafbfc; }
table.data-table tbody tr:hover { background: #f9fafb; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.table-toolbar input, .table-toolbar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.badge-crew { background: #e7f0f7; color: var(--primary-dark); }
.badge-shore { background: #eef2ff; color: #4338ca; }
.badge-completed { background: #e6f5ec; color: #1e7a4c; }
.badge-draft { background: #f1f2f4; color: #5a6472; }
.badge-self-assessment, .badge-manager-review { background: #fdf1de; color: #9a6316; }
.badge-active { background: #e6f5ec; color: #1e7a4c; }
.badge-closed { background: #f1f2f4; color: #5a6472; }
.rating-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; font-weight: 700; font-size: 12.5px; }
.rating-5, .rating-4-5 { background: #e6f5ec; color: #1e7a4c; }
.rating-4, .rating-3-5 { background: #eaf3e0; color: #4c7a1e; }
.rating-3 { background: #fdf1de; color: #9a6316; }
.rating-2, .rating-2-5 { background: #fbe9df; color: #b5501a; }
.rating-1, .rating-1-5 { background: #fbeceb; color: var(--danger); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.form-field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; width: 100%;
}
.form-field textarea { resize: vertical; min-height: 60px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 32, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,0.3); }
.modal.modal-wide { max-width: 760px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px 24px; }

/* ---------- Nine box ---------- */
.ninebox-grid { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 8px; align-items: stretch; }
.ninebox-axis-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; font-weight: 700; color: var(--text-muted); display: flex; align-items: center; justify-content: center; grid-row: span 3; }
.ninebox-cell { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-height: 130px; }
.ninebox-cell .cell-label { font-size: 12px; font-weight: 700; color: var(--primary-dark); margin-bottom: 8px; }
.ninebox-emp { font-size: 12.5px; padding: 5px 7px; background: #f6f8fa; border-radius: 6px; margin-bottom: 5px; }
.ninebox-emp .emp-name { font-weight: 600; }
.ninebox-emp .emp-role { color: var(--text-muted); font-size: 11.5px; }
.ninebox-xlabels { display: grid; grid-template-columns: auto repeat(3, 1fr); gap: 8px; margin-top: 8px; text-align: center; font-size: 12px; font-weight: 700; color: var(--text-muted); }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress-bar-fill { height: 100%; background: var(--primary); }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; margin-right: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tag { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; color: var(--text-muted); }
.feedback-item { border-left: 3px solid var(--primary); padding: 8px 0 8px 12px; margin-bottom: 10px; background: #fafbfc; border-radius: 0 8px 8px 0; }
.feedback-item .meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: #16273a; color: white;
  padding: 12px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 20px rgba(0,0,0,0.25); z-index: 200;
}
.toast.error { background: var(--danger); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn { padding: 9px 14px; border: none; background: none; font-weight: 600; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.scale-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.scale-row label { flex: 1; font-size: 13px; }
.scale-row select, .scale-row input[type=number] { width: 90px; }
