:root {
	--aka-bg: #f5f7fb;
	--aka-card: #ffffff;
	--aka-border: #d9dce1;
	--aka-text: #111827;
	--aka-muted: #6b7280;
	--aka-primary: #2563eb;
	--aka-primary-700: #1d4ed8;
	--aka-warning: #b45309;
	--aka-danger: #b91c1c;
	--aka-shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
	--aka-radius: 12px;
	--aka-radius-sm: 8px;
}

.aka-md-dashboard {
	color: var(--aka-text);
}

.aka-md-toolbar {
	background: var(--aka-card);
	border: 1px solid var(--aka-border);
	border-radius: var(--aka-radius);
	padding: 12px;
	margin-bottom: 14px;
	box-shadow: var(--aka-shadow);
}

.aka-md-toolbar form {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	align-items: flex-end;
}

.aka-md-toolbar label {
	font-size: 12px;
	color: var(--aka-muted);
	font-weight: 600;
}

.aka-md-toolbar select,
.aka-md-toolbar input[type="text"],
.aka-md-toolbar input[type="search"] {
	min-height: 36px;
	padding: 6px 10px;
	border: 1px solid var(--aka-border);
	border-radius: var(--aka-radius-sm);
	background: #fff;
	font-size: 13px;
	line-height: 1.2;
}

.aka-md-date-wrap {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	flex-wrap: wrap;
}

.aka-md-date-wrap .aka-md-date-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.aka-md-date-wrap .aka-md-date-clear {
	min-height: 36px;
}

.aka-md-tabs {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin: 0 0 12px;
}

.aka-md-tab-btn {
	border: 1px solid #c8ccd2;
	background: #fff;
	padding: 8px 12px;
	border-radius: var(--aka-radius-sm);
	cursor: pointer;
	font-weight: 700;
	font-size: 13px;
	line-height: 1.1;
}

.aka-md-tab-btn.is-active {
	background: #1f2937;
	color: #fff;
	border-color: #1f2937;
}

.aka-md-panel {
	display: none;
}

.aka-md-panel.is-active {
	display: block;
}

.aka-kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 12px;
	margin: 12px 0 16px;
}

.aka-kpi-card {
	border: 1px solid var(--aka-border);
	border-radius: var(--aka-radius);
	background: var(--aka-card);
	padding: 12px;
	box-shadow: var(--aka-shadow);
}

.aka-kpi-card h4 {
	margin: 0 0 8px;
	font-size: 13px;
	color: #4b5563;
	font-weight: 700;
}

.aka-kpi-value {
	font-size: 24px;
	line-height: 1.1;
	font-weight: 800;
	color: #111827;
}

.aka-kpi-prev {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	color: #6b7280;
}

.aka-card {
	background: var(--aka-card);
	border: 1px solid var(--aka-border);
	border-radius: var(--aka-radius);
	padding: 12px;
	margin-bottom: 14px;
	box-shadow: var(--aka-shadow);
}

.aka-card h3,
.aka-card h4 {
	margin: 0 0 10px;
}

.aka-chart-wrap {
	width: 100%;
	height: 320px;
}

.aka-pie-row {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 16px;
}

.aka-pie-box canvas {
	max-height: 260px;
}

.aka-sortable {
	width: 100%;
	border-collapse: collapse;
}

.aka-sortable th,
.aka-sortable td {
	border: 1px solid #e5e7eb;
	padding: 7px;
	font-size: 13px;
	vertical-align: top;
}

.aka-sortable th {
	background: #f9fafb;
	text-align: left;
}

.aka-badge {
	display: inline-block;
	padding: 2px 7px;
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
}

.aka-badge-lifetime {
	background: #facc15;
	color: #111827;
}

.aka-badge-exchange {
	background: #7c3aed;
	color: #fff;
}

.aka-badge-regular {
	background: #2563eb;
	color: #fff;
}

.aka-pill {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 999px;
	color: #fff;
	font-size: 11px;
	font-weight: 700;
}

.aka-pill-checkout { background: #0ea5e9; }
.aka-pill-manual { background: #6b7280; }
.aka-pill-ontime { background: #16a34a; }
.aka-pill-comeback { background: #dc2626; }

.aka-warning {
	display: inline-block;
	margin-left: 6px;
	color: var(--aka-warning);
	font-size: 12px;
	font-weight: 700;
}

/* DataTables */
.aka-md-dashboard .dataTables_wrapper {
	margin-top: 8px;
}

.aka-md-dashboard .dataTables_wrapper .dataTables_filter input,
.aka-md-dashboard .dataTables_wrapper .dataTables_length select {
	border: 1px solid var(--aka-border);
	border-radius: 8px;
	padding: 5px 8px;
	background: #fff;
}

.aka-md-dashboard .dt-buttons {
	display: inline-flex;
	gap: 8px;
	margin-bottom: 8px;
	flex-wrap: wrap;
}

.aka-md-dashboard .dt-button,
.aka-md-dashboard button.dt-button,
.aka-md-dashboard a.dt-button {
	border-radius: 8px !important;
	border: 1px solid #c7ccd3 !important;
	background: #fff !important;
	color: #111827 !important;
	padding: 6px 10px !important;
	font-size: 12px !important;
	line-height: 1.2 !important;
}

.aka-md-dashboard .dt-button:hover {
	background: #f4f6f9 !important;
}

/* Sticky DataTable headers */
.aka-md-dashboard table.dataTable thead th,
.aka-md-dashboard .aka-datatable thead th {
	position: sticky;
	top: 0;
	z-index: 3;
	background: #f9fafb;
}

/* Notes: modal-based mode */
.aka-note-cell {
	min-width: 230px;
}

.aka-note-editor.aka-note-enhanced .aka-note-input,
.aka-note-editor.aka-note-enhanced .aka-note-controls,
.aka-note-editor.aka-note-enhanced .aka-note-status {
	display: none !important;
}

.aka-note-trigger-wrap {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.aka-note-open {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	border: 1px solid #c7ccd3;
	border-radius: 8px;
	padding: 6px 8px;
	font-size: 12px;
	font-weight: 700;
	background: #fff;
	color: #111827;
	cursor: pointer;
}

.aka-note-open:hover {
	background: #f4f6f9;
}

.aka-note-preview {
	font-size: 12px;
	line-height: 1.35;
	color: #374151;
	white-space: pre-wrap;
	word-break: break-word;
	max-height: 68px;
	overflow: hidden;
}

/* Modal */
.aka-note-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(17, 24, 39, 0.45);
	display: none;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	padding: 20px;
}

.aka-note-modal-overlay.is-open {
	display: flex;
}

.aka-note-modal {
	width: min(680px, 100%);
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 24px 50px rgba(0, 0, 0, 0.24);
	overflow: hidden;
	border: 1px solid #d3d8df;
}

.aka-note-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #e5e7eb;
}

.aka-note-modal-head h4 {
	margin: 0;
	font-size: 16px;
}

.aka-note-modal-close {
	border: 0;
	background: transparent;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	padding: 0 2px;
	color: #6b7280;
}

.aka-note-modal-body {
	padding: 14px 16px;
}

.aka-note-modal-text {
	width: 100%;
	min-height: 180px;
	resize: vertical;
	padding: 10px;
	border: 1px solid #c9d0d9;
	border-radius: 8px;
	font-size: 14px;
	line-height: 1.4;
}

.aka-note-modal-foot {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 16px 16px;
	border-top: 1px solid #eef1f5;
}

.aka-note-modal-status {
	padding: 0 16px 10px;
	font-size: 12px;
	color: var(--aka-muted);
}

.aka-note-modal-status.is-error {
	color: var(--aka-danger);
}

.aka-md-toast {
	position: fixed;
	right: 16px;
	bottom: 16px;
	background: #111827;
	color: #fff;
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 12px;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.2s ease, transform 0.2s ease;
	z-index: 100000;
}

.aka-md-toast.is-visible {
	opacity: 1;
	transform: translateY(0);
}

.aka-md-letter-template-manager {
	margin: 0 0 14px;
	padding: 14px 16px;
	border: 1px solid #d8dee6;
	border-radius: 12px;
	background: #fbfdff;
}

.aka-md-letter-template-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
}

.aka-md-letter-template-head h5 {
	margin: 0 0 4px;
	font-size: 18px;
}

.aka-md-letter-template-head p {
	margin: 0;
	color: var(--aka-muted);
}

.aka-md-letter-template-meta {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 8px 14px;
	margin-top: 12px;
	font-size: 13px;
	color: #334155;
}

.aka-md-template-notice {
	margin-top: 12px;
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 13px;
}

.aka-md-template-notice.is-success {
	background: #ecfdf3;
	border: 1px solid #86efac;
	color: #166534;
}

.aka-md-template-notice.is-error {
	background: #fef2f2;
	border: 1px solid #fca5a5;
	color: #b91c1c;
}

.aka-md-letter-template-panel {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px solid #e5e7eb;
}

.aka-md-template-upload-form {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 14px;
	align-items: end;
}

.aka-md-template-upload-form label {
	display: grid;
	gap: 6px;
	font-size: 13px;
}

.aka-md-template-tag-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
	gap: 8px;
	margin: 14px 0;
}

.aka-md-template-tag {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	padding: 10px 12px;
	border: 1px solid #d5dbe3;
	border-radius: 10px;
	background: #fff;
	cursor: pointer;
	text-align: left;
}

.aka-md-template-tag span {
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
	font-size: 13px;
	font-weight: 700;
}

.aka-md-template-tag small {
	color: var(--aka-muted);
}

.aka-md-template-editor-grid {
	display: grid;
	grid-template-columns: minmax(320px, 1.1fr) minmax(280px, 0.9fr);
	gap: 16px;
}

.aka-md-template-editor-col,
.aka-md-template-preview-col {
	display: grid;
	gap: 8px;
}

.aka-md-template-preview-col h6 {
	margin: 0;
	font-size: 15px;
}

.aka-md-template-body {
	width: 100%;
	min-height: 320px;
	padding: 10px 12px;
	border: 1px solid #c9d0d9;
	border-radius: 10px;
	font-size: 14px;
	line-height: 1.5;
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.aka-md-template-editor-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.aka-md-letter-preview-doc {
	min-height: 320px;
	padding: 18px 20px;
	border: 1px solid #d9e0ea;
	border-radius: 12px;
	background: #fff;
	box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.aka-md-letter-preview-head {
	margin-bottom: 14px;
	font-size: 13px;
	color: var(--aka-muted);
}

.aka-md-letter-preview-body p {
	margin: 0 0 14px;
	line-height: 1.55;
	white-space: normal;
}

.aka-md-letter-preview-date {
	margin-top: 20px;
	text-align: right;
	font-size: 13px;
	color: #334155;
}

@media (max-width: 820px) {
	.aka-kpi-grid {
		grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
	}

	.aka-md-toolbar form {
		gap: 8px;
	}

	.aka-md-letter-template-head,
	.aka-md-template-editor-grid {
		grid-template-columns: 1fr;
		display: grid;
	}
}

@media print {
	.aka-md-tabs,
	.aka-md-toolbar,
	.dt-buttons,
	.dataTables_filter,
	.dataTables_length,
	.dataTables_info,
	.dataTables_paginate,
	.aka-note-open,
	.aka-note-modal-overlay,
	.aka-md-toast,
	.aka-md-letter-template-manager {
		display: none !important;
	}

	.aka-note-editor .aka-note-text-print {
		display: block !important;
	}

	.aka-note-editor .aka-note-input,
	.aka-note-editor .aka-note-controls,
	.aka-note-editor .aka-note-status {
		display: none !important;
	}

	.aka-md-panel {
		display: block !important;
	}

	.aka-md-panel + .aka-md-panel {
		margin-top: 20px;
	}

	.aka-card {
		box-shadow: none !important;
	}
}
