:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d8e0ea;
  --panel: #ffffff;
  --soft: #f3f6fb;
  --dark: #181225;
  --accent: #7c3aed;
  --accent-dark: #5b21b6;
  --green: #12845f;
  --blue: #2563eb;
  --amber: #b7791f;
  --danger: #d92d20;
  --danger-soft: #fee4e2;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }

body {
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  margin: 0;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sso-redirect {
  align-items: center;
  background: #181225;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.sso-card {
  background: #fff;
  border-radius: 12px;
  max-width: 480px;
  padding: 34px;
  width: 100%;
}

.sso-card h1 {
  font-size: 40px;
  margin: 10px 0;
}

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

.sidebar {
  background: var(--dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 26px 18px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, #7c3aed, #38bdf8);
  border-radius: 10px;
  color: #fff;
  display: flex;
  font-weight: 900;
  height: 58px;
  justify-content: center;
  width: 58px;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span,
.panel-label,
.eyebrow {
  color: #98a2b3;
  letter-spacing: 0;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255,255,255,.78);
  display: flex;
  gap: 14px;
  min-height: 52px;
  padding: 0 16px;
  text-align: left;
}

.nav-item.active {
  background: rgba(124, 58, 237, .24);
  border-color: rgba(255,255,255,.12);
  color: #fff;
}

.sidebar-panel {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  margin-top: auto;
  padding: 18px;
}

.sidebar-panel ol {
  margin: 14px 0 0;
  padding-left: 20px;
}

.sidebar-panel li {
  margin: 8px 0;
}

.main {
  overflow: hidden;
}

.topbar {
  align-items: start;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(240px, 1fr) auto;
  padding: 26px 30px;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1;
  margin: 4px 0 0;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: end;
}

.user-chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 180px;
  padding: 9px 12px;
}

.user-chip span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.danger-button {
  align-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger);
}

.danger-zone {
  background: #fff6f6;
  border: 1px solid #fecdca;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  padding: 12px;
}

.danger-zone p {
  margin: 0;
}

.icon-button {
  background: #eef2f7;
  color: var(--ink);
  font-size: 26px;
  height: 48px;
  padding: 0;
  width: 48px;
}

.notification-button span {
  background: var(--danger);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  justify-content: center;
  margin-left: 8px;
  min-width: 22px;
  padding: 2px 7px;
}

.notification-panel,
.system-message,
.view {
  margin: 22px 30px 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.notification-panel,
.panel,
.metric,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.notification-panel,
.system-message {
  padding: 16px;
}

.system-message.error {
  background: #fff4e5;
  border-color: #f6c36b;
  color: #7a4a00;
}

.system-message.success {
  background: #e8f7ef;
  border-color: #b7e4ca;
  color: #176342;
}

.metric-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  border-top: 6px solid var(--accent);
  min-height: 140px;
  padding: 20px;
}

.metric.blue { border-top-color: var(--blue); }
.metric.green { border-top-color: var(--green); }
.metric.purple { border-top-color: var(--accent); }
.metric.amber { border-top-color: var(--amber); }
.metric.red { border-top-color: var(--danger); }

.metric span,
.metric small,
.panel p,
.section-toolbar p,
.hint {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 26px;
  margin: 10px 0 6px;
}

.content-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, .8fr);
  margin-top: 18px;
}

.panel {
  padding: 20px;
}

.panel.wide {
  min-width: 0;
}

.panel-header,
.section-toolbar,
.modal-header,
.modal-actions {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.panel-header h2,
.section-toolbar h2,
.modal-header h2 {
  margin: 0;
}

.section-toolbar {
  margin-bottom: 14px;
}

.request-list {
  display: grid;
  gap: 12px;
}

.request-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.request-card header {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.request-card h3,
.request-card p {
  margin: 0;
}

.request-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  padding: 6px 10px;
}

.stage-manager { background: #fff7e6; color: #9a5b00; }
.stage-gm { background: #eef4ff; color: #1849a9; }
.stage-approved { background: #e8f7ef; color: #176342; }
.stage-rejected { background: #fee4e2; color: #b42318; }
.attendance-overtime { background: #e8f7ef; color: #176342; }
.attendance-missing { background: #fee4e2; color: #b42318; }
.attendance-on_time { background: #eef4ff; color: #1849a9; }

.attendance-row-overtime td {
  background: #f2fbf6;
}

.attendance-row-missing td {
  background: #fff6f6;
}

.attendance-row-on_time td {
  background: #f5f8ff;
}

.approval-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.kanban {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 360px;
  padding: 14px;
}

.kanban-column h3 {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 0 12px;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 900px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.profile-card {
  display: grid;
  gap: 12px;
}

.profile-widget {
  margin-bottom: 18px;
}

.profile-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.profile-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-bottom: 10px;
}

.profile-grid .profile-row {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.profile-row span {
  color: var(--muted);
  font-weight: 800;
}

.profile-page-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(280px, .8fr) minmax(0, 1.6fr);
}

.profile-hero {
  align-items: center;
  display: flex;
  gap: 18px;
}

.profile-photo {
  align-items: center;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 18px;
  color: #fff;
  display: flex;
  flex: 0 0 96px;
  font-size: 26px;
  font-weight: 900;
  height: 96px;
  justify-content: center;
  overflow: hidden;
  width: 96px;
}

.profile-photo img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-attendance-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.mini-attendance-row {
  align-items: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  padding: 10px 12px;
}

.mini-attendance-row.attendance-row-overtime {
  border-left-color: var(--green);
  background: #f2fbf6;
}

.mini-attendance-row.attendance-row-missing {
  border-left-color: var(--danger);
  background: #fff6f6;
}

.balance-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.balance-strip article {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
}

.balance-strip span,
.balance-strip small {
  color: var(--muted);
}

.balance-strip strong {
  font-size: 24px;
}

.compact-card {
  padding: 12px;
}

.report-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.report-filter-panel,
.report-table-panel {
  margin-bottom: 18px;
}

.report-filter-grid {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: 190px minmax(240px, 1fr) 170px 170px;
}

.report-filter-grid label {
  color: var(--muted);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

.attendance-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  margin-bottom: 18px;
}

.users-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, .7fr) minmax(0, 1.3fr);
}

.attendance-metrics {
  margin-bottom: 18px;
}

.attendance-filter-panel {
  margin-bottom: 18px;
}

.attendance-filter-grid {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
  margin-top: 14px;
}

.attendance-filter-grid label {
  color: var(--muted);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

.attendance-summary-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.summary-chip {
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 12px;
}

.summary-chip span {
  color: var(--muted);
}

.summary-chip.summary-missing {
  border-left-color: var(--danger);
  background: #fff6f6;
}

.summary-chip.summary-ok {
  border-left-color: var(--green);
  background: #f2fbf6;
}

.day-group-row td {
  background: #eef2f7;
  color: var(--ink);
  font-weight: 900;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  color: var(--muted);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

.load-error {
  margin: 16vh auto;
  max-width: 640px;
  padding: 28px;
}

.muted {
  color: var(--muted);
}

.modal {
  border: 0;
  background: transparent;
  max-width: min(920px, calc(100vw - 28px));
  width: 920px;
}

#user-dialog {
  width: min(1080px, calc(100vw - 28px));
}

.modal.narrow {
  width: 560px;
}

.modal::backdrop {
  background: rgba(15, 23, 42, .56);
}

.modal-card {
  padding: 26px;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid label {
  color: var(--muted);
  display: grid;
  font-weight: 800;
  gap: 7px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
}

.form-fieldset legend {
  color: var(--ink);
  font-weight: 900;
  padding: 0 8px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

.warning-profile.notice,
.warning-profile.warning,
.warning-profile.final {
  border-left: 5px solid var(--amber);
  padding-left: 12px;
}

.warning-profile.warning,
.warning-profile.final {
  background: #fff7e6;
}

.warning-profile.final {
  border-left-color: var(--danger);
  background: #fff6f6;
}

textarea {
  resize: vertical;
}

.decision-note {
  color: var(--muted);
  display: grid;
  font-weight: 800;
  gap: 8px;
}

.form-error {
  color: var(--danger);
  font-weight: 800;
  min-height: 22px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .metric-grid,
  .content-grid,
  .attendance-grid,
  .attendance-filter-grid,
  .attendance-summary-strip,
  .balance-strip,
  .profile-grid,
  .profile-page-grid,
  .mini-attendance-row,
  .users-layout,
  .report-grid,
  .report-filter-grid {
    grid-template-columns: 1fr;
  }
  .topbar {
    grid-template-columns: 1fr;
  }
  .topbar-actions {
    justify-content: start;
  }
}
