:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --bg: #f8fafc;
  --sidebar-bg: #0f172a;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;

  --present-bg: #dcfce7;
  --present-color: #15803d;
  --late-bg: #fef9c3;
  --late-color: #a16207;
  --absent-bg: #fee2e2;
  --absent-color: #b91c1c;
  --leave-bg: #e0f2fe;
  --leave-color: #0369a1;
  --company-bg: #f3e8ff;
  --company-color: #6b21a8;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg); color: var(--text-main); height: 100vh; overflow: hidden; }

/* LOGIN SCREEN */
.login-container {
  display: flex; height: 100vh; width: 100vw; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.login-card {
  background: #ffffff; width: 100%; max-width: 420px; padding: 2.5rem;
  border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header .logo-badge {
  background: var(--primary-light); color: var(--primary); width: 48px; height: 48px;
  border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.75rem;
}
.login-header h2 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.login-header p { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }

.role-toggle {
  display: flex; background: #f1f5f9; padding: 4px; border-radius: 8px; margin-bottom: 1.5rem;
}
.role-btn {
  flex: 1; padding: 0.5rem; border: none; background: transparent; font-size: 0.85rem;
  font-weight: 600; color: var(--text-muted); border-radius: 6px; cursor: pointer; transition: 0.2s;
}
.role-btn.active { background: #ffffff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* MAIN INTERFACE */
.app-container { display: none; height: 100vh; width: 100vw; }
.app-container.active { display: flex; }

aside {
  width: 260px; background: var(--sidebar-bg); color: #94a3b8;
  padding: 1.25rem 1rem; display: flex; flex-direction: column; justify-content: space-between; flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 0.75rem; color: #fff; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.5px; }
.brand-icon { background: var(--primary); color: #fff; padding: 0.4rem; border-radius: 8px; display: flex; }

nav { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 0.35rem; }
nav button {
  background: transparent; border: none; color: #94a3b8; padding: 0.75rem 1rem;
  border-radius: 8px; font-size: 0.875rem; font-weight: 500; display: flex; align-items: center;
  gap: 0.75rem; cursor: pointer; text-align: left; width: 100%; transition: all 0.2s;
}
nav button:hover { background: rgba(255, 255, 255, 0.08); color: #ffffff; }
nav button.active { background: var(--primary); color: #ffffff; }

.user-profile-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 0.75rem; border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 600;
}

main { flex: 1; padding: 2rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1.5rem; }
header { display: flex; justify-content: space-between; align-items: center; }
header h1 { font-size: 1.5rem; font-weight: 700; }
header p { font-size: 0.85rem; color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem;
  font-size: 0.85rem; font-weight: 600; border-radius: 8px; cursor: pointer; border: none; transition: 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text-main); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-purple { background: #9333ea; color: #fff; }
.btn-purple:hover { background: #7e22ce; }
.btn-danger { background: #fee2e2; color: #b91c1c; }

/* TERMINAL CARD */
.terminal-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px;
  padding: 2rem; max-width: 600px; margin: 0 auto; width: 100%; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
  text-align: center; display: flex; flex-direction: column; gap: 1.25rem;
}
.terminal-clock-display {
  font-size: 2.25rem; font-weight: 800; font-family: monospace; color: var(--primary); letter-spacing: 1.5px;
}

.media-preview-container {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 0.5rem;
}
.preview-box {
  border: 1px dashed var(--border); border-radius: 10px; padding: 0.75rem;
  background: #f8fafc; min-height: 140px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.5rem; position: relative;
}
.preview-box video, .preview-box img {
  width: 100%; height: 120px; object-fit: cover; border-radius: 8px;
}

.btn-punch-main {
  padding: 0.85rem; font-size: 1.1rem; font-weight: 700; border-radius: 10px; border: none;
  cursor: pointer; width: 100%; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-punch-main.in { background: #22c55e; color: #fff; }
.btn-punch-main.in:hover { background: #16a34a; }
.btn-punch-main.out { background: #ef4444; color: #fff; }
.btn-punch-main.out:hover { background: #dc2626; }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.metric-card {
  background: var(--card-bg); border: 1px solid var(--border); padding: 1.25rem;
  border-radius: var(--radius); display: flex; align-items: center; justify-content: space-between;
}
.metric-title { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.metric-value { font-size: 1.75rem; font-weight: 700; margin-top: 0.25rem; }

.toolbar {
  background: var(--card-bg); border: 1px solid var(--border); padding: 0.85rem 1rem;
  border-radius: var(--radius); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: center;
}
.search-input { position: relative; flex: 1; min-width: 220px; }
.search-input input {
  width: 100%; padding: 0.5rem 0.8rem 0.5rem 2.2rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; outline: none;
}
.search-input i { position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; }

.filter-selects { display: flex; gap: 0.5rem; }
.filter-selects select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; background: #fff; outline: none; }

.table-container { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #f8fafc; color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); }
td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; vertical-align: middle; }
tr:hover { background: #f8fafc; }

.badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.6rem; border-radius: 50px; font-size: 0.75rem; font-weight: 600; }
.badge-present { background: var(--present-bg); color: var(--present-color); }
.badge-late { background: var(--late-bg); color: var(--late-color); }
.badge-absent { background: var(--absent-bg); color: var(--absent-color); }
.badge-leave { background: var(--leave-bg); color: var(--leave-color); }
.badge-company { background: var(--company-bg); color: var(--company-color); }

.action-group { display: flex; gap: 0.35rem; }
.icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.icon-btn:hover { background: var(--border); color: var(--text-main); }

.input-rate {
  width: 100px; padding: 0.35rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; font-weight: 600; outline: none;
}

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(2px); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px; padding: 1.5rem; box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.form-group { margin-bottom: 0.85rem; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.25rem; }
.form-group input, .form-group select { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; outline: none; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

.credentials-box {
  background: #f8fafc; border: 1px dashed var(--primary); border-radius: 8px; padding: 0.85rem; margin-bottom: 0.85rem;
}
.credentials-box-title {
  font-size: 0.75rem; font-weight: 700; color: var(--primary); text-transform: uppercase; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.3rem;
}

.pass-tag {
  font-family: monospace; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; border: 1px solid var(--border);
}

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 0.9rem;
}

.tab-content { display: none; }
.tab-content.active { display: block; }