/* === Design Tokens — Modern Material Ethos === */
:root {
  /* Google Material colors */
  --color-primary: #1a73e8;
  --color-primary-hover: #1557b0;
  --color-primary-container: #d2e3fc;
  --color-on-primary-container: #041e49;
  --color-success: #34a853;
  --color-success-hover: #1e8e3e;
  --color-error: #ea4335;
  --color-error-hover: #c5221f;
  --color-warning: #fbbc04;

  /* Surfaces */
  --color-surface: #ffffff;
  --color-surface-secondary: #f8f9fa;
  --color-surface-hover: #f1f3f4;
  --color-surface-tertiary: #e8eaed;

  /* Text */
  --color-text: #3c4043;
  --color-text-muted: #5f6368;
  --color-on-primary: #ffffff;

  /* Borders */
  --color-border: #dadce0;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(60, 64, 67, 0.3);
  --shadow-2: 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-3: 0 4px 8px 3px rgba(60, 64, 67, 0.15);

  /* Spacing — 8px grid */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Roboto Flex', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* === Reset & Base === */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@300;400;500;600&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.25px;
  color: var(--color-text);
  background: var(--color-surface-secondary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.3;
}
h1 { font-size: 22px; letter-spacing: 0; }
h2 { font-size: 16px; letter-spacing: 0.15px; }
h3 { font-size: 14px; letter-spacing: 0.1px; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Layout === */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* === Top App Bar === */
.app-bar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-bar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
}
.app-bar .brand {
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.15px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.app-bar .brand:hover { text-decoration: none; }
.app-bar .brand .dot {
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 600;
}
.app-bar .nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.app-bar .nav-links a {
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--color-text-muted);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  transition: background 0.15s;
}
.app-bar .nav-links a:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}
.app-bar .nav-links a.active {
  background: var(--color-primary-container);
  color: var(--color-on-primary-container);
}

/* === Main Content === */
main {
  padding-top: var(--space-lg);
  padding-bottom: var(--space-xxl);
}

/* === Cards === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}
.card.card-hover:hover {
  box-shadow: var(--shadow-1);
  border-color: var(--color-primary);
  transition: box-shadow 0.2s, border-color 0.2s;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 40px;
  padding: 0 var(--space-lg);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-filled {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-2);
}
.btn-filled:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-3);
}

.btn-tonal {
  background: var(--color-primary-container);
  color: var(--color-on-primary-container);
}
.btn-tonal:hover { background: #c2d7f5; }

.btn-outlined {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}
.btn-outlined:hover { background: var(--color-surface-hover); }

.btn-success {
  background: var(--color-success);
  color: white;
}
.btn-success:hover { background: var(--color-success-hover); }

.btn-danger {
  background: var(--color-error);
  color: white;
}
.btn-danger:hover { background: var(--color-error-hover); }

.btn-sm {
  min-height: 32px;
  padding: 0 var(--space-md);
  font-size: 13px;
}
.btn-lg {
  min-height: 48px;
  padding: 0 var(--space-xl);
  font-size: 16px;
}

/* === Alerts / Flash Messages === */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
}
.alert-success {
  background: #e6f4ea;
  color: #137333;
  border: 1px solid #ceead6;
}
.alert-error {
  background: #fce8e6;
  color: #c5221f;
  border: 1px solid #f5c6cb;
}
.alert-warning {
  background: #fef7e0;
  color: #9c6e00;
  border: 1px solid #feefc3;
}

/* === Forms === */
.form-group {
  margin-bottom: var(--space-md);
}
.form-group label {
  display: block;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}
.form-group input,
.form-group select {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-md);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6368' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  border-width: 2px;
  padding: 0 calc(var(--space-md) - 1px);
}
.form-group input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}
.form-row {
  display: flex;
  gap: var(--space-md);
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
thead th {
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
}
tbody td {
  font-size: 14px;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid #f1f3f4;
  color: var(--color-text);
  background: var(--color-surface);
}
tbody tr:hover td {
  background: var(--color-surface-secondary);
}

/* === Inline inputs (inside table cells) === */
.inline-input {
  width: 100%;
  max-width: 130px;
  height: 32px;
  padding: 0 var(--space-sm);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.inline-input:focus { outline: none; }

/* === New row inputs (data entry table) === */
.new-row input {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-sm);
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 0.15s, border-color 0.15s;
}
.new-row input:hover { background: var(--color-surface-hover); }
.new-row input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}
.new-row td { padding: var(--space-xs) var(--space-sm); }

/* === Dashboard / Empresa grid === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
}

.grid-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  color: var(--color-text);
  text-decoration: none;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.grid-card:hover {
  box-shadow: var(--shadow-1);
  border-color: var(--color-primary);
  text-decoration: none;
  color: var(--color-text);
}
.grid-card .card-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: var(--space-xs);
}
.grid-card .card-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* === Section header === */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.section-header .breadcrumb {
  font-size: 13px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.section-header .breadcrumb a { color: var(--color-text-muted); }
.section-header .breadcrumb a:hover { color: var(--color-primary); }
.section-header .actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* === Utilities === */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* === Chip / Pill === */
.chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--space-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface-hover);
  border-radius: var(--radius-full);
  white-space: nowrap;
  transition: background 0.15s;
}
.chip:hover {
  background: var(--color-surface-tertiary);
  text-decoration: none;
}

/* === Login page === */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-secondary);
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-1);
}
.login-card .login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.login-card .login-brand .dot {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 600;
}
.login-card .login-brand span {
  font-size: 20px;
  font-weight: 500;
  color: var(--color-text);
}

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
  font-size: 13px;
  color: var(--color-text-muted);
}

/* === Responsive === */
@media (max-width: 640px) {
  .container { padding: 0 var(--space-md); }
  .form-row { flex-direction: column; }
  .grid { grid-template-columns: 1fr; }
  .app-bar .container { flex-direction: column; height: auto; padding: var(--space-sm) 0; }
  .app-bar .nav-links { flex-wrap: wrap; justify-content: center; margin-top: var(--space-sm); }
  .section-header { flex-direction: column; align-items: flex-start; }
  .login-card { margin: var(--space-md); }
}
