/* TPT — white/black/grey, Poppins, mobile-first */
:root {
  --tpt-bg:        #ffffff;
  --tpt-fg:        #111111;
  --tpt-muted:     #6c757d;
  --tpt-border:    #e5e5e5;
  --tpt-surface:   #f7f7f8;
  --tpt-surface-2: #efeff1;
  --tpt-btn:       #4a4a4a;
  --tpt-btn-hover: #2f2f2f;
  --tpt-btn-light: #e9e9ec;
  --tpt-accent:    #222222;
  --tpt-danger:    #d33;
  --tpt-warn:      #a77800;
  --tpt-success:   #166c3b;
  --tpt-radius:    10px;
  --tpt-sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--tpt-bg);
  color: var(--tpt-fg);
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--tpt-fg); text-decoration: none; }
a:hover { color: #000; text-decoration: underline; }

/* Layout */
.tpt-app { display: flex; min-height: 100vh; }
.tpt-sidebar {
  width: var(--tpt-sidebar-w);
  background: var(--tpt-surface);
  border-right: 1px solid var(--tpt-border);
  position: fixed;
  inset: 0 auto 0 0;
  transform: translateX(-100%);
  transition: transform 200ms ease;
  z-index: 1040;
  overflow-y: auto;
}
.tpt-sidebar.open { transform: translateX(0); }
.tpt-sidebar-brand {
  font-weight: 700; font-size: 1.05rem;
  padding: 16px; border-bottom: 1px solid var(--tpt-border);
  letter-spacing: .3px;
}
.tpt-nav { list-style: none; margin: 0; padding: 8px 0; }
.tpt-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; color: var(--tpt-fg);
  font-size: .92rem;
}
.tpt-nav a:hover { background: var(--tpt-surface-2); text-decoration: none; }
.tpt-nav a.active { background: #111; color: #fff; }

/* Accordion sections */
.tpt-section-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: 0;
  padding: 9px 14px; color: var(--tpt-fg);
  font-size: .92rem; font-family: inherit; cursor: pointer;
  text-align: left;
}
.tpt-section-head:hover { background: var(--tpt-surface-2); }
.tpt-section-caret { font-size: .75rem; transition: transform 180ms ease; color: var(--tpt-muted); }
.tpt-section.open .tpt-section-caret { transform: rotate(180deg); }

.tpt-section-items {
  max-height: 0; overflow: hidden;
  transition: max-height 220ms ease;
}
.tpt-section.open .tpt-section-items { max-height: 600px; }

.tpt-section-items a {
  padding: 7px 14px 7px 40px; font-size: .88rem;
}

/* Highlight the whole section header when a child is active */
.tpt-section.has-active > .tpt-section-head {
  color: #111; font-weight: 600;
}

/* Topbar */
.tpt-main { flex: 1; min-width: 0; margin-left: 0; display: flex; flex-direction: column; }
.tpt-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--tpt-border);
  background: #fff; position: sticky; top: 0; z-index: 1030;
}
.tpt-hamburger {
  background: transparent; border: 1px solid var(--tpt-border);
  width: 38px; height: 38px; border-radius: var(--tpt-radius);
  cursor: pointer;
}
.tpt-topbar-title { font-weight: 600; }
.tpt-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.tpt-content { padding: 16px; }

/* Desktop */
@media (min-width: 992px) {
  .tpt-sidebar { transform: translateX(0); }
  .tpt-main { margin-left: var(--tpt-sidebar-w); }
  .tpt-hamburger { display: none; }
}

/* Buttons — grey palette */
.btn {
  border-radius: var(--tpt-radius);
  font-weight: 500;
  padding: .5rem .9rem;
  font-family: inherit;
}
.btn-primary, .btn-dark {
  background: var(--tpt-btn); border-color: var(--tpt-btn); color: #fff;
}
.btn-primary:hover, .btn-dark:hover {
  background: var(--tpt-btn-hover); border-color: var(--tpt-btn-hover); color: #fff;
}
.btn-outline-dark { color: var(--tpt-fg); border-color: var(--tpt-btn); }
.btn-outline-dark:hover { background: var(--tpt-btn); color: #fff; }
.btn-light, .btn-secondary {
  background: var(--tpt-btn-light); border-color: var(--tpt-btn-light); color: var(--tpt-fg);
}
.btn-light:hover, .btn-secondary:hover {
  background: #dcdce0; border-color: #dcdce0; color: var(--tpt-fg);
}
.btn-sm { padding: .32rem .6rem; font-size: .82rem; }

/* Cards / tables */
.card {
  background: #fff;
  border: 1px solid var(--tpt-border);
  border-radius: var(--tpt-radius);
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
.card-header {
  background: #fff; border-bottom: 1px solid var(--tpt-border);
  padding: .85rem 1rem; font-weight: 600;
}
.card-body { padding: 1rem; }

.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .9rem;
}
.table th, .table td { padding: .65rem .75rem; border-bottom: 1px solid var(--tpt-border); }
.table th {
  text-align: left; font-weight: 600;
  background: var(--tpt-surface); color: var(--tpt-fg);
  position: sticky; top: 0;
}
.table tbody tr:hover { background: var(--tpt-surface); }

.form-control, .form-select {
  border-radius: var(--tpt-radius);
  border: 1px solid var(--tpt-border);
  padding: .5rem .7rem; font-family: inherit; font-size: .9rem;
  background: #fff; color: var(--tpt-fg);
}
.form-control:focus, .form-select:focus {
  border-color: #777; box-shadow: 0 0 0 .2rem rgba(0,0,0,.05);
  outline: none;
}
/* Visible keyboard focus on actionable elements (a11y) */
.btn:focus-visible, a:focus-visible, [data-toggle-sidebar]:focus-visible,
button:focus-visible, .tpt-section-head:focus-visible {
  outline: 2px solid #1a1a1a;
  outline-offset: 2px;
}
/* Field-level error state */
.form-control.is-invalid, .form-select.is-invalid {
  border-color: #b00020;
  box-shadow: 0 0 0 .15rem rgba(176,0,32,.12);
}
.invalid-feedback { color: #b00020; font-size: .78rem; margin-top: .25rem; display: block; }
/* Disabled state with sufficient contrast */
.btn:disabled, .form-control:disabled, .form-select:disabled {
  opacity: .55; cursor: not-allowed;
}
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }

.badge-soft {
  background: var(--tpt-surface-2); color: #333;
  padding: .22rem .55rem; border-radius: 999px; font-size: .72rem;
}
.badge-ok { background: #e6f4ea; color: var(--tpt-success); }
.badge-warn { background: #fff3cd; color: var(--tpt-warn); }
.badge-danger { background: #fde8e8; color: var(--tpt-danger); }

.alert {
  border-radius: var(--tpt-radius);
  padding: .65rem .85rem; font-size: .9rem;
  border: 1px solid var(--tpt-border); background: var(--tpt-surface);
}
.alert-danger { background: #fde8e8; color: var(--tpt-danger); border-color: #f5bcbc; }
.alert-success { background: #e6f4ea; color: var(--tpt-success); border-color: #bfe0c9; }

/* Stat cards for dashboard */
.stat {
  display: flex; flex-direction: column;
  padding: 1rem 1.1rem; background: #fff;
  border: 1px solid var(--tpt-border); border-radius: var(--tpt-radius);
}
.stat .label { color: var(--tpt-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.stat .value { font-size: 1.6rem; font-weight: 600; margin-top: 2px; }

/* Auth */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--tpt-surface);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: #fff; border: 1px solid var(--tpt-border);
  border-radius: var(--tpt-radius); padding: 24px;
}

/* Tables responsive on small */
@media (max-width: 767.98px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--tpt-border); border-radius: var(--tpt-radius); margin-bottom: 10px; }
  .table td { border-bottom: 1px dashed var(--tpt-border); padding: .55rem .7rem; }
  .table td:last-child { border-bottom: 0; }
  .table td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 130px;
    font-weight: 600;
    color: var(--tpt-muted);
  }
}
