:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1c2638;
  --muted: #677189;
  --line: #e1e5ee;
  --primary: #7b1e2b;       /* merah maroon */
  --primary-dark: #5e1520;
  --primary-soft: #f6e8ea;
  --navy: #1e2f55;          /* biru navy */
  --navy-dark: #15223f;
  --navy-soft: #e7ebf3;
  --danger: #c0564b;
  --danger-soft: #f8e6e3;
  --warn: #b7862c;
  --warn-soft: #f8efdc;
  --ok: #3c8a57;
  --ok-soft: #e2f1e6;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 40, 35, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
h2 { font-size: 1.15rem; color: var(--navy); }
h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }

label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border: 0; border-radius: 10px; font: inherit; font-weight: 600;
  background: var(--primary); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.light { background: var(--primary-soft); color: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.navy { background: var(--navy); }
.btn.navy:hover { background: var(--navy-dark); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.big { padding: 18px; font-size: 1.1rem; border-radius: 14px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--navy-soft); color: var(--navy); }

/* toast & loading */
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 99; max-width: 92vw;
  background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: .92rem; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
#toast.error { background: var(--danger); }
#loading { position: fixed; inset: 0; background: rgba(255,255,255,.8); z-index: 98; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; font-weight: 600; color: var(--navy); }
.spinner { width: 38px; height: 38px; border: 4px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 55%, var(--primary-dark) 100%); }
.login-box { width: 100%; max-width: 380px; border-top: 5px solid var(--primary); text-align: center; }
.login-box form { text-align: left; }
.login-box .logo { width: 110px; height: auto; display: block; margin: 4px auto 10px; }
.company { font-weight: 700; color: var(--navy); letter-spacing: .2px; }
.login-box h1 { font-size: 1.25rem; color: var(--primary); margin-top: 4px; }
.login-foot { color: rgba(255,255,255,.7); font-size: .8rem; text-align: center; margin-top: 14px; }

/* foto */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--line); cursor: zoom-in; display: block; }
.thumb-wrap { position: relative; }
.thumb-wrap .x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--danger); color: #fff; font-size: 14px; line-height: 22px; cursor: pointer; padding: 0; }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,30,28,.45); z-index: 90; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 16px; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 520px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ===== aplikasi karyawan (HP) ===== */
body.emp { padding-bottom: 76px; }
.emp-header { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); color: #fff; padding: 14px 16px 52px; border-bottom: 4px solid var(--primary); }
.emp-header .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.emp-header .brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.emp-header .brand div { font-weight: 700; font-size: .92rem; line-height: 1.2; }
.emp-header .brand small { display: block; font-weight: 400; opacity: .75; font-size: .75rem; }
.emp-header .name { font-weight: 700; font-size: 1.1rem; }
.emp-header .sub { opacity: .85; font-size: .88rem; }
.emp-main { max-width: 560px; margin: -38px auto 0; padding: 0 16px; }
.clock { text-align: center; }
.clock .time { font-size: 2.6rem; font-weight: 700; letter-spacing: 1px; color: var(--navy); }
.att-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.att-cell { background: var(--bg); border-radius: 12px; padding: 10px; text-align: center; }
.att-cell .v { font-size: 1.3rem; font-weight: 700; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav button { flex: 1; border: 0; background: none; padding: 10px 0 12px; font: inherit; font-size: .78rem; color: var(--muted); cursor: pointer; }
.bottom-nav button .ic { display: block; font-size: 1.35rem; line-height: 1.2; }
.bottom-nav button.active { color: var(--primary); font-weight: 600; }
.act-item { border-top: 1px solid var(--line); padding: 12px 0; }
.act-item:first-child { border-top: 0; padding-top: 0; }
.day-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.day-item:first-child { border-top: 0; }

/* ===== admin ===== */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--navy); color: #dbe1ee; padding: 18px 12px; flex-shrink: 0; }
.sidebar .brand { padding: 0 6px 16px; color: #fff; display: flex; align-items: center; gap: 10px; }
.sidebar .brand img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; flex-shrink: 0; }
.sidebar .brand div { font-weight: 700; font-size: .9rem; line-height: 1.25; }
.sidebar .brand small { display: block; font-weight: 400; opacity: .7; font-size: .75rem; }
.sidebar button { display: block; width: 100%; text-align: left; border: 0; background: none; color: inherit; font: inherit;
  padding: 10px 12px; border-radius: 9px; cursor: pointer; margin-bottom: 2px; }
.sidebar button:hover { background: rgba(255,255,255,.07); }
.sidebar button.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar .sep { height: 1px; background: rgba(255,255,255,.12); margin: 10px 6px; }
.content { flex: 1; padding: 22px; min-width: 0; }
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title h1 { font-size: 1.35rem; margin: 0; color: var(--navy); }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.filters label { margin-top: 0; }
.filters .btns { display: flex; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-left: 4px solid var(--navy); }
.stat .v { font-size: 1.7rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.content > h2 { margin-top: 4px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--navy-soft); font-weight: 600; color: var(--navy); font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td .thumb { width: 48px; height: 48px; border-radius: 8px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.act-card { display: flex; gap: 14px; }
.act-card .desc { white-space: pre-wrap; }

@media (max-width: 820px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: auto; display: flex; overflow-x: auto; padding: 8px; gap: 4px; position: sticky; top: 0; z-index: 40; }
  .sidebar .brand, .sidebar .sep { display: none; }
  .sidebar button { width: auto; white-space: nowrap; margin: 0; }
  .content { padding: 16px; }
}

/* cetak laporan */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* arsip foto */
.thumb.archived { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; font-size: 20px; color: var(--muted); cursor: default; border: 1px dashed var(--line); background: var(--bg); }
.thumb.archived small { font-size: 10px; }
.alert { background: var(--warn-soft); color: #6d4c12; border-left: 4px solid var(--warn); padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar span { display: block; height: 100%; border-radius: 99px; }

/* pilihan hak akses admin */
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .92rem; margin: 6px 0; cursor: pointer; }
label.check input { width: auto; margin: 0; }
.check-list { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-top: 6px; max-height: 220px; overflow-y: auto; background: var(--bg); }

.clock .time .tz { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
