/* ============================================================
   CTE Sistema — Design System
   ============================================================ */

:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --sidebar-bg:     #0f172a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text:   rgba(255,255,255,.7);
  --topbar-bg:      #ffffff;
  --body-bg:        #f1f5f9;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --white:          #ffffff;
  --success:        #059669;
  --success-light:  #ecfdf5;
  --error:          #dc2626;
  --error-light:    #fef2f2;
  --warning:        #d97706;
  --warning-light:  #fffbeb;
  --sidebar-w:      248px;
  --topbar-h:       60px;
  --radius:         8px;
  --radius-lg:      12px;
  --shadow:         0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 8px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--body-bg);
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }

/* ============================================================
   APP LAYOUT
   ============================================================ */

.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2;
}
.brand-name span {
  display: block; font-size: 11px; font-weight: 400;
  color: rgba(255,255,255,.35); margin-top: 1px;
}

.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }

.nav-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .7px; color: rgba(255,255,255,.28);
  padding: 10px 10px 5px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.nav-link:hover  { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link svg    { flex-shrink: 0; opacity: .75; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--sidebar-border);
}

.btn-logout {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px;
  background: none; border: none; cursor: pointer;
  border-radius: var(--radius);
  color: rgba(255,255,255,.45);
  font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: rgba(220,38,38,.15); color: #fca5a5; }

/* Content area */
.app-content {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column; min-height: 100vh;
}

/* Topbar */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px;
  z-index: 90;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-user  { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--primary);
}
.user-email { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* Page content */
.page-content { flex: 1; padding: 28px; }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Page header */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.page-header p  { font-size: 14px; color: var(--text-muted); }

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 700; color: var(--text); }
.card-body { padding: 22px; }

/* Quick cards */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.quick-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 24px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  cursor: pointer;
}
.quick-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08), var(--shadow-md);
  transform: translateY(-2px);
}
.quick-card-icon {
  width: 50px; height: 50px;
  background: var(--primary-light);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.quick-card-label { font-size: 13px; font-weight: 600; color: var(--text); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-hint { font-size: 12px; color: var(--text-muted); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 22px; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-icon {
  position: absolute; left: 11px;
  top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.input-wrap input { padding-left: 36px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; font-family: inherit;
  transition: background .15s, box-shadow .15s, transform .1s;
}
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
  transform: translateY(-1px);
}
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-full { width: 100%; justify-content: center; }
.btn-spin {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite; display: none;
}
.btn-primary.loading .btn-txt { opacity: .7; }
.btn-primary.loading .btn-spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Alerts */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 20px;
}
.alert-error   { background: var(--error-light);   color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 14px;
  background: #f8fafc;
  font-weight: 600; color: var(--text-muted); text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* Upload area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 24px; text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-area-icon { margin: 0 auto 12px; color: var(--text-muted); }
.upload-area h3   { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.upload-area p    { font-size: 13px; color: var(--text-muted); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page { min-height: 100vh; display: flex; background: var(--body-bg); }

.login-brand {
  flex: 0 0 42%;
  background: linear-gradient(155deg, #0f172a 0%, #1e3a8a 60%, #1d4ed8 100%);
  display: flex; flex-direction: column;
  justify-content: center; align-items: flex-start;
  padding: 60px 56px; position: relative; overflow: hidden;
}
.login-brand::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='29' fill='none' stroke='rgba(255,255,255,.04)' stroke-width='1'/%3E%3C/svg%3E") 0 0/60px 60px;
  pointer-events: none;
}
.login-brand .brand-logo {
  width: 52px; height: 52px; border-radius: 14px; font-size: 17px;
  margin-bottom: 28px; box-shadow: 0 8px 20px rgba(37,99,235,.45);
}
.login-brand h1 {
  font-size: 30px; font-weight: 800; color: #fff;
  line-height: 1.2; letter-spacing: -.5px; margin-bottom: 14px;
}
.login-brand > p {
  font-size: 15px; color: rgba(255,255,255,.6); line-height: 1.6; margin-bottom: 36px;
}
.login-brand ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.login-brand ul li {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: rgba(255,255,255,.75); font-weight: 500;
}
.login-brand ul li::before {
  content: ''; width: 18px; height: 18px; flex-shrink: 0;
  background: rgba(255,255,255,.12) url("data:image/svg+xml,%3Csvg width='10' height='10' viewBox='0 0 10 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 5l2.5 2.5L8 3' stroke='%23fff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
  border-radius: 50%;
}
.login-brand-badge {
  position: absolute; bottom: 28px; left: 56px;
  font-size: 12px; color: rgba(255,255,255,.3);
}

.login-form-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 32px;
}
.login-box { width: 100%; max-width: 420px; }

.login-heading { margin-bottom: 28px; }
.login-heading h2 { font-size: 24px; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.login-heading p  { font-size: 14px; color: var(--text-muted); }

.login-form .form-group { margin-bottom: 16px; }
.login-footer { display: flex; justify-content: flex-end; margin-bottom: 20px; margin-top: -8px; }

.forgot-link { font-size: 13px; color: var(--primary); font-weight: 500; }
.forgot-link:hover { text-decoration: underline; }

.toggle-pwd {
  position: absolute; right: 10px;
  top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: 4px;
  display: flex; align-items: center; transition: color .15s;
}
.input-wrap:has(.toggle-pwd) input { padding-right: 40px; }
.toggle-pwd:hover { color: #64748b; }

.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--primary); font-weight: 500; margin-top: 20px;
}
.back-link:hover { text-decoration: underline; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .login-brand      { display: none; }
  .login-form-wrap  { padding: 32px 20px; }
  .app-content      { margin-left: 0; }
  .quick-grid       { grid-template-columns: 1fr 1fr; }
  .form-grid        { grid-template-columns: 1fr; }
}
