/* ============================================================
   HRMIS design system — self-hosted, no external dependencies
   ============================================================ */
:root {
    --navy: #17365D;
    --navy-700: #1f4677;
    --navy-50: #eef5fa;
    --blue: #2f6fb0;
    --blue-100: #d9eaf7;
    --accent: #0d9488;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --line: #e2e8f0;
    --text: #1e2a38;
    --muted: #64748b;
    --ok: #15803d; --ok-bg: #dcfce7;
    --warn: #b45309; --warn-bg: #fef3c7;
    --bad: #b91c1c; --bad-bg: #fee2e2;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
    --sidebar-w: 244px;
    --font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { color: var(--navy); margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }

/* ---- Auth ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 60%, var(--blue) 100%); padding: 1rem; }
.auth-card { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 45px rgba(0,0,0,.25); width: 100%; max-width: 400px; padding: 2rem; }
.auth-card .brand { text-align: center; margin-bottom: 1.25rem; }
.auth-card .brand .logo { width: 54px; height: 54px; border-radius: 12px; background: var(--navy); color:#fff; display:grid; place-items:center; font-weight:700; font-size:1.3rem; margin: 0 auto .6rem; }
.auth-card h1 { font-size: 1.15rem; text-align: center; }
.auth-sub { color: var(--muted); text-align: center; font-size: .85rem; margin-bottom: 1.25rem; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--navy); color: #cfdcea; position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; z-index: 40; }
.sidebar .brand { padding: 1rem 1.1rem; display: flex; align-items: center; gap: .6rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--blue); color:#fff; display:grid; place-items:center; font-weight:700; flex: 0 0 auto; }
.sidebar .brand .t { color: #fff; font-weight: 600; font-size: .92rem; line-height: 1.15; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .6rem 0; }
.sidebar .nav-section { color: #7b93ad; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: .8rem 1.1rem .3rem; }
.sidebar a.nav-item { display: flex; align-items: center; gap: .65rem; padding: .5rem 1.1rem; color: #cfdcea; font-size: .875rem; border-left: 3px solid transparent; }
.sidebar a.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar a.nav-item.active { background: rgba(47,111,176,.28); border-left-color: var(--blue); color: #fff; }
.sidebar a.nav-item .ico { width: 18px; text-align: center; opacity: .9; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 1.25rem; position: sticky; top: 0; z-index: 30; }
.topbar .page-title { font-weight: 600; color: var(--navy); }
.topbar .right { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-50); color: var(--navy); display: grid; place-items: center; font-weight: 600; font-size: .8rem; }
.user-menu { display:flex; align-items:center; gap:.55rem; }
.user-menu .role { font-size: .72rem; color: var(--muted); }
.content { padding: 1.25rem; flex: 1; }
.menu-toggle { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--navy); }

/* ---- Cards & grid ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card > .card-head { padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card > .card-head h3 { margin: 0; }
.card > .card-body { padding: 1.1rem; }
.grid { display: grid; gap: 1.25rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; flex-wrap: wrap; gap: 1.25rem; }

/* ---- Stat tiles ---- */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.stat .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--navy); }
.stat .sub { font-size: .78rem; color: var(--muted); }
.stat.accent { border-top: 3px solid var(--blue); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th, table.data td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th { background: var(--navy-50); color: var(--navy); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
table.data tbody tr:hover { background: #f8fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { text-align: center; color: var(--muted); padding: 2rem; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: #e2e8f0; color: #475569; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 600; font-size: .8rem; margin-bottom: .3rem; color: #334155; }
label .req { color: var(--bad); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date],
input[type=time], input[type=search], select, textarea {
    width: 100%; padding: .5rem .6rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,176,.15); }
textarea { min-height: 76px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.field-error { color: var(--bad); font-size: .76rem; margin-top: .25rem; }
input.err, select.err { border-color: var(--bad); }
.help { color: var(--muted); font-size: .76rem; margin-top: .25rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin: 0 0 1.1rem; }
legend { font-weight: 600; color: var(--navy); padding: 0 .4rem; font-size: .85rem; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .84rem; cursor: pointer; background: #e2e8f0; color: #334155; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: #cbd5e1; color: #334155; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Alerts / flash ---- */
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .86rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.alert-info { background: var(--blue-100); color: var(--navy); border-color: #bae6fd; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

/* ---- Misc ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { color: var(--muted); font-size: .8rem; margin-bottom: .3rem; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; color: var(--muted); font-weight: 600; font-size: .85rem; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--navy); border-bottom-color: var(--navy); }
.tabs a:hover { text-decoration: none; color: var(--navy); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: .4rem 1rem; font-size: .87rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.pill { display:inline-block; background: var(--navy-50); color: var(--navy); padding:.12rem .5rem; border-radius: 6px; font-size:.75rem; font-weight:600; }
.chip-list { display:flex; flex-wrap:wrap; gap:.4rem; }
.avatar-lg { width: 72px; height: 72px; border-radius: 50%; background: var(--navy-50); color: var(--navy); display:grid; place-items:center; font-weight:700; font-size:1.4rem; }
.divider { height:1px; background: var(--line); margin: 1rem 0; border: 0; }
.inline-form { display: inline; }
.callout { border-left: 3px solid var(--blue); background: var(--blue-100); padding: .7rem .9rem; border-radius: 0 8px 8px 0; font-size: .84rem; color: var(--navy); margin-bottom: 1rem; }

/* ---- Responsive ---- */
@media (max-width: 980px) {
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: 1fr; }
    .grid.cols-2 { grid-template-columns: 1fr; }
    .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .kv { grid-template-columns: 1fr; }
    .content { padding: .9rem; }
}
