:root {
  --primary: #3b82f6;
  --secondary: #10b981;
  --accent: #8b5cf6;
  --bg: #f8fafc;
  --sidebar: #1e293b;
  --text: #334155;
  --text-light: #64748b;
  --border: #e2e8f0;
  --white: #fff;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-width: 260px;
}

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

body.tc-body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.tc-sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--sidebar) 0%, #0f172a 100%);
  color: #fff;
  padding: 24px 0;
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.tc-sidebar-head {
  padding: 0 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 20px;
}

.tc-sidebar-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tc-sidebar-head span {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tc-nav-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  padding: 8px 20px;
}

.tc-nav {
  flex: 1;
  padding: 0 12px;
}

.tc-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.tc-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tc-nav a.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}

.tc-sidebar-foot {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tc-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.tc-user-meta h4 {
  margin: 0;
  font-size: 0.88rem;
}

.tc-user-meta span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
}

.tc-logout {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.tc-logout:hover {
  background: rgba(239, 68, 68, 0.25);
}

.tc-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 32px;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-width));
}

.tc-page-head {
  margin-bottom: 24px;
}

.tc-page-head h2 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}

.tc-page-head p {
  margin: 0;
  color: var(--text-light);
  font-size: 0.9rem;
}

.tc-page-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.tc-page-head-row .tc-page-head {
  margin-bottom: 0;
}

.tc-page-head-row .tc-btn-primary {
  align-self: center;
}

.tc-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tc-btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--white);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: inline-block;
  box-sizing: border-box;
}

button.tc-btn-sm {
  line-height: inherit;
}

.tc-btn-sm:hover {
  background: var(--bg);
}

.tc-btn-sm.danger {
  color: var(--danger);
  border-color: #fecaca;
}

.tc-banner {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  padding: 22px 26px;
  color: #fff;
  margin-bottom: 24px;
}

.tc-banner h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.tc-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .tc-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .tc-sidebar {
    transform: translateX(-100%);
  }
  .tc-sidebar.open {
    transform: translateX(0);
  }
  .tc-main {
    margin-left: 0;
    width: 100%;
    padding: 72px 16px 24px;
  }
  .tc-stats {
    grid-template-columns: 1fr;
  }
}

.tc-stat {
  background: var(--white);
  padding: 18px;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tc-stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-light);
}

.tc-stat .value {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 6px;
}

.tc-stat .value.blue {
  color: var(--primary);
}
.tc-stat .value.green {
  color: var(--secondary);
}
.tc-stat .value.purple {
  color: var(--accent);
}
.tc-stat .value.warning {
  color: var(--warning);
}

.tc-card {
  background: var(--white);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.tc-card h3 {
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.tc-table-wrap {
  overflow-x: auto;
}

table.tc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.tc-table th,
.tc-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tc-table th {
  background: var(--bg);
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tc-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
}

.tc-badge.active,
.tc-badge.paid {
  background: #d1fae5;
  color: #059669;
}
.tc-badge.pending,
.tc-badge.in_progress {
  background: #fef3c7;
  color: #d97706;
}
.tc-badge.inactive,
.tc-badge.planning {
  background: #f1f5f9;
  color: #64748b;
}
.tc-badge.overdue {
  background: #fee2e2;
  color: #dc2626;
}
.tc-badge.prospect {
  background: #e0e7ff;
  color: #4f46e5;
}
.tc-badge.completed {
  background: #dbeafe;
  color: #2563eb;
}

.tc-empty {
  text-align: center;
  padding: 28px;
  color: var(--text-light);
}

.tc-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sidebar) 0%, #0f172a 100%);
  padding: 20px;
}

.tc-login-box {
  background: var(--white);
  padding: 36px;
  border-radius: 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.tc-login-box h1 {
  text-align: center;
  margin: 0 0 6px;
  font-size: 1.6rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tc-login-box .sub {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.tc-field {
  margin-bottom: 14px;
}

.tc-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.tc-field input {
  width: 100%;
  padding: 11px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font: inherit;
}

.tc-field input:focus {
  outline: none;
  border-color: var(--primary);
}

.tc-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.tc-btn {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  width: 100%;
}

.tc-btn:hover {
  opacity: 0.95;
}

.tc-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .tc-grid-2 {
    grid-template-columns: 1fr;
  }
}

.tc-mobile-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .tc-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.tc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
}

.tc-overlay.open {
  display: block;
}

/* CRUD / API UI */
.tc-page-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tc-btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.tc-btn-add:hover {
  opacity: 0.95;
}

.tc-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.75;
}

.tc-icon-btn:hover {
  opacity: 1;
  background: var(--bg);
}

.tc-icon-btn.danger:hover {
  background: #fee2e2;
}

.tc-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(15, 23, 42, 0.55);
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.tc-modal-backdrop.open {
  display: flex;
}

.tc-modal-panel {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.tc-modal-panel.wide {
  max-width: 720px;
}

.tc-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.tc-modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.tc-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.tc-modal-close:hover {
  background: var(--danger);
  color: #fff;
}

.tc-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.tc-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .tc-form-grid {
    grid-template-columns: 1fr;
  }
}

.tc-form-grid .full {
  grid-column: 1 / -1;
}

.tc-form-grid label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.tc-form-grid input,
.tc-form-grid select,
.tc-form-grid textarea {
  width: 100%;
  padding: 9px 11px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.88rem;
}

.tc-form-grid textarea {
  min-height: 72px;
  resize: vertical;
}

.tc-form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.tc-btn-secondary {
  padding: 9px 16px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--white);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.tc-btn-secondary:hover {
  background: var(--bg);
}

.tc-btn-primary {
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tc-api-err {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.tc-inv-row {
  display: grid;
  grid-template-columns: 1fr 70px 90px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

@media (max-width: 520px) {
  .tc-inv-row {
    grid-template-columns: 1fr 1fr 36px;
  }
  .tc-inv-row input:first-child {
    grid-column: 1 / -1;
  }
}
