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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

.app-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Animated SVG Iconography */
@keyframes icoPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.16); opacity: 0.9; }
}

@keyframes icoFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-4px); }
}

@keyframes icoGlide {
  0%, 100% { transform: translate3d(0px, 0px, 0) rotate(0deg); }
  35% { transform: translate3d(2px, -3.5px, 0) rotate(-4deg); }
  70% { transform: translate3d(-1.5px, -1.5px, 0) rotate(3deg); }
}

@keyframes icoSpinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes icoBounceSoft {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-4.5px); }
  75% { transform: translateY(1px); }
}

@keyframes icoWave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-11deg); }
  75% { transform: rotate(11deg); }
}

@keyframes icoRing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes icoCoin {
  0%, 100% { transform: scaleX(1) translateY(0); }
  50% { transform: scaleX(0.45) translateY(-2.5px); }
}

@keyframes icoTrend {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(2.5px, -3px, 0); }
}

@keyframes icoPop {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.18); }
  70% { transform: scale(0.95); }
}

@keyframes icoTwinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.2) rotate(18deg); opacity: 0.85; }
}

@keyframes icoWiggle {
  0%, 82%, 100% { transform: rotate(0deg); }
  86% { transform: rotate(-12deg); }
  92% { transform: rotate(12deg); }
  96% { transform: rotate(-6deg); }
}

@keyframes icoDrop {
  0%, 100% { transform: translateY(-1px); }
  50% { transform: translateY(3px); }
}

@keyframes icoNudgeLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-3px); }
}

@keyframes icoNudgeRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

@keyframes icoBarDance {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(0.58); }
}

@keyframes icoClockSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.pl-ico {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  overflow: visible;
  will-change: transform;
  transition: transform 0.2s ease;
}

.ico-pulse { animation: icoPulse 2.1s ease-in-out infinite; }
.ico-float { animation: icoFloat 2.4s ease-in-out infinite; }
.ico-glide { animation: icoGlide 2.8s ease-in-out infinite; }
.ico-spin-slow { animation: icoSpinSlow 8s linear infinite; }
.ico-bounce-soft { animation: icoBounceSoft 2.1s ease-in-out infinite; }
.ico-wave { animation: icoWave 2.3s ease-in-out infinite; transform-origin: center; }
.ico-ring { animation: icoRing 2.2s ease-in-out infinite; }
.ico-coin { animation: icoCoin 2.6s ease-in-out infinite; transform-origin: center; }
.ico-trend { animation: icoTrend 2s ease-in-out infinite; }
.ico-pop { animation: icoPop 2.4s ease-in-out infinite; }
.ico-twinkle { animation: icoTwinkle 2.3s ease-in-out infinite; transform-origin: center; }
.ico-wiggle { animation: icoWiggle 2.8s ease-in-out infinite; transform-origin: center; }
.ico-drop { animation: icoDrop 1.8s ease-in-out infinite; }
.ico-nudge-left { animation: icoNudgeLeft 1.9s ease-in-out infinite; }
.ico-nudge-right { animation: icoNudgeRight 1.9s ease-in-out infinite; }

.pl-ico .ico-bar-1,
.pl-ico .ico-bar-2,
.pl-ico .ico-bar-3 {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: icoBarDance 1.8s ease-in-out infinite;
}
.pl-ico .ico-bar-2 { animation-delay: 0.28s; }
.pl-ico .ico-bar-3 { animation-delay: 0.56s; }

.pl-ico .ico-clock-hand {
  transform-origin: 12px 12px;
  animation: icoClockSpin 7s linear infinite;
}

.btn:hover .pl-ico,
.project-tab:hover .pl-ico {
  transform: scale(1.14);
}

.icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(46, 139, 103, 0.16);
  flex-shrink: 0;
}

.icon-badge-light {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
}

/* Topbar Materialized */
.topbar {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--elev-1);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.12rem;
  color: var(--text-primary);
  cursor: pointer;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--elev-2);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.22rem 0.72rem 0.22rem 0.26rem;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--elev-1);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 0.68rem;
}

.avatar-lg {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

/* Container */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Material Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.52rem 0.95rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, transform 0.08s ease;
  background: var(--bg-surface);
  color: var(--text-primary);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--elev-1);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--elev-2);
}

.btn-tonal {
  background: var(--primary-soft);
  color: var(--primary-text);
  border-color: rgba(46, 139, 103, 0.22);
}

.btn-tonal:hover:not(:disabled) {
  background: #d7ede3;
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
  box-shadow: var(--elev-1);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  box-shadow: var(--elev-1);
}

.btn-danger:hover:not(:disabled) {
  background: #ad3c3c;
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-sm {
  padding: 0.38rem 0.72rem;
  font-size: 0.81rem;
}

.btn-xs {
  padding: 0.24rem 0.52rem;
  font-size: 0.75rem;
}

/* Materialized Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  margin-bottom: 0.85rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
}

label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='url'],
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.72rem;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 500;
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 139, 103, 0.16);
}

textarea {
  resize: vertical;
  min-height: 76px;
}

/* Materialized Cards & Heavier Card Text */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-2);
  padding: 1.05rem;
  font-weight: 500;
}

.card h2,
.card h3,
.card h4 {
  font-weight: 700;
  color: var(--text-primary);
}

.card p {
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.badge-success {
  background: var(--success-soft);
  color: #166647;
}

.badge-warning {
  background: var(--warning-soft);
  color: #8b5c15;
}

.badge-danger {
  background: var(--danger-soft);
  color: #932e2e;
}

.badge-info {
  background: var(--info-soft);
  color: #246476;
}

/* Progress bar */
.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--progress-gradient);
  border-radius: var(--radius-full);
  transition: width 0.25s ease;
}

.progress-fill.done {
  background: linear-gradient(90deg, #237a57, #2a9d6f);
}

/* Material Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 31, 0.48);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 60;
  overflow-y: auto;
}

.modal-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-4);
  width: 100%;
  max-width: 780px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-panel.modal-sm {
  max-width: 500px;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-subtle);
}

.modal-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.modal-body {
  padding: 1.15rem 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  background: var(--bg-subtle);
}

/* Toast */
.toast-root {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + var(--safe-bottom));
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.toast {
  background: var(--text-primary);
  color: #ffffff;
  padding: 0.72rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--elev-3);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.toast-success {
  background: #1f6f50;
}

.toast-error {
  background: #9f3030;
}

.toast-warning {
  background: #936218;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--elev-1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  text-align: left;
  padding: 0.68rem 0.82rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

.text-muted {
  color: var(--text-muted);
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-1);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.flex-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.55rem 0.85rem;
  }
  .hide-xs {
    display: none;
  }
  .modal-backdrop {
    padding: 0.5rem;
    align-items: flex-end;
  }
  .modal-panel {
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-md) var(--radius-md);
  }
  .toast-root {
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
  }
}
