/* =====================================================
   Face-ID Davomat Tizimi — Global Styles
   ===================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f4f6fb;
  --card:     #ffffff;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --muted:    #64748b;
  --primary:  #3b82f6;
  --success:  #22c55e;
  --danger:   #ef4444;
  --warning:  #f59e0b;
  --purple:   #8b5cf6;
  --gray:     #94a3b8;
  --nav-h:    60px;
  --radius:   10px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }

/* ---- NAVBAR ---- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: #1e293b;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-brand { color: #fff; font-size: 16px; font-weight: 700; white-space: nowrap; }
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  color: #94a3b8; text-decoration: none; padding: 6px 12px;
  border-radius: 6px; font-size: 13px; transition: all .2s;
}
.nav-links a:hover, .nav-links a.active { background: #334155; color: #fff; }
.nav-logout { margin-left: 8px; }
.nav-logout:hover { background: #7f1d1d !important; color: #fca5a5 !important; }
.nav-time { margin-left: auto; color: #94a3b8; font-size: 13px; font-family: monospace; }

/* ---- LAYOUT ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width:900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- CARD ---- */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
        margin-bottom: 16px; overflow: hidden; }
.card-header {
  padding: 12px 16px; font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--border); background: #f8fafc;
  display: flex; align-items: center; gap: 8px;
}
.alert-header { background: #fff7ed; border-bottom-color: #fed7aa; color: #9a3412; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(6,1fr); gap: 12px; margin-bottom: 16px; }
@media(max-width:1100px) { .stats-grid { grid-template-columns: repeat(3,1fr); } }
@media(max-width:600px)  { .stats-grid { grid-template-columns: repeat(2,1fr); } }

.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  text-align: center; border: 1px solid var(--border);
  border-top: 4px solid transparent; transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 24px; margin-bottom: 4px; }
.stat-val  { font-size: 32px; font-weight: 700; line-height: 1; }
.stat-lbl  { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-green  { border-top-color: var(--success); }  .stat-green  .stat-val { color: var(--success); }
.stat-blue   { border-top-color: var(--primary); }  .stat-blue   .stat-val { color: var(--primary); }
.stat-orange { border-top-color: var(--warning); }  .stat-orange .stat-val { color: var(--warning); }
.stat-red    { border-top-color: var(--danger); }   .stat-red    .stat-val { color: var(--danger); }
.stat-purple { border-top-color: var(--purple); }   .stat-purple .stat-val { color: var(--purple); }
.stat-gray   { border-top-color: var(--gray); }     .stat-gray   .stat-val { color: var(--gray); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 10px 12px; text-align: left; font-weight: 600;
            background: #f8fafc; border-bottom: 2px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.row-entry td:first-child { border-left: 3px solid var(--success); }
.row-exit  td:first-child { border-left: 3px solid var(--danger); }
.row-late  { background: #fff7ed !important; }
.row-late td:first-child { border-left: 3px solid var(--warning) !important; }
.empty { text-align: center; color: var(--muted); padding: 24px !important; }

/* ---- BADGES ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-late   { background: #fed7aa; color: #9a3412; padding: 1px 6px;
                border-radius: 4px; font-size: 11px; margin-left: 4px; }

/* ---- BUTTONS ---- */
.btn { display: inline-block; padding: 8px 16px; border-radius: 7px; font-size: 13px;
       font-weight: 600; border: none; cursor: pointer; text-decoration: none; transition: all .2s; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-secondary { background: #f1f5f9; color: var(--text); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-block { width: 100%; text-align: center; padding: 10px; }
.btn-sm { display: inline-block; padding: 3px 8px; border-radius: 5px; font-size: 12px;
          background: #f1f5f9; color: var(--text); border: 1px solid var(--border);
          cursor: pointer; text-decoration: none; }
.btn-sm:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

/* ---- FORMS ---- */
.form-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 180px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; outline: none; transition: border .2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary); }

/* ---- ALERTS ---- */
.alert { padding: 10px 14px; border-radius: 7px; margin-bottom: 12px; font-size: 13px; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- FACE GRID ---- */
.face-grid { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px; }
.face-card {
  background: #f8fafc; border-radius: 10px; padding: 12px;
  text-align: center; width: 120px; border: 2px solid var(--border);
}
.face-card.late { border-color: var(--warning); background: #fff7ed; }
.face-img { width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
            border: 2px solid var(--border); display: block; margin: 0 auto 8px; }
.face-placeholder { width: 80px; height: 80px; border-radius: 50%; background: #e2e8f0;
                    display: flex; align-items: center; justify-content: center;
                    font-size: 32px; margin: 0 auto 8px; }
.face-name { font-size: 11px; font-weight: 600; line-height: 1.3; }
.face-time { font-size: 12px; color: var(--warning); font-weight: 700; margin-top: 2px; }
.face-dept { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---- THUMB ---- */
.thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
         border: 2px solid var(--border); vertical-align: middle; }
.no-photo { font-size: 20px; }

/* ---- LIVE DOT ---- */
.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50% { opacity:.5; transform:scale(1.4); }
}

/* ---- DEVICES ---- */
.devices-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr));
                gap: 16px; padding: 16px; }
.device-card {
  border-radius: var(--radius); padding: 20px; border: 2px solid var(--border);
  position: relative; text-align: center;
}
.device-online { border-color: #bbf7d0; background: #f0fdf4; }
.device-offline { border-color: #fca5a5; background: #fff1f2; }
.device-status-dot { width: 12px; height: 12px; border-radius: 50%; position: absolute; top: 16px; right: 16px; }
.dot-green { background: var(--success); }
.dot-red   { background: var(--danger); }
.device-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.device-ip   { margin-bottom: 8px; }
.device-loc  { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.device-stat { font-size: 13px; margin: 8px 0; }
.device-last { font-size: 12px; color: var(--muted); }
.device-conn { margin-top: 8px; font-size: 13px; font-weight: 600; }

/* ---- LOGIN ---- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center;
              background: linear-gradient(135deg, #1e293b 0%, #334155 100%); }
.login-wrap { width: 100%; max-width: 400px; padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-icon { font-size: 48px; text-align: center; margin-bottom: 12px; }
.login-card h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 16px; }

/* ---- MISC ---- */
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
ol { padding-left: 20px; }
ol li { margin-bottom: 8px; }
canvas { padding: 12px; }
