@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #f8f9fa;
  --card: #ffffff;
  --text: #212529;
  --muted: #6c757d;
  --accent: #0d6efd;
  --accent-soft: #cfe2ff;
  --danger: #dc3545;
  --success: #198754;
  --border: #dee2e6;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
  --glow: 0 0 8px rgba(var(--accent-rgb), 0.5);

  /* Noise texture */
  --noise-url: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.02"/></svg>');
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216;
  --card: #171c22;
  --text: #e9edf2;
  --muted: #a4acb6;
  --accent: #5c8dff;
  --accent-soft: #2a3550;
  --danger: #ff6b6b;
  --success: #3ddc97;
  --border: #2a313a;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
  --glow: 0 0 8px rgba(92, 141, 255, 0.4);
  --noise-url: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.03"/></svg>');
}

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

body {
  font-family: 'Poppins', "Pretendard", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  padding: clamp(1rem, 5vw, 3rem);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  background: var(--noise-url);
  z-index: -1;
}

h1 {
  font-size: clamp(2rem, 1.5rem + 1.5vw, 3rem);
  font-weight: 700;
  margin: 4px 0 8px;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

p, label, small, li, span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 500px), 1fr));
  gap: 32px;
  margin-top: 32px;
}

/* Page-specific layout helpers */
.page-single main {
  display: block;
}

.page-single .card {
  max-width: 980px;
  margin: 0 auto;
}

.page-single .table-scroll {
  max-height: 70vh;
}

.page-single .grid-form {
  max-width: 720px;
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

.app-footer {
    text-align: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.app-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

.brand-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand-logo {
  width: clamp(140px, 22vw, 220px);
  max-width: 80vw;
  height: auto;
  display: block;
  margin: 0 0 8px var(--logo-nudge, 0px);
  object-fit: contain;
}


.kicker {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.subtext {
  font-size: 1rem;
  max-width: 60ch;
}

.header-subrow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.link-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card.highlight {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

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

input, select, textarea, button {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg);
    transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
    cursor: pointer;
    background: var(--accent);
    color: white;
    font-weight: 600;
    border: none;
}

button:hover {
    filter: brightness(1.1);
}

button.secondary {
    background: var(--muted);
}

button.danger {
    background: var(--danger);
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, minmax(80px, 1fr));
    gap: 10px;
}

.keypad button {
    padding: 14px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.keypad button:hover {
    filter: brightness(0.98);
}

/* Shadow DOM buttons (custom-button) */
:host(.compact) button {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.actions {
    display: flex;
    gap: 12px;
}

.actions custom-button.compact::part(button),
.actions custom-button.compact button {
    padding: 8px 12px;
    font-size: 0.85rem;
}

custom-button.mini::part(button),
custom-button.mini button {
    padding: 6px 8px;
    font-size: 0.75rem;
}

.actions {
    flex-wrap: wrap;
    align-items: center;
}

.session-timer {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--text);
    font-weight: 600;
}

.session-timer span {
    color: var(--text);
}

.table-scroll {
    overflow-x: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.daily-table {
    table-layout: fixed;
    white-space: normal;
}

.daily-table th,
.daily-table td {
    word-break: break-word;
}

.daily-table .actions-cell {
    white-space: nowrap;
}

.daily-table .status-open {
    color: var(--danger);
    font-weight: 600;
}

thead {
    background: var(--bg);
}

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

th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--muted);
}

.right { text-align: right; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.summary-card {
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.summary-card span {
    font-size: 0.9rem;
}

.summary-card strong {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 4px 0;
}

.donut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 16px 0 24px;
}

.donut-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.donut-wrap {
    position: relative;
    width: 220px;
    height: 220px;
    margin: 12px auto 0;
}

.donut {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--accent) 0deg 360deg);
    position: relative;
}

.donut::after {
    content: "";
    position: absolute;
    inset: 22%;
    background: var(--card);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.donut-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    text-align: center;
    pointer-events: none;
}

.donut-center span {
    font-size: 0.85rem;
    color: var(--muted);
}

.donut-center strong {
    display: block;
    font-size: 1.2rem;
    color: var(--text);
    margin-top: 4px;
}

.donut-legend {
    list-style: none;
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.donut-legend li {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    font-size: 0.9rem;
}

.donut-legend .label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.donut-legend .dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
}

.donut-legend .bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.donut-legend .bar {
    height: 100%;
    border-radius: 999px;
}

.donut-legend .bar-value {
    min-width: 90px;
    text-align: right;
    color: var(--text);
}

dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0;
    max-width: 500px;
    width: 90%;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.dialog-form {
    padding: 32px;
}
